Skip to main content
GameDev.net gamedev.net
🔒 Locked

Rotating level offset

Started by phi Aug 24, 2006 at 9:58 AM 7 replies 600+ views
Original Post
phi
phi
Hi, I'm stuck on a problem, but am not sure why it's happening. Hopefully someone could shed some theory on what I should be doing. (No need for real code, only pseudo). I have any enemy patrolling an area in a simple manner. It travels horizontally, bounces off the wall (no energy loss) and travels in the opposite direction and th process repeats. However, if the user presses the "rotate" button, the level rotates 90degrees. In order to get the enemy to stay in its relative position, I mount it to the level as it rotates. However, since it rotates 90degrees, the object has to start travelling vertically in order to stay on the path it should. I've handled this change like this: -check direction -if vertical, stop force on x axis and apply force on y axis -else- -stop force on y axis and apply force on x axis. This works fine, however, when I rotate the level there's a slight offset. This offset accumulates and the enemy seems to end up far away from it's 'patrol zone' Why is it doing this? [Edited by - phi on August 24, 2006 10:24:23 AM]
Agony
Agony
When you say "rotate level", does that actually mean the level is physically rotating, or merely the player's view of the level? If the latter, then I would suggest that instead of literally rotating the level to get the effect, let the level stay exactly as it is (thus allowing all entity movement within the level to remain the same), and only apply the effect of rotation when you display the level. It might make the display code a little bit more complicated, but will make the game logic code far simpler. Plus, it will actually represent reality far better: Since the game world remains the same while the player's view is the only thing that changes, it makes sense for the game logic code to keep doing exactly what it's doing, and the display code is responsible for adjusting to view changes.
"We should have a great fewer disputes in the world if words were taken for what they are, the signs of our ideas nly, and not for things themselves." - John Locke o
stevenmarky
stevenmarky
interesting problem.

I'd double check I was rotating around the exact center of the board.
Also when the board rotates, does the enemy also rotate?
If not then you must make sure the point you are rotating is in the center of the enemy otherwise it will get offset.
phi
phi
Thanks for the replies. At the moment I'm rotating the entire level about its midpoint. The enemy is also rotated about its midpoint and rotates with the level as if it's stuck. If I don't dismount it from the level, then it stays exactly where it should all the time, no matter how many rotations. However, this means that it won't be moving since it's still mounted.
I'll try rotating the 'camera' instead. However, I'm using torque game builder so I'm not sure if this is possible.

phi
phi
I had a feeling that was causing the problem, so just before I dismount I reset the X and y velocity to zero, but still no luck.
phi
phi
Every single sprite on screen is rotated from its centre point, including the map.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.