Archived

This topic is now archived and is closed to further replies.

Rotating

This topic is 5876 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi I am still writing my 2D racing game engine with a perception of 3D ( like the mario kart on the snes). Everything was working fine till I got to rotating. The way I am doing it is the player has a bearing,xpos & ypos. He moves around the level with xpos & ypos but the level rotates around him depending on his bearing. So every time the frame is drawn the engine goes to every topleft hand corner of a tile & rotates approbiately according to the bearing. So it finds how many tiles away from the players xPos & how many tiles away from the players yPos. Then uses pythogras theroem to find the distance of the top left corner form the player. Now that I know the distance from the player ot the top left corner of the tile & I want to find out where its new position will be by rotating it. How would I do this without using a compass :p ? Some how I have to take into the account the distance & the bearing to figure out where the new location is ? y \ \ \ x--- (y is the top left of the tile ,x is the center of rotation (car) & it rotates the tile by 90 degres, how would I find the new position for tile) thanx in advnace WizHarD

Share this post


Link to post
Share on other sites
http://therabbithole.redback.inficad.com/basic/quickbasic/3DBASIC/


Go there and there''s a demo that allows you to race around a wireframe track. The player is always centered and the track rotates which is what you''re trying to do.

It''s in QuickBASIC which you can also download at my site from the main "basic" directory.

It''s one of the "real3d" demos.

Ben


Share this post


Link to post
Share on other sites
thanx for the replay. I finally figured it out. You would do it like this:

xPos=CarX+(sin(bearing)*distance_to_tile);
yPos=CarY+(cos(bearing)*distance_to_tile);
// Then the Y formula has to account for going from top to bottom etc.

thanx for you help

Share this post


Link to post
Share on other sites