1. Add the
LoadSounds
method to thegame
class.Method LoadSounds:Int ()
2. Set the sound objects via calls to the engine's
LoadSound
method. The parameter is the filename of the sound, but without a file extension.sndExplo = eng.LoadSound("explosion") sndShot = eng.LoadSound("shoot1")
3. Close the method:
Return 0 End
Even though we have only two sounds to load, with the LoadSounds
method you have a code section that you can easily expand once you want to add more sounds to the game.
In every game, you have a user interface (UI) that will let you control the game somehow and also inform the player about certain statistics of the game. For example, how high the score is, how many lives are remaining, and so on. In the following screenshot, for example, the red arrows point to the UI elements:
This can be done with graphics or text. In CometCrusher, you will print these values as text...