grid movement

Blitz3D Forums/Blitz3D Beginners Area/grid movement

Hi Jsoren,

if you want to use a grid style movement system there are many ways of doing this.

What I think is possibly the simplest is the following:

Often in my games when I have a creature/entity that needs to walk/move from one point to another I store the following variables:

x,y,z - global coordinates of current position

tx,ty,tx - global coordinates of target position

Then simply point the creature/entity at the target position, which in your case would be the centre of the next grid square to move to.

Then proceed to move the creature/entity to the tx,ty,tz coordinates at its usual movement speed.

The final step is to ensure that it ends its movement on the target coordinates. This may be done in a number of ways. The simplest is to simply 'accept' the movement as being complete once the distance to the target position is within a specified tolerance. A more complex method is to reduce the creature's/entity's movement speed such that as it gets closer to the target position it slows down until it stops.

Using an array for the grid is handy if you want to store say the object handle of the creature/entity in the appropriate slot in the array to designate it as 'filled' and 0 otherwise.

Hopefully that gives you some ideas.