This method will do various things, from cleaning up the layers to initializing the tile map to setting the end time.
StartNewGame
, inside the game
class.Method StartNewGame:Int()
tile
variable with the type INT.Local tile:Int = 0
Millisecs
and set the game score to 0
.Seed = Millisecs() score = 0
gmPlay
and activate layers with it.gameMode = gmPlay ActivateLayer(gameMode)
layerGame
and remove all objects form the game layer and the GFX layer.eng.SetDefaultLayer(layerGame) layerGame.RemoveAllObjects() layerGFX.RemoveAllObjects()
selector = eng.CreateImage(atlas,64,0,64,64,0,0) selector.SetVisible(False)
For Local y:Int = 1 To rows For Local x:Int = 1 To columns
-1
. Then, close the FOR loops.tileMap[x-1][y-1] = -1 Next Next
rows
and columns
.For Local y:Int = 1 To rows For Local x:Int = 1 To columns
Repeat
statement.Repeat
tile
with a random number ranging from 0
to 6
. Set the maximum allowable value to 5
.tile = Rnd(6) If tile = 6 Then tile = 5
Until
statement, which will check gems horizontally and vertically to make sure that more than one gem doesn't have the same ID. This ensures that three matching tiles are not already in a row.Until (CheckGemsX(x,y,tile)<2 And CheckGemsY(x,y, tile)<2)
tile
value.tileMap[x-1][y-1] = tile
tile
value, create a new gem tile.Local obj:=CreateTile(x,y,tile)
justStarted
to True
.Next Next justStarted = True
Millisecs
+ gameTime
. Then, close the method.endTime = Millisecs()+(gameTime) Return 0 End
The method StartNewGame
will just do that—start a new game. Of course, it will also clean up every setting that was done before so you can start a new game afresh.
3.133.144.217