Ring Documentation, Release 1.5.2
ok
if aMouseList[GE_MOUSE_Y] < oSelf.Y # up
cFunc = oself.keypress
call cFunc(oGame,oSelf,Key_up)
else
cFunc = oself.keypress
call cFunc(oGame,oSelf,Key_down)
ok
ok
}
}
addenemy(oGame,600)
addenemy(oGame,900)
addenemy(oGame,1550)
addenemy(oGame,2350)
addenemy(oGame,3350)
addenemy(oGame,3500)
addenemy(oGame,3670)
addenemy(oGame,3840)
text {
animate = false
point = 400
size = 30
file = "fonts/pirulen.ttf"
text = "Score : " + oGameState.score
x = 500 y=0
state = func oGame,oSelf {
oSelf { text = "Score : " + oGameState.score }
}
}
text {
animate = false
point = 400
size = 30
file = "fonts/pirulen.ttf"
text = "Energy : " + oGameState.value
x = 10 y=0
state = func oGame,oSelf { oSelf { text = "Energy : " + oGameState.value } }
}
}
func inlist nValue,aList
for x in aList
if x = nValue
return true
ok
next
return false
func checkwall oGame,oself,diffx,diffy
alist = [1,2,3]
return checkwall2(oGame,oself,diffx,diffy,aList)
func checkwall2 oGame,oself,diffx,diffy,aList
52.29. Super Man 2016 Game 485
Ring Documentation, Release 1.5.2
xPos = oSelf.x + diffx
yPos = oSelf.y + diffy
nValue = oGame.aObjects[2].getvalue(xPos,yPos)
nValue = inlist(nValue,aList)
nValue = not nValue
if nValue = 0 return nValue ok
xPos = oSelf.x + diffx
yPos = oSelf.y + diffy + oSelf.height
nValue = oGame.aObjects[2].getvalue(xPos,yPos)
nValue = inlist(nValue,aList)
nValue = not nValue
if nValue = 0 return nValue ok
xPos = oSelf.x + diffx + oSelf.width
yPos = oSelf.y + diffy
nValue = oGame.aObjects[2].getvalue(xPos,yPos)
nValue = inlist(nValue,aList)
nValue = not nValue
if nValue = 0 return nValue ok
xPos = oSelf.x + diffx + oSelf.width
yPos = oSelf.y + diffy + oSelf.height
nValue = oGame.aObjects[2].getvalue(xPos,yPos)
nValue = inlist(nValue,aList)
nValue = not nValue
if nValue = 0 return nValue ok
return nValue
func checkopenwall oGame
if oGameState.score = 900
oGame.aObjects[2].aMap[3][10] = 3
oGame.aObjects[2].aMap[4][10] = 0
oGame.aObjects[2].aMap[5][10] = 0
oGame.aObjects[2].aMap[6][10] = 0
oGame.aObjects[2].aMap[7][10] = 0
oGame.aObjects[2].aMap[8][10] = 0
but oGameState.score = 1800
oGame.aObjects[2].aMap[3][18] = 3
oGame.aObjects[2].aMap[4][18] = 0
oGame.aObjects[2].aMap[5][18] = 0
oGame.aObjects[2].aMap[6][18] = 0
oGame.aObjects[2].aMap[7][18] = 0
oGame.aObjects[2].aMap[8][18] = 0
but oGameState.score = 5500
oGame.aObjects[2].aMap[1][44] = 0
oGame.aObjects[2].aMap[2][44] = 0
oGame.aObjects[2].aMap[3][44] = 2
ok
func checkgameover ogame
if oGameState.gameresult return ok
if oGameState.value <= 0
oGameState.value = 0
oGameState.gameresult = true
oGame {
52.29. Super Man 2016 Game 486
Ring Documentation, Release 1.5.2
text {
point = 400
size = 30
nStep = 9
file = "fonts/pirulen.ttf"
text = "Game Over !!!"
x = 500 y=10
state = func ogame,oself {
if oself.y >= 400
ogame.shutdown = true
ok
}
}
}
showfire(oGame,oGame.aObjects[oGameState.PlayerIndex].x+40,
oGame.aObjects[oGameState.PlayerIndex].y+40)
oGame.aObjects[oGameState.PlayerIndex].enabled = false
oGame.remove(oGameState.PlayerIndex)
ok
func showfire oGame,nX,nY
oGame {
animate {
file = "images/fire.png"
x = nX
y = nY
framewidth = 40
height = 42
nStep = 3
transparent = true
state = func oGame,oSelf {
oSelf {
nStep--
if nStep = 0
nStep = 3
if frame < 13
frame++
else
frame=1
oGame.remove(oself.nIndex)
ok
ok
}
}
}
}
func addenemy oGame,xPos
oGame {
lbraceend = false
sprite {
type = ge_type_enemy
file = "images/smenemy.png"
transparent = true
x = xPos y =10 width=100 height=100
animate=true Scaled=true
direction = GE_DIRECTION_NOMOVE
52.29. Super Man 2016 Game 487
Ring Documentation, Release 1.5.2
temp = xPos
state = func oGame,oSelf {
oself {
x = oSelf.temp + oGame.aObjects[2].x
if y < 0 y = 0 ok
if y > 100 y=100 ok
if x > SCREEN_W or x < 0 return ok
}
if random(10) = 1
if oGameState.gameresult return ok
ogame {
sprite {
type = ge_type_fire
file = "images/smrocket.png"
scaled = true
transparent = true
x = oself.x + 30
y = oself.y + oself.height+ 30
width = 30
height = 30
point = ogame.screen_h+30
nstep = 30
direction = ge_direction_incvertical
xvalue = oGame.aObjects[2].x
temp = oself.x + 30 - xvalue
state = func oGame,oSelf {
oself { x = oSelf.temp + oGame.aObjects[2].x }
x = oGame.aObjects[oGameState.playerindex]
if oself.x >= x.x and oself.y >= x.y and
oself.x <= x.x + x.width and
oself.y <= x.y + x.height
if oGameState.value > 0
oGameState.value-=1000
ok
ogame.remove(oself.nindex)
checkgameover(oGame)
ok
}
}
}
ok
}
}
}
ogame.lbraceend = true
func checkstarskey oGame,oSelf,nValue,nRow,nCol
switch nValue
on 4
oGame.aObjects[2].aMap[nRow][nCol] = 6
oGameState.Score += 100
checkopenwall(oGame)
oGame { Sound {
once = true
file = "sound/sfx_point.wav"
} }
52.29. Super Man 2016 Game 488
Ring Documentation, Release 1.5.2
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 489
Ring Documentation, Release 1.5.2
52.29. Super Man 2016 Game 490
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
491
Ring Documentation, Release 1.5.2
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 492
Ring Documentation, Release 1.5.2
ant debug
53.3. Building the project 493
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
494

More Related Content

PDF
The Ring programming language version 1.6 book - Part 55 of 189
PDF
The Ring programming language version 1.8 book - Part 59 of 202
PDF
The Ring programming language version 1.3 book - Part 42 of 88
PDF
The Ring programming language version 1.5.3 book - Part 62 of 184
PDF
The Ring programming language version 1.5 book - Part 9 of 31
PDF
The Ring programming language version 1.5.1 book - Part 49 of 180
PDF
The Ring programming language version 1.9 book - Part 62 of 210
PDF
The Ring programming language version 1.8 book - Part 57 of 202
The Ring programming language version 1.6 book - Part 55 of 189
The Ring programming language version 1.8 book - Part 59 of 202
The Ring programming language version 1.3 book - Part 42 of 88
The Ring programming language version 1.5.3 book - Part 62 of 184
The Ring programming language version 1.5 book - Part 9 of 31
The Ring programming language version 1.5.1 book - Part 49 of 180
The Ring programming language version 1.9 book - Part 62 of 210
The Ring programming language version 1.8 book - Part 57 of 202

What's hot (20)

PDF
The Ring programming language version 1.5.4 book - Part 53 of 185
PDF
The Ring programming language version 1.9 book - Part 60 of 210
PDF
The Ring programming language version 1.7 book - Part 57 of 196
PDF
The Ring programming language version 1.5.2 book - Part 66 of 181
PDF
The Ring programming language version 1.2 book - Part 38 of 84
PDF
The Ring programming language version 1.10 book - Part 64 of 212
PDF
What Have The Properties Ever Done For Us
PDF
The Ring programming language version 1.9 book - Part 53 of 210
PDF
The Ring programming language version 1.2 book - Part 39 of 84
PDF
The Ring programming language version 1.5.2 book - Part 51 of 181
PDF
The Ring programming language version 1.10 book - Part 81 of 212
PDF
The Ring programming language version 1.5.4 book - Part 50 of 185
PDF
The Ring programming language version 1.5.1 book - Part 60 of 180
PDF
The Ring programming language version 1.5.4 book - Part 52 of 185
PDF
The Ring programming language version 1.8 book - Part 56 of 202
PDF
The Ring programming language version 1.5.1 book - Part 48 of 180
PPTX
Raspberry Pi à la GroovyFX
PDF
The Ring programming language version 1.5.3 book - Part 61 of 184
PDF
The Ring programming language version 1.5.2 book - Part 64 of 181
PDF
The Ring programming language version 1.10 book - Part 63 of 212
The Ring programming language version 1.5.4 book - Part 53 of 185
The Ring programming language version 1.9 book - Part 60 of 210
The Ring programming language version 1.7 book - Part 57 of 196
The Ring programming language version 1.5.2 book - Part 66 of 181
The Ring programming language version 1.2 book - Part 38 of 84
The Ring programming language version 1.10 book - Part 64 of 212
What Have The Properties Ever Done For Us
The Ring programming language version 1.9 book - Part 53 of 210
The Ring programming language version 1.2 book - Part 39 of 84
The Ring programming language version 1.5.2 book - Part 51 of 181
The Ring programming language version 1.10 book - Part 81 of 212
The Ring programming language version 1.5.4 book - Part 50 of 185
The Ring programming language version 1.5.1 book - Part 60 of 180
The Ring programming language version 1.5.4 book - Part 52 of 185
The Ring programming language version 1.8 book - Part 56 of 202
The Ring programming language version 1.5.1 book - Part 48 of 180
Raspberry Pi à la GroovyFX
The Ring programming language version 1.5.3 book - Part 61 of 184
The Ring programming language version 1.5.2 book - Part 64 of 181
The Ring programming language version 1.10 book - Part 63 of 212
Ad

Similar to The Ring programming language version 1.5.2 book - Part 52 of 181 (19)

PDF
The Ring programming language version 1.5.1 book - Part 51 of 180
PDF
The Ring programming language version 1.7 book - Part 55 of 196
PDF
The Ring programming language version 1.5.3 book - Part 50 of 184
PDF
The Ring programming language version 1.5.3 book - Part 60 of 184
PDF
The Ring programming language version 1.3 book - Part 40 of 88
PDF
The Ring programming language version 1.10 book - Part 61 of 212
PDF
The Ring programming language version 1.3 book - Part 43 of 88
PDF
The Ring programming language version 1.2 book - Part 40 of 84
PDF
The Ring programming language version 1.4.1 book - Part 15 of 31
PDF
The Ring programming language version 1.5.4 book - Part 51 of 185
PDF
The Ring programming language version 1.5.2 book - Part 50 of 181
PDF
The Ring programming language version 1.6 book - Part 54 of 189
PDF
The Ring programming language version 1.10 book - Part 70 of 212
PDF
The Ring programming language version 1.9 book - Part 63 of 210
PDF
The Ring programming language version 1.6 book - Part 53 of 189
DOCX
Create xo game in android studio
PDF
The Ring programming language version 1.4 book - Part 15 of 30
PDF
The Ring programming language version 1.7 book - Part 56 of 196
PDF
The Ring programming language version 1.10 book - Part 62 of 212
The Ring programming language version 1.5.1 book - Part 51 of 180
The Ring programming language version 1.7 book - Part 55 of 196
The Ring programming language version 1.5.3 book - Part 50 of 184
The Ring programming language version 1.5.3 book - Part 60 of 184
The Ring programming language version 1.3 book - Part 40 of 88
The Ring programming language version 1.10 book - Part 61 of 212
The Ring programming language version 1.3 book - Part 43 of 88
The Ring programming language version 1.2 book - Part 40 of 84
The Ring programming language version 1.4.1 book - Part 15 of 31
The Ring programming language version 1.5.4 book - Part 51 of 185
The Ring programming language version 1.5.2 book - Part 50 of 181
The Ring programming language version 1.6 book - Part 54 of 189
The Ring programming language version 1.10 book - Part 70 of 212
The Ring programming language version 1.9 book - Part 63 of 210
The Ring programming language version 1.6 book - Part 53 of 189
Create xo game in android studio
The Ring programming language version 1.4 book - Part 15 of 30
The Ring programming language version 1.7 book - Part 56 of 196
The Ring programming language version 1.10 book - Part 62 of 212
Ad

More from Mahmoud Samir Fayed (20)

PDF
The Ring programming language version 1.10 book - Part 212 of 212
PDF
The Ring programming language version 1.10 book - Part 211 of 212
PDF
The Ring programming language version 1.10 book - Part 210 of 212
PDF
The Ring programming language version 1.10 book - Part 208 of 212
PDF
The Ring programming language version 1.10 book - Part 207 of 212
PDF
The Ring programming language version 1.10 book - Part 205 of 212
PDF
The Ring programming language version 1.10 book - Part 206 of 212
PDF
The Ring programming language version 1.10 book - Part 204 of 212
PDF
The Ring programming language version 1.10 book - Part 203 of 212
PDF
The Ring programming language version 1.10 book - Part 202 of 212
PDF
The Ring programming language version 1.10 book - Part 201 of 212
PDF
The Ring programming language version 1.10 book - Part 200 of 212
PDF
The Ring programming language version 1.10 book - Part 199 of 212
PDF
The Ring programming language version 1.10 book - Part 198 of 212
PDF
The Ring programming language version 1.10 book - Part 197 of 212
PDF
The Ring programming language version 1.10 book - Part 196 of 212
PDF
The Ring programming language version 1.10 book - Part 195 of 212
PDF
The Ring programming language version 1.10 book - Part 194 of 212
PDF
The Ring programming language version 1.10 book - Part 193 of 212
PDF
The Ring programming language version 1.10 book - Part 192 of 212
The Ring programming language version 1.10 book - Part 212 of 212
The Ring programming language version 1.10 book - Part 211 of 212
The Ring programming language version 1.10 book - Part 210 of 212
The Ring programming language version 1.10 book - Part 208 of 212
The Ring programming language version 1.10 book - Part 207 of 212
The Ring programming language version 1.10 book - Part 205 of 212
The Ring programming language version 1.10 book - Part 206 of 212
The Ring programming language version 1.10 book - Part 204 of 212
The Ring programming language version 1.10 book - Part 203 of 212
The Ring programming language version 1.10 book - Part 202 of 212
The Ring programming language version 1.10 book - Part 201 of 212
The Ring programming language version 1.10 book - Part 200 of 212
The Ring programming language version 1.10 book - Part 199 of 212
The Ring programming language version 1.10 book - Part 198 of 212
The Ring programming language version 1.10 book - Part 197 of 212
The Ring programming language version 1.10 book - Part 196 of 212
The Ring programming language version 1.10 book - Part 195 of 212
The Ring programming language version 1.10 book - Part 194 of 212
The Ring programming language version 1.10 book - Part 193 of 212
The Ring programming language version 1.10 book - Part 192 of 212

Recently uploaded (20)

PDF
zbrain.ai-Scope Key Metrics Configuration and Best Practices.pdf
PDF
Transform-Your-Supply-Chain-with-AI-Driven-Quality-Engineering.pdf
PDF
NewMind AI Weekly Chronicles – August ’25 Week IV
PPTX
Module 1 Introduction to Web Programming .pptx
PDF
Dell Pro Micro: Speed customer interactions, patient processing, and learning...
PDF
Build Real-Time ML Apps with Python, Feast & NoSQL
PDF
Human Computer Interaction Miterm Lesson
PDF
Connector Corner: Transform Unstructured Documents with Agentic Automation
PDF
giants, standing on the shoulders of - by Daniel Stenberg
PDF
The-2025-Engineering-Revolution-AI-Quality-and-DevOps-Convergence.pdf
PDF
substrate PowerPoint Presentation basic one
PDF
Rapid Prototyping: A lecture on prototyping techniques for interface design
PDF
Data Virtualization in Action: Scaling APIs and Apps with FME
PDF
Lung cancer patients survival prediction using outlier detection and optimize...
PDF
Electrocardiogram sequences data analytics and classification using unsupervi...
PDF
Introduction to MCP and A2A Protocols: Enabling Agent Communication
PDF
A symptom-driven medical diagnosis support model based on machine learning te...
PDF
Transform-Your-Factory-with-AI-Driven-Quality-Engineering.pdf
PDF
Co-training pseudo-labeling for text classification with support vector machi...
PDF
4 layer Arch & Reference Arch of IoT.pdf
zbrain.ai-Scope Key Metrics Configuration and Best Practices.pdf
Transform-Your-Supply-Chain-with-AI-Driven-Quality-Engineering.pdf
NewMind AI Weekly Chronicles – August ’25 Week IV
Module 1 Introduction to Web Programming .pptx
Dell Pro Micro: Speed customer interactions, patient processing, and learning...
Build Real-Time ML Apps with Python, Feast & NoSQL
Human Computer Interaction Miterm Lesson
Connector Corner: Transform Unstructured Documents with Agentic Automation
giants, standing on the shoulders of - by Daniel Stenberg
The-2025-Engineering-Revolution-AI-Quality-and-DevOps-Convergence.pdf
substrate PowerPoint Presentation basic one
Rapid Prototyping: A lecture on prototyping techniques for interface design
Data Virtualization in Action: Scaling APIs and Apps with FME
Lung cancer patients survival prediction using outlier detection and optimize...
Electrocardiogram sequences data analytics and classification using unsupervi...
Introduction to MCP and A2A Protocols: Enabling Agent Communication
A symptom-driven medical diagnosis support model based on machine learning te...
Transform-Your-Factory-with-AI-Driven-Quality-Engineering.pdf
Co-training pseudo-labeling for text classification with support vector machi...
4 layer Arch & Reference Arch of IoT.pdf

The Ring programming language version 1.5.2 book - Part 52 of 181

  • 1. Ring Documentation, Release 1.5.2 ok if aMouseList[GE_MOUSE_Y] < oSelf.Y # up cFunc = oself.keypress call cFunc(oGame,oSelf,Key_up) else cFunc = oself.keypress call cFunc(oGame,oSelf,Key_down) ok ok } } addenemy(oGame,600) addenemy(oGame,900) addenemy(oGame,1550) addenemy(oGame,2350) addenemy(oGame,3350) addenemy(oGame,3500) addenemy(oGame,3670) addenemy(oGame,3840) text { animate = false point = 400 size = 30 file = "fonts/pirulen.ttf" text = "Score : " + oGameState.score x = 500 y=0 state = func oGame,oSelf { oSelf { text = "Score : " + oGameState.score } } } text { animate = false point = 400 size = 30 file = "fonts/pirulen.ttf" text = "Energy : " + oGameState.value x = 10 y=0 state = func oGame,oSelf { oSelf { text = "Energy : " + oGameState.value } } } } func inlist nValue,aList for x in aList if x = nValue return true ok next return false func checkwall oGame,oself,diffx,diffy alist = [1,2,3] return checkwall2(oGame,oself,diffx,diffy,aList) func checkwall2 oGame,oself,diffx,diffy,aList 52.29. Super Man 2016 Game 485
  • 2. Ring Documentation, Release 1.5.2 xPos = oSelf.x + diffx yPos = oSelf.y + diffy nValue = oGame.aObjects[2].getvalue(xPos,yPos) nValue = inlist(nValue,aList) nValue = not nValue if nValue = 0 return nValue ok xPos = oSelf.x + diffx yPos = oSelf.y + diffy + oSelf.height nValue = oGame.aObjects[2].getvalue(xPos,yPos) nValue = inlist(nValue,aList) nValue = not nValue if nValue = 0 return nValue ok xPos = oSelf.x + diffx + oSelf.width yPos = oSelf.y + diffy nValue = oGame.aObjects[2].getvalue(xPos,yPos) nValue = inlist(nValue,aList) nValue = not nValue if nValue = 0 return nValue ok xPos = oSelf.x + diffx + oSelf.width yPos = oSelf.y + diffy + oSelf.height nValue = oGame.aObjects[2].getvalue(xPos,yPos) nValue = inlist(nValue,aList) nValue = not nValue if nValue = 0 return nValue ok return nValue func checkopenwall oGame if oGameState.score = 900 oGame.aObjects[2].aMap[3][10] = 3 oGame.aObjects[2].aMap[4][10] = 0 oGame.aObjects[2].aMap[5][10] = 0 oGame.aObjects[2].aMap[6][10] = 0 oGame.aObjects[2].aMap[7][10] = 0 oGame.aObjects[2].aMap[8][10] = 0 but oGameState.score = 1800 oGame.aObjects[2].aMap[3][18] = 3 oGame.aObjects[2].aMap[4][18] = 0 oGame.aObjects[2].aMap[5][18] = 0 oGame.aObjects[2].aMap[6][18] = 0 oGame.aObjects[2].aMap[7][18] = 0 oGame.aObjects[2].aMap[8][18] = 0 but oGameState.score = 5500 oGame.aObjects[2].aMap[1][44] = 0 oGame.aObjects[2].aMap[2][44] = 0 oGame.aObjects[2].aMap[3][44] = 2 ok func checkgameover ogame if oGameState.gameresult return ok if oGameState.value <= 0 oGameState.value = 0 oGameState.gameresult = true oGame { 52.29. Super Man 2016 Game 486
  • 3. Ring Documentation, Release 1.5.2 text { point = 400 size = 30 nStep = 9 file = "fonts/pirulen.ttf" text = "Game Over !!!" x = 500 y=10 state = func ogame,oself { if oself.y >= 400 ogame.shutdown = true ok } } } showfire(oGame,oGame.aObjects[oGameState.PlayerIndex].x+40, oGame.aObjects[oGameState.PlayerIndex].y+40) oGame.aObjects[oGameState.PlayerIndex].enabled = false oGame.remove(oGameState.PlayerIndex) ok func showfire oGame,nX,nY oGame { animate { file = "images/fire.png" x = nX y = nY framewidth = 40 height = 42 nStep = 3 transparent = true state = func oGame,oSelf { oSelf { nStep-- if nStep = 0 nStep = 3 if frame < 13 frame++ else frame=1 oGame.remove(oself.nIndex) ok ok } } } } func addenemy oGame,xPos oGame { lbraceend = false sprite { type = ge_type_enemy file = "images/smenemy.png" transparent = true x = xPos y =10 width=100 height=100 animate=true Scaled=true direction = GE_DIRECTION_NOMOVE 52.29. Super Man 2016 Game 487
  • 4. Ring Documentation, Release 1.5.2 temp = xPos state = func oGame,oSelf { oself { x = oSelf.temp + oGame.aObjects[2].x if y < 0 y = 0 ok if y > 100 y=100 ok if x > SCREEN_W or x < 0 return ok } if random(10) = 1 if oGameState.gameresult return ok ogame { sprite { type = ge_type_fire file = "images/smrocket.png" scaled = true transparent = true x = oself.x + 30 y = oself.y + oself.height+ 30 width = 30 height = 30 point = ogame.screen_h+30 nstep = 30 direction = ge_direction_incvertical xvalue = oGame.aObjects[2].x temp = oself.x + 30 - xvalue state = func oGame,oSelf { oself { x = oSelf.temp + oGame.aObjects[2].x } x = oGame.aObjects[oGameState.playerindex] if oself.x >= x.x and oself.y >= x.y and oself.x <= x.x + x.width and oself.y <= x.y + x.height if oGameState.value > 0 oGameState.value-=1000 ok ogame.remove(oself.nindex) checkgameover(oGame) ok } } } ok } } } ogame.lbraceend = true func checkstarskey oGame,oSelf,nValue,nRow,nCol switch nValue on 4 oGame.aObjects[2].aMap[nRow][nCol] = 6 oGameState.Score += 100 checkopenwall(oGame) oGame { Sound { once = true file = "sound/sfx_point.wav" } } 52.29. Super Man 2016 Game 488
  • 5. Ring Documentation, Release 1.5.2 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 489
  • 6. Ring Documentation, Release 1.5.2 52.29. Super Man 2016 Game 490
  • 7. 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 491
  • 8. Ring Documentation, Release 1.5.2 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 492
  • 9. Ring Documentation, Release 1.5.2 ant debug 53.3. Building the project 493
  • 10. 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 494