grid based movement using arrays |
Using the same array I am able to move the player about and detect if there is a wall in the way and block the movement.
The green and red are done in the same way, except for the their movement, it is simply a random number between 1-4 which determines which way they will try to move (1=left, 2=right, 3=up, 4=down).
a code snippet |
You could for instance have sections of the grid that are power-ups/keys etc. which when you move over them change something. You just check which position you are on the grid, look into the array at this position and get what's there.
chris
No comments:
Post a Comment