As always, we will place our data storage in the game
class. You could also create these fields as global variables, but it is a better practice to encapsulate them inside a class, if you are mainly using an object-oriented coding style.
Class game Extends App Field eng:engine Field isSuspended:Bool = False Field layerGame:ftLayer Field layerTitle:ftLayer
Field txtCrates:ftObject
Field font1:ftFont
Field atlas:Image
Field onTarget:Int = 0 Field crateNum:Int=0
Field hitWall:Bool=False Field hitWall2:Bool=False
Field hitCrate:ftObject=Null Field hitCrate2:ftObject=Null
Field player:ftObject
Field levelNum:Int = 0 Field gameMode:Int = gmMenu
Field plStPos:Float[] = [0.0, 0.0]
These were the fields to store dynamic data. Now we need some constants.
Menu, Play
, and NextLevel
.Const gmMenu:Int = 1 Const gmPlay:Int = 2 Const gmNextLevel:Int = 3
Const grpPlayer2:Int = 6 Const grpPlayer:Int = 5 Const grpCrate:Int = 2 Const grpWall:Int = 1 Const grpFloor:Int = 3 Const grpTarget:Int = 4
Const tidNextLevel:Int=1 Method OnCreate:Int()
That's all!
3.135.182.221