Let's start modifying the game class.
engine
class, the instance of the fantomEngine's ftEngine
class.Field eng:engine
ftObject
instances, which need to be accessible at any time.Field obj:ftObject 'A general object Field player:ftObject 'Holds the player ship object Field shield:ftObject 'the Shield of the player
Field txtScore:ftObject 'Stores the game store info text Field txtLifes:ftObject 'The text info about the lifes left Field txtLevel:ftObject 'Shows which level we are in Field txtComets:ftObject 'Info about how many comets are left Field txtHighScore:ftObject[10] 'Score list(array) with 10 entries
Field font1:ftFont
ftLayer
class instances.Field layerBackGround:ftLayer 'Groups all background stars Field layerGame:ftLayer 'All game objects are stored here Field layerUI:ftLayer 'Holds the info text objects Field layerFX:ftLayer 'ParticleFX objects Field layerTitle:ftLayer 'the title screen Field layerScore:ftLayer 'The high-score list
ftSound
instance for the explosion, and one for a shot.Field sndExplo:ftSound Field sndShot:ftSound
Field atlas:Image
Field cometCount:Int 'How many comets are active Field levelNumber:Int 'The level number Field score:Int 'Game score Field lifes:Int 'Player lifes left Field gameMode:Int = gmMenu 'Mode the game is in
The last fields we will add are related to the delta timing feature of our game.
Field lastTime:Int Field deltaTime:Int
To finish off the data structure and to make the game logic easier to read, we will add some constants.
Const gmMenu:Int = 1 Const gmPlay:Int = 2 Const gmGameOver:Int = 3 Const gmScoreList:Int = 4
Const cmSmall:Int = 0 Const cmMiddle:Int = 1 Const cmLarge:Int = 2
Const grpShot:Int = 1 Const grpComet:Int = 2 Const grpPlayer:Int = 3 Const grpShield:Int = 6
Const tmObjRemove:Int = 2 Const tmShieldTime:Int = 3
That's all for now. And later too!
Save your script, and build it to see if any error shows up.