Skip to main content
gamedev.net
🔒 Locked

Rotating

Started by WizHarDx 1 reply 200+ views
Original Post
WizHarDx
WizHarDx
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
who is it that keeps on nicking WizHarD name !! :P
KalvinB
KalvinB
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


WizHarDx
WizHarDx
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
who is it that keeps on nicking WizHarD name !! :P

Topic Locked

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

Sign in to reply to this topic.