Conforming character movement to a grid
Blitz3D Forums/Blitz3D Beginners Area/Conforming character movement to a grid
| ||
Hey guys, I�m starting to make my first game in Blitz3D (a simple clone of the classic Sega arcade game Pengo) and I need some help moving my character around properly. Basically I want my character to always conform to the grid squares in the playing area which are 64x64 units. So my character can move at any speed but when the player lets go of the move key the character always stops on the next closest grid space. Any help or simple code would be great :-) |
| ||
EDIT: better code below. |
| ||
Thanks for the example octothorpe although I don't think it will do exactly what I want and I can't seem to work out exactly what's going on (I don't think I need an x_moves_remaining variable). Does anyone else have some tips or simple examples? |
| ||
Not sure about what you want but try to make a cube of 64*64*64 then sets the collisions and move the character in the cube, use FlipMesh cube and you are ok. Is this the solution? |
| ||
you can do so: take into two variables your character's x,y coords*cell_width, where x and y are the cell indexes (from 0 to 63, or from 1 to 64); when you want to move your character into another cell, you need to calculate the new coords. At that moment, you know the start and finish coordinates of the character movement and with a simple function you can move it at which speed you prefer. I hope I have been helpful :) |
| ||
This is simpler. I don't know why my previous suggestion was so convoluted.If player\x Mod 64 = 0 Then player\vx = KeyDown(205) - KeyDown(203) EndIf player\x = player\x + player\vx |