To store data in Treasure chest, we will add some fields to the game
class.
1. First, start with two FLOAT variables, which will hold the size of the canvas.
Class game Extends App Field eng:engine Field isSuspended:Bool = False Field cw:Float Field ch:Float
2. Next, add a field to store the mode of the game. Initialize it with a constant, which we will define shortly.
Field gameMode:Int = gmTitle
3. During the game, we need to measure how much time is left. For this, we need a field for minutes and one for seconds.
Field minutes:Int Field seconds:Int
4. When a game begins, we need to store the time in milliseconds, to check when it will end.
Field endTime:Int
5. Add a field for the game score.
Field score:Int = 0
6. The time for one round will be stored as well. It is initialized to
2000
milliseconds. This makes it easy for testing.Field gameTime:Int = (1000*60*2)
7. Next, add two fields to define the size of our game grid.
Field rows:Int = 6 Field...