Day 4 Game 4: 30 games in 30 days using Grids

[button url=”http://www.gamelogic.co.za/examples/30-games-in-30-days/game04/” size=”large”]CLICK HERE TO PLAY GAME 4[/button]

[divider]

[slogan]This is what Grids did for us today. What can Grids do for you?[/slogan]

The aim of Game 4 is to move your player to the centre of the hex grid without the monsters landing on the cell that your piece is in. The grid becomes bigger as you play which increases the level of difficulty (and the number of monsters to dodge!).

Under the hood the game is very simple. Monsters move in circles around the origin. On a hex grid, circles are of course hexagons. The direction of movement is fixed for each cell, and pre-calculated. We basically iterate the grid in a spiral fashion, and assign directions accordingly, something like the following:

foreach circle in startRadius to FinishRadius
 for each side in circle
 for each point in side
 grid[point].Direction = Directions[side]

[divider]

Click here to check out all 30 games 

[divider]

 

Scroll to Top