I’m toying with a game idea… for sake of argument think “PacMan”.
Internally the game board is an 11x11 integer array, with each element being blank, a power pill, etc (things for the main character to interact with)
Here is the problem… the main character (actor) can more one of 4 directions … but on the display the movement needs to be fluid (not jumping from cell to cell), but attempts to turn, pick up the cells object , have to occur when the actor is completely in the cell…
the actor class has two floating values (X,Y) and technically when those are both “integer” ( floor(x)=ceil(x) ) is when I need things to be checked, but because they are double values, rounding errors make this difficult to detect. Also, as well as checking if there is an object to pick up… at the same time it needs to check if there is a maze wall which would stop forward motion.
I fear I’m way overthinking this… so am hoping someone will slap me up side the head (virtually)
for x=1 to 1000
actor.x=x
if x/cellsize then ???? // cellsize would be how many points wide/tall each of the 11x11 values cover graphiclly
// when condition, then need to check which cell for what conditon
next x
in reality actor.x and actor.y would be altered by events, and may non necessary be altered by +/- 1, it could be +/- 10, 15 or n points