SlideShare a Scribd company logo
Ring Documentation, Release 1.8
but nkey = key_down and checkwall(oGame,oSelf,0,40)
file = "images/supermandown.png"
dotransparent()
y += 40
if y>=500 y=500 ok
but nKey = key_right and checkwall(oGame,oSelf,10,0)
file = "images/supermanright.png"
dotransparent()
x += 10
if x >= 440
if oGame.aObjects[2].x > -4500
oGame.aObjects[2].x -= 50
callenemystate(oGame)
else
if x <= 750
if checkwall(oGame,oSelf,10,0)
x += 10
ok
else
if checkwall(oGame,oSelf,-10,0)
x -= 10
ok
ok
return
ok
x=400
ok
but nKey = key_left and checkwall(oGame,oSelf,-10,0)
file = "images/supermanleft.png"
dotransparent()
x -= 10
if x <= 0
x += 10
if oGame.aObjects[2].x != 0
oGame.aObjects[2].x += 50
callenemystate(oGame)
x += 50
ok
ok
but nkey = key_esc or nKey = GE_AC_BACK
ogame.shutdown()
ok
}
ok
}
mouse = func ogame,oself,nType,aMouseList {
if nType = GE_MOUSE_DOWN
oGameState.moveplayer = TRUE
But nType = GE_MOUSE_UP
oGameState.moveplayer = FALSE
ok
if oGameState.moveplayer = TRUE
if aMouseList[GE_MOUSE_X] < oSelf.X # left
cFunc = oself.keypress
call cFunc(oGame,oSelf,Key_left)
else
cFunc = oself.keypress
call cFunc(oGame,oSelf,Key_right)
56.29. Super Man 2016 Game 551
Ring Documentation, Release 1.8
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
56.29. Super Man 2016 Game 552
Ring Documentation, Release 1.8
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 {
56.29. Super Man 2016 Game 553
Ring Documentation, Release 1.8
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
56.29. Super Man 2016 Game 554
Ring Documentation, Release 1.8
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"
} }
56.29. Super Man 2016 Game 555
Ring Documentation, Release 1.8
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:
56.29. Super Man 2016 Game 556
Ring Documentation, Release 1.8
56.29. Super Man 2016 Game 557
CHAPTER
FIFTYSEVEN
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.
57.1 Download Requirements and Update the Android SDK
• The Android SDK Tools
https://developer.android.com/studio/index.html
• The Android NDK (Tested using android-ndk-r10c)
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
Tested using Android 4.4.2 (API 19)
• In Windows - Define the next Environment Variables based on your system.
1. JAVA_HOME
For Example : C:Program Files (x86)Javajdk1.8.0_05
2. ANDROID_HOME
For Example : B:mahmoudToolsJava-Androidadt-bundle-windows-x86-20140702sdk
57.2 Project Folder
Open the project folder : ring/android/ringlibsdl/project
558
Ring Documentation, Release 1.8
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"
57.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.
57.3. Building the project 559
Ring Documentation, Release 1.8
ant debug
57.3. Building the project 560

More Related Content

PDF
The Ring programming language version 1.7 book - Part 57 of 196
PDF
The Ring programming language version 1.5.1 book - Part 51 of 180
PDF
The Ring programming language version 1.5.2 book - Part 52 of 181
PDF
The Ring programming language version 1.10 book - Part 64 of 212
PDF
The Ring programming language version 1.5.1 book - Part 49 of 180
PDF
The Ring programming language version 1.6 book - Part 55 of 189
PDF
The Ring programming language version 1.8 book - Part 57 of 202
PPTX
Raspberry Pi à la GroovyFX
The Ring programming language version 1.7 book - Part 57 of 196
The Ring programming language version 1.5.1 book - Part 51 of 180
The Ring programming language version 1.5.2 book - Part 52 of 181
The Ring programming language version 1.10 book - Part 64 of 212
The Ring programming language version 1.5.1 book - Part 49 of 180
The Ring programming language version 1.6 book - Part 55 of 189
The Ring programming language version 1.8 book - Part 57 of 202
Raspberry Pi à la GroovyFX

What's hot (20)

PDF
The Ring programming language version 1.9 book - Part 62 of 210
PDF
The Ring programming language version 1.3 book - Part 42 of 88
PDF
The Ring programming language version 1.2 book - Part 38 of 84
PDF
The Ring programming language version 1.5 book - Part 9 of 31
KEY
Intro to Game Programming
PDF
The Ring programming language version 1.5.3 book - Part 62 of 184
PDF
The Ring programming language version 1.2 book - Part 40 of 84
KEY
Introduction to Game Programming Tutorial
PDF
The Ring programming language version 1.7 book - Part 55 of 196
PDF
The Ring programming language version 1.10 book - Part 81 of 212
PDF
The Ring programming language version 1.9 book - Part 60 of 210
PDF
The Ring programming language version 1.5.2 book - Part 66 of 181
PDF
A promise is a Promise
PDF
The Ring programming language version 1.10 book - Part 62 of 212
PDF
Node meetup feb_20_12
PDF
The Ring programming language version 1.10 book - Part 61 of 212
PDF
The Ring programming language version 1.5.4 book - Part 51 of 185
PDF
The Ring programming language version 1.2 book - Part 35 of 84
PDF
The Ring programming language version 1.10 book - Part 63 of 212
PDF
The Ring programming language version 1.9 book - Part 62 of 210
The Ring programming language version 1.3 book - Part 42 of 88
The Ring programming language version 1.2 book - Part 38 of 84
The Ring programming language version 1.5 book - Part 9 of 31
Intro to Game Programming
The Ring programming language version 1.5.3 book - Part 62 of 184
The Ring programming language version 1.2 book - Part 40 of 84
Introduction to Game Programming Tutorial
The Ring programming language version 1.7 book - Part 55 of 196
The Ring programming language version 1.10 book - Part 81 of 212
The Ring programming language version 1.9 book - Part 60 of 210
The Ring programming language version 1.5.2 book - Part 66 of 181
A promise is a Promise
The Ring programming language version 1.10 book - Part 62 of 212
Node meetup feb_20_12
The Ring programming language version 1.10 book - Part 61 of 212
The Ring programming language version 1.5.4 book - Part 51 of 185
The Ring programming language version 1.2 book - Part 35 of 84
The Ring programming language version 1.10 book - Part 63 of 212
Ad

Similar to The Ring programming language version 1.8 book - Part 59 of 202 (20)

PDF
The Ring programming language version 1.5.4 book - Part 52 of 185
PDF
The Ring programming language version 1.5.4 book - Part 53 of 185
PDF
The Ring programming language version 1.5.2 book - Part 51 of 181
PDF
The Ring programming language version 1.6 book - Part 54 of 189
PDF
The Ring programming language version 1.8 book - Part 58 of 202
PDF
The Ring programming language version 1.5.1 book - Part 50 of 180
PDF
The Ring programming language version 1.4 book - Part 15 of 30
PDF
The Ring programming language version 1.2 book - Part 37 of 84
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.6 book - Part 52 of 189
PDF
The Ring programming language version 1.2 book - Part 39 of 84
PDF
The Ring programming language version 1.8 book - Part 56 of 202
PDF
The Ring programming language version 1.6 book - Part 53 of 189
PDF
The Ring programming language version 1.5.4 book - Part 50 of 185
PDF
The Ring programming language version 1.7 book - Part 56 of 196
PDF
The Ring programming language version 1.5.1 book - Part 48 of 180
PDF
The Ring programming language version 1.5.2 book - Part 50 of 181
PDF
The Ring programming language version 1.7 book - Part 54 of 196
The Ring programming language version 1.5.4 book - Part 52 of 185
The Ring programming language version 1.5.4 book - Part 53 of 185
The Ring programming language version 1.5.2 book - Part 51 of 181
The Ring programming language version 1.6 book - Part 54 of 189
The Ring programming language version 1.8 book - Part 58 of 202
The Ring programming language version 1.5.1 book - Part 50 of 180
The Ring programming language version 1.4 book - Part 15 of 30
The Ring programming language version 1.2 book - Part 37 of 84
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.6 book - Part 52 of 189
The Ring programming language version 1.2 book - Part 39 of 84
The Ring programming language version 1.8 book - Part 56 of 202
The Ring programming language version 1.6 book - Part 53 of 189
The Ring programming language version 1.5.4 book - Part 50 of 185
The Ring programming language version 1.7 book - Part 56 of 196
The Ring programming language version 1.5.1 book - Part 48 of 180
The Ring programming language version 1.5.2 book - Part 50 of 181
The Ring programming language version 1.7 book - Part 54 of 196
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
Digital Strategies for Manufacturing Companies
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
Softaken Excel to vCard Converter Software.pdf
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
AI in Product Development-omnex systems
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PPTX
ai tools demonstartion for schools and inter college
PDF
medical staffing services at VALiNTRY
PPTX
Essential Infomation Tech presentation.pptx
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PPTX
history of c programming in notes for students .pptx
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
System and Network Administraation Chapter 3
PDF
System and Network Administration Chapter 2
PDF
PTS Company Brochure 2025 (1).pdf.......
Digital Strategies for Manufacturing Companies
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Softaken Excel to vCard Converter Software.pdf
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
AI in Product Development-omnex systems
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Operating system designcfffgfgggggggvggggggggg
Wondershare Filmora 15 Crack With Activation Key [2025
ai tools demonstartion for schools and inter college
medical staffing services at VALiNTRY
Essential Infomation Tech presentation.pptx
wealthsignaloriginal-com-DS-text-... (1).pdf
How to Migrate SBCGlobal Email to Yahoo Easily
history of c programming in notes for students .pptx
Navsoft: AI-Powered Business Solutions & Custom Software Development
System and Network Administraation Chapter 3
System and Network Administration Chapter 2
PTS Company Brochure 2025 (1).pdf.......

The Ring programming language version 1.8 book - Part 59 of 202

  • 1. Ring Documentation, Release 1.8 but nkey = key_down and checkwall(oGame,oSelf,0,40) file = "images/supermandown.png" dotransparent() y += 40 if y>=500 y=500 ok but nKey = key_right and checkwall(oGame,oSelf,10,0) file = "images/supermanright.png" dotransparent() x += 10 if x >= 440 if oGame.aObjects[2].x > -4500 oGame.aObjects[2].x -= 50 callenemystate(oGame) else if x <= 750 if checkwall(oGame,oSelf,10,0) x += 10 ok else if checkwall(oGame,oSelf,-10,0) x -= 10 ok ok return ok x=400 ok but nKey = key_left and checkwall(oGame,oSelf,-10,0) file = "images/supermanleft.png" dotransparent() x -= 10 if x <= 0 x += 10 if oGame.aObjects[2].x != 0 oGame.aObjects[2].x += 50 callenemystate(oGame) x += 50 ok ok but nkey = key_esc or nKey = GE_AC_BACK ogame.shutdown() ok } ok } mouse = func ogame,oself,nType,aMouseList { if nType = GE_MOUSE_DOWN oGameState.moveplayer = TRUE But nType = GE_MOUSE_UP oGameState.moveplayer = FALSE ok if oGameState.moveplayer = TRUE if aMouseList[GE_MOUSE_X] < oSelf.X # left cFunc = oself.keypress call cFunc(oGame,oSelf,Key_left) else cFunc = oself.keypress call cFunc(oGame,oSelf,Key_right) 56.29. Super Man 2016 Game 551
  • 2. Ring Documentation, Release 1.8 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 56.29. Super Man 2016 Game 552
  • 3. Ring Documentation, Release 1.8 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 { 56.29. Super Man 2016 Game 553
  • 4. Ring Documentation, Release 1.8 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 56.29. Super Man 2016 Game 554
  • 5. Ring Documentation, Release 1.8 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" } } 56.29. Super Man 2016 Game 555
  • 6. Ring Documentation, Release 1.8 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: 56.29. Super Man 2016 Game 556
  • 7. Ring Documentation, Release 1.8 56.29. Super Man 2016 Game 557
  • 8. CHAPTER FIFTYSEVEN 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. 57.1 Download Requirements and Update the Android SDK • The Android SDK Tools https://developer.android.com/studio/index.html • The Android NDK (Tested using android-ndk-r10c) 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 Tested using Android 4.4.2 (API 19) • In Windows - Define the next Environment Variables based on your system. 1. JAVA_HOME For Example : C:Program Files (x86)Javajdk1.8.0_05 2. ANDROID_HOME For Example : B:mahmoudToolsJava-Androidadt-bundle-windows-x86-20140702sdk 57.2 Project Folder Open the project folder : ring/android/ringlibsdl/project 558
  • 9. Ring Documentation, Release 1.8 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" 57.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. 57.3. Building the project 559
  • 10. Ring Documentation, Release 1.8 ant debug 57.3. Building the project 560