SlideShare a Scribd company logo
Ring Documentation, Release 1.6
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
53.29. Super Man 2016 Game 513
Ring Documentation, Release 1.6
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 {
53.29. Super Man 2016 Game 514
Ring Documentation, Release 1.6
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
53.29. Super Man 2016 Game 515
Ring Documentation, Release 1.6
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"
} }
53.29. Super Man 2016 Game 516
Ring Documentation, Release 1.6
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:
53.29. Super Man 2016 Game 517
Ring Documentation, Release 1.6
53.29. Super Man 2016 Game 518
CHAPTER
FIFTYFOUR
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.
54.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
54.2 Project Folder
Open the project folder : ring/android/ringlibsdl/project
519
Ring Documentation, Release 1.6
You can add the source code (*.ring) and Images/Sound Files to the assets folder.
You will nd the Flappy Bird 3000 Game ready for building.
The execution starts from the start.ring le
load "game2.ring"
54.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.
54.3. Building the project 520
Ring Documentation, Release 1.6
ant debug
54.3. Building the project 521
CHAPTER
FIFTYFIVE
USING RINGOPENGL AND RINGFREEGLUT FOR 3D GRAPHICS
In this chapter we will learn about using RingOpenGL
55.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
55.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
522

More Related Content

What's hot (20)

PDF
Building Real Time Systems on MongoDB Using the Oplog at Stripe
MongoDB
 
PDF
The Ring programming language version 1.10 book - Part 64 of 212
Mahmoud Samir Fayed
 
PDF
Building Real Time Systems on MongoDB Using the Oplog at Stripe
MongoDB
 
PDF
The Ring programming language version 1.7 book - Part 57 of 196
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.8 book - Part 57 of 202
Mahmoud Samir Fayed
 
PDF
Unbreakable: The Craft of Code
Joe Morgan
 
PDF
The Ring programming language version 1.5.1 book - Part 65 of 180
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.7 book - Part 33 of 196
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.2 book - Part 38 of 84
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.3 book - Part 63 of 184
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.2 book - Part 64 of 181
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.6 book - Part 71 of 189
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.8 book - Part 75 of 202
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.4 book - Part 66 of 185
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.7 book - Part 73 of 196
Mahmoud Samir Fayed
 
PDF
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
MongoSF
 
PDF
The Ring programming language version 1.7 book - Part 93 of 196
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 70 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.7 book - Part 72 of 196
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.8 book - Part 74 of 202
Mahmoud Samir Fayed
 
Building Real Time Systems on MongoDB Using the Oplog at Stripe
MongoDB
 
The Ring programming language version 1.10 book - Part 64 of 212
Mahmoud Samir Fayed
 
Building Real Time Systems on MongoDB Using the Oplog at Stripe
MongoDB
 
The Ring programming language version 1.7 book - Part 57 of 196
Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 57 of 202
Mahmoud Samir Fayed
 
Unbreakable: The Craft of Code
Joe Morgan
 
The Ring programming language version 1.5.1 book - Part 65 of 180
Mahmoud Samir Fayed
 
The Ring programming language version 1.7 book - Part 33 of 196
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 38 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 63 of 184
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.2 book - Part 64 of 181
Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 71 of 189
Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 75 of 202
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.4 book - Part 66 of 185
Mahmoud Samir Fayed
 
The Ring programming language version 1.7 book - Part 73 of 196
Mahmoud Samir Fayed
 
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
MongoSF
 
The Ring programming language version 1.7 book - Part 93 of 196
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 70 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.7 book - Part 72 of 196
Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 74 of 202
Mahmoud Samir Fayed
 

Similar to The Ring programming language version 1.6 book - Part 55 of 189 (20)

PDF
The Ring programming language version 1.2 book - Part 40 of 84
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.1 book - Part 51 of 180
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 63 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.3 book - Part 62 of 184
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.9 book - Part 62 of 210
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.4 book - Part 52 of 185
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.3 book - Part 42 of 88
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.1 book - Part 50 of 180
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.6 book - Part 54 of 189
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.2 book - Part 51 of 181
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.8 book - Part 58 of 202
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.4 book - Part 15 of 30
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.3 book - Part 40 of 88
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.3 book - Part 60 of 184
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.3 book - Part 50 of 184
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.9 book - Part 60 of 210
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.7 book - Part 55 of 196
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.6 book - Part 52 of 189
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.9 book - Part 63 of 210
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.6 book - Part 53 of 189
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 40 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.1 book - Part 51 of 180
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 63 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 62 of 184
Mahmoud Samir Fayed
 
The Ring programming language version 1.9 book - Part 62 of 210
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.4 book - Part 52 of 185
Mahmoud Samir Fayed
 
The Ring programming language version 1.3 book - Part 42 of 88
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.1 book - Part 50 of 180
Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 54 of 189
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.2 book - Part 51 of 181
Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 58 of 202
Mahmoud Samir Fayed
 
The Ring programming language version 1.4 book - Part 15 of 30
Mahmoud Samir Fayed
 
The Ring programming language version 1.3 book - Part 40 of 88
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 60 of 184
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 50 of 184
Mahmoud Samir Fayed
 
The Ring programming language version 1.9 book - Part 60 of 210
Mahmoud Samir Fayed
 
The Ring programming language version 1.7 book - Part 55 of 196
Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 52 of 189
Mahmoud Samir Fayed
 
The Ring programming language version 1.9 book - Part 63 of 210
Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 53 of 189
Mahmoud Samir Fayed
 
Ad

More from Mahmoud Samir Fayed (20)

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

Recently uploaded (20)

PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
PPT
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PPTX
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PPTX
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PPTX
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
PDF
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 

The Ring programming language version 1.6 book - Part 55 of 189

  • 1. Ring Documentation, Release 1.6 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 53.29. Super Man 2016 Game 513
  • 2. Ring Documentation, Release 1.6 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 { 53.29. Super Man 2016 Game 514
  • 3. Ring Documentation, Release 1.6 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 53.29. Super Man 2016 Game 515
  • 4. Ring Documentation, Release 1.6 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" } } 53.29. Super Man 2016 Game 516
  • 5. Ring Documentation, Release 1.6 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: 53.29. Super Man 2016 Game 517
  • 6. Ring Documentation, Release 1.6 53.29. Super Man 2016 Game 518
  • 7. CHAPTER FIFTYFOUR 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. 54.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 - Dene 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 54.2 Project Folder Open the project folder : ring/android/ringlibsdl/project 519
  • 8. Ring Documentation, Release 1.6 You can add the source code (*.ring) and Images/Sound Files to the assets folder. You will nd the Flappy Bird 3000 Game ready for building. The execution starts from the start.ring le load "game2.ring" 54.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. 54.3. Building the project 520
  • 9. Ring Documentation, Release 1.6 ant debug 54.3. Building the project 521
  • 10. CHAPTER FIFTYFIVE USING RINGOPENGL AND RINGFREEGLUT FOR 3D GRAPHICS In this chapter we will learn about using RingOpenGL 55.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 55.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 522