I want to make a grid-based-movement puzzle game. The rules are simple - player must go to exit, but when he’s on the same line (horizontally or vertically) as an enemy, and there is no any rocks etc. between them, the enemy starts to chase the player (also one square per one player’s move, turn-based-like).
I don’t know how to program and I thought it could be easy to make such a game but I don’t know how to do this. Could somebody help?
You’ll want to put an boolean object variable on the enemy object (say call it “IsChasing”)
Then you’ll need to add an event to check the whether the enemy’s column or row is the same as the player, and if it is then set the IsChasing variable to True.
In the event that moves the player, add a subevent to move enemies that have the IsChasing variable set to True.
These columns and rows are just a picture (background). Is it ok, or they have to be objects?
Technically, the background is an object.
You can make the background a sprite of just one of the grid cells and then tile it. This will allow you to change the dimensions of the game without having to rescale the background. Also, it will take up less memory (particularly good for low memory devices).
How to do that? Is this about ‘X position’ and ‘Y position’?
Yes, and use the x position to work out the number of whole cell widths each object is from the left side :
(cellWidth is a scene variable with the width of each cell)