Vous êtes sur la page 1sur 10

Ring Documentation, Release 1.5.

on 5
oGame.aObjects[2].aMap[nRow][nCol] = 0
oGameState.DoorKey = true
oGameState.Score += 500
checkopenwall(oGame)
oGame { Sound {
once = true
file = "sound/sfx_point.wav"
} }
off

func checkstarskeycol oGame,oSelf


nValue = oGame.aObjects[2].getvalue(oSelf.x,oSelf.y)
nRow = oGame.aObjects[2].getrow(oSelf.x,oSelf.y)
nCol = oGame.aObjects[2].getcol(oSelf.x,oSelf.y)
checkstarskey(oGame,oSelf,nValue,nRow,nCol)

nValue = oGame.aObjects[2].getvalue(oSelf.x+oSelf.width,oSelf.y+oSelf.height)
nRow = oGame.aObjects[2].getrow(oSelf.x+oSelf.width,oSelf.y+oSelf.height)
nCol = oGame.aObjects[2].getcol(oSelf.x+oSelf.width,oSelf.y+oSelf.height)
checkstarskey(oGame,oSelf,nValue,nRow,nCol)

nValue = oGame.aObjects[2].getvalue(oSelf.x+oSelf.width,oSelf.y)
nRow = oGame.aObjects[2].getrow(oSelf.x+oSelf.width,oSelf.y)
nCol = oGame.aObjects[2].getcol(oSelf.x+oSelf.width,oSelf.y)
checkstarskey(oGame,oSelf,nValue,nRow,nCol)

nValue = oGame.aObjects[2].getvalue(oSelf.x,oSelf.y+oSelf.height)
nRow = oGame.aObjects[2].getrow(oSelf.x,oSelf.y+oSelf.height)
nCol = oGame.aObjects[2].getcol(oSelf.x,oSelf.y+oSelf.height)
checkstarskey(oGame,oSelf,nValue,nRow,nCol)

func callenemystate oGame


for t in oGame.aObjects
t {
if type = GE_TYPE_ENEMY
call state(oGame,t)
ok
}
next

Class GameState

down = 3
gameresult = false
Score = 0
startplay=false
lastcol = 0
playerwin = false
DoorKey = false
playerindex = 4
value = 1000
moveplayer = false

Screen Shot:

52.29. Super Man 2016 Game 495


Ring Documentation, Release 1.5.3

52.29. Super Man 2016 Game 496


CHAPTER

FIFTYTHREE

BUILDING GAMES FOR ANDROID

In this chapter we will learn about Building RingLibSDL Games for Mobile.
So we can create packages (*.apk) for the applications that are developed using Ring Game Engine for 2D Games.

53.1 Download Requirements and Update the Android SDK

• The Android SDK Tools


https://developer.android.com/studio/index.html
• The Android NDK
https://developer.android.com/ndk/index.html
• Apache Ant v1.8 or later
http://ant.apache.org/bindownload.cgi
• Java SE Development Kit (JDK) v6 or later
http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
• Update the Android SDK to get the API and tools packages required for development

53.2 Project Folder

Open the project folder : ring/android/ringlibsdl/project

497
Ring Documentation, Release 1.5.3

You can add the source code (*.ring) and Images/Sound Files to the assets folder.

You will find the Flappy Bird 3000 Game ready for building.
The execution starts from the start.ring file
load "game2.ring"

53.3 Building the project

Move to the ring/android/ringlibsdl/project folder


We can build using the next command (We need to do this for one time only).
ndk-build

Then we can create the package (*.apk) using the next command.

53.3. Building the project 498


Ring Documentation, Release 1.5.3

ant debug

53.3. Building the project 499


CHAPTER

FIFTYFOUR

USING RINGOPENGL AND RINGFREEGLUT FOR 3D GRAPHICS

In this chapter we will learn about using RingOpenGL

54.1 Samples Source (Authors)

The samples in this chapter are based on C Tutorials


from
1. http://www.lighthouse3d.com/tutorials/glut-tutorial/
2. http://www.wikihow.com/Make-a-Cube-in-OpenGL

54.2 What is RingOpenGL?

RingOpenGL contains the Ring binding to the OpenGL library


You can learn about OpenGL from : https://www.opengl.org/
RingOpenGL comes with support for the next versions
• OpenGL 1.1
• OpenGL 1.2
• OpenGL 1.3
• OpenGL 1.4
• OpenGL 1.5
• OpenGL 2.0
• OpenGL 2.1
• OpenGL 3.0
• OpenGL 3.2
• OpenGL 3.3
• OpenGL 4.0
• OpenGL 4.1
• OpenGL 4.2
• OpenGL 4.3

500
Ring Documentation, Release 1.5.3

• OpenGL 4.4
• OpenGL 4.5
• OpenGL 4.6
For example, if you want to use OpenGL 2.1 then load RingOpenGL 2.1 library
load "opengl21lib.ring"

54.3 What is RingFreeGLUT?

RingFreeGLUT contains the Ring binding to the FreeGLUT library


You can learn about FreeGLUT from : http://freeglut.sourceforge.net/
To use the RingFreeGLUT library, Just load the library
load "freeglut.ring"

54.4 The First Window using RingFreeGLUT

Example:
load "freeglut.ring"

func main
glutInit()
glutInitDisplayMode(GLUT_SINGLE)
glutInitWindowSize(800, 600)
glutInitWindowPosition(100, 10)
glutCreateWindow("RingFreeGLUT - Test 1")
glutDisplayFunc(:displayCode)
glutMainLoop()

func displaycode

Screen Shot

54.3. What is RingFreeGLUT? 501


Ring Documentation, Release 1.5.3

54.5 Drawing using RingOpenGL

Example:
load "freeglut.ring"
load "opengl21lib.ring"

func main
glutInit()
glutInitDisplayMode(GLUT_SINGLE)
glutInitWindowSize(800, 600)
glutInitWindowPosition(100, 10)
glutCreateWindow("RingFreeGLUT - Test 2")
glutDisplayFunc(:displayCode)
glutMainLoop()

func displaycode
glClear(GL_COLOR_BUFFER_BIT)
glColor3f(0,255,0)
glBegin(GL_POLYGON)
glVertex3f(0.0, 0.0, 0.0)

54.5. Drawing using RingOpenGL 502


Ring Documentation, Release 1.5.3

glVertex3f(0.5, 0.0, 0.0)


glVertex3f(0.5, 0.5, 0.0)
glVertex3f(0.0, 0.5, 0.0)
glEnd()
glColor3f(255,0,0)
glBegin(GL_POLYGON)
glVertex3f(0.0, 0.0, 0.0)
glVertex3f(0.5, 0.0, 0.0)
glVertex3f(-0.5,- 1, 0.0)
glVertex3f(0.0, -1, 0.0)
glEnd()
glColor3f(0,0,255)
glBegin(GL_POLYGON)
glVertex3f(0.0, 0.0, 0.0)
glVertex3f(-0.5, 0.0, 0.0)
glVertex3f(-0.5,- 0.5, 0.0)
glVertex3f(0.0, -0.5, 0.0)
glEnd()

glFlush()

Screen Shot

54.5. Drawing using RingOpenGL 503


Ring Documentation, Release 1.5.3

54.6 The First Triangle

Example:
load "freeglut.ring"
load "opengl21lib.ring"

func main
glutInit()
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA)
glutInitWindowSize(320,320)
glutInitWindowPosition(100, 10)
glutCreateWindow("RingFreeGLUT - Test 3")
glutDisplayFunc(:renderScene)
glutMainLoop()

func renderScene

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

glBegin(GL_TRIANGLES)
glVertex3f(-0.5,-0.5,0.0)
glVertex3f(0.5,0.0,0.0)
glVertex3f(0.0,0.5,0.0)
glEnd()

glutSwapBuffers()

Screen Shot

54.6. The First Triangle 504

Vous aimerez peut-être aussi