views:

351

answers:

2

SHORT INTRO:
I'm having trouble with a 3D cube on a plane. The plane is a grid of squares. The ID number of the square that the cube currently occupies on is stored in a storage-variable. This is so that I can tell whether or not adjacent squares are free for the cube to move onto. When I move the cube, the storage-variable is updated to reflect the ID number of the new square.

PROBLEM:
The problem is that sometimes when I am moving the cube, the cube is moved too far or in the wrong direction and the square in the storage-variable does not match the actual square the cube is drawn on...This causes problems like the cube not detecting collisions and even going through objects it is not supposed to....

Cube is drawn in a drawView method in an iPhone OpenGL ES EAGLView at a rate of 24 times per second...Could the fast drawing be the cause of this???? How can I fix this? My job depends on it...

Somebody please help.

+2  A: 

Well, not a lot to go on... But I doubt that the display refresh rate has any bearing on where the cube is going. Sounds like you have a good old fashioned logic error. But again, that's only going off what you've given.

Casey K.
+1  A: 

Have you tried checking to make sure each storage-variable maps correctly onto each square in your plane? Try debugging, drawing a square at a time to make sure it's drawing each one where you think it's supposed to be.

bkritzer