The OnLayerUpdate
method has the layer as a parameter.
g.layerGame
.Method OnLayerUpdate:Int(layer:ftLayer) If layer = g.layerGame Then
g.lifes
are equal to or below 0
.If g.lifes <= 0 Then 'GameOVER
gameMode
to g.gmGameOver
.g.gameMode = g.gmGameOver
g.layerTitle
.g.layerTitle.SetActive(True)
g.score
to the high score list of the engine.g.eng.scoreList.AddScore(g.score,"---")
g.player.SetActive(False)
g.layerFX.RemoveAllObjects() layer.RemoveAllObjectsByID(g.grpComet)
g.SaveHighScore
. Then Return
from the method.g.SaveHighScore() Return 0 Endif
g.gameMode
still equals g.gmPlay
.'All comets destroyed-> next level If g.cometCount <= 0 And g.gameMode = g.gmPlay Then
ActivateShield()
g.levelNumber += 1 g.SpawnComets(3 + g.levelNumber) g.lifes += 1 Endif Endif Return 0 End
In the preceding four methods, we basically set all the controls and condition checks for our gameplay.
Of course there are other ways to handle all this. Remember, this is just one way to do it. The whole game code is about 450-500 lines. That is not much. But fantomEngine took a lot of work from us. You could easily add another 800-1000 lines to the game if you had to create all this yourself.
One thing that is missing from an Asteroids clone is the enemy ship that showed up randomly and shot at your ship. You could also try to destroy it, and if you hit it you get a good amount of points rewarded to you. It would be a good challenge for you to add an enemy ship. If you look at the sprite sheet, then you will find a green enemy ship right there. Try it, it is easy!
18.118.150.80