Hello, I'm new here... just started programming my gp2x, but I've already ran in trouble
I'm coding a pacman game, just for fun, using EdgeLib. Everything okay, the engine is nice, stuff is compiling and running fine. But I got some problems with floats:
In order for me to know the grid-snapped coordinates of the player, I need to divide the actual pixel-perfect coordinate by 16, which is the grid size:
CODE
unsigned int x,y; // Current real coordinates
unsigned int sx,sy; // Snapped coordinates
[...]
sx = x/16;
sy = y/16;
Well,.. The problem is that this division is always rounded down("floor()'ed"), that is, Even though the division resulted in,.. say 3,98, the unsigned int variable got a value of 3, while if it was properly rounded, that would result in 4.
Anyway, when I declared sx as float, the result was the same: It was still getting floored. I wonder if this happens because of the lack of a FPU in a gp2x?
Thx!
I'm coding a pacman game, just for fun, using EdgeLib. Everything okay, the engine is nice, stuff is compiling and running fine. But I got some problems with floats:
In order for me to know the grid-snapped coordinates of the player, I need to divide the actual pixel-perfect coordinate by 16, which is the grid size:
CODE
unsigned int x,y; // Current real coordinates
unsigned int sx,sy; // Snapped coordinates
[...]
sx = x/16;
sy = y/16;
Well,.. The problem is that this division is always rounded down("floor()'ed"), that is, Even though the division resulted in,.. say 3,98, the unsigned int variable got a value of 3, while if it was properly rounded, that would result in 4.
Anyway, when I declared sx as float, the result was the same: It was still getting floored. I wonder if this happens because of the lack of a FPU in a gp2x?
Thx!