Archived

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

Pipo DeClown

"rotate 50º to the right and go straight till you reach the finish!"

Recommended Posts

You got position coordinates for every obstacle,
so just check whether the coordinates match your view or not, badabingbadabum.

for(;P("\n"),R--;P("|"))for(e=C;e--;P("_")+(*u++/8)%2))P("| "+(*u/4)%2);

[edited by - Bill Cosby on July 29, 2002 4:36:33 AM]

Share this post


Link to post
Share on other sites
like in a racegame, the player turns right, not the world, so if the player moves straight ahead, which cordinate must be ++?
cuz normally thats the Z coordinate, but in this case, the world doesnt move, just the player.

Share this post


Link to post
Share on other sites
You need to learn vector mathematics

Basically you have a "forward" vector, which is what you rotate when the car turns. Then, if you want to move ahead n units, you simply scalar-multiply your "forward" vector by n and add it to the current position. This is assuming your "forward" vector is normalized, which is usually the case in these matters.

If I had my way, I''d have all of you shot!


codeka.com - Just click it.

Share this post


Link to post
Share on other sites
quote:
Original post by Pipo DeClown
like in a racegame, the player turns right, not the world, so if the player moves straight ahead, which cordinate must be ++?
cuz normally thats the Z coordinate, but in this case, the world doesnt move, just the player.


I think this is the most common mistake, you can''t move your screen, can you? so you got to move the world.
Therefor are the matrices and vectors calculations.


for(;P("\n"),R--;P("|"))for(e=C;e--;P("_")+(*u++/8)%2))P("| "+(*u/4)%2);

Share this post


Link to post
Share on other sites
ok, you look at your screen, you see a box, you move ahead, so what''s happening, the box approaches and you don''t, ''cause you are stuck on your seat.
It''s impossible to move your viewmatrix like this or it''s even more complicated and serves no purpose, I guess

for(;P("\n"),R--;P("|"))for(e=C;e--;P("_")+(*u++/8)%2))P("| "+(*u/4)%2);

Share this post


Link to post
Share on other sites
I find it more convenient to think about the camera as it''s own object with position and direction and just leave the "move the entire world" bit until the point where you calculate the view matrix (i.e. at the end). It''s no more computationally expensive, and it''s much closer to the way I think about things...

If I had my way, I''d have all of you shot!


codeka.com - Just click it.

Share this post


Link to post
Share on other sites
quote:
Original post by Dean Harding
I find it more convenient to think about the camera as it''s own object with position and direction and just leave the "move the entire world" bit until the point where you calculate the view matrix (i.e. at the end). It''s no more computationally expensive, and it''s much closer to the way I think about things...


Yes indeed, and in a multiplayer or split screen game "move the world" way isn''t correct anymore because then the world would have to move in different directios at the same time for the two cameras

Share this post


Link to post
Share on other sites
yes, as previous posters said, you need vector/matrix calcs...

however, in short: x''=x+speed*cos(angle);
y''=y+speed*sin(angle);

, where angle is in Radiians, (x'',0,y'') is new position and (x,0,y) is old position (im assuming its a simple first person control you need) .. so basically rotate your character by angle from standard position, and then use this to determine direction of motion. If you want realistic physics, you''ll also have to use acceleration to update speed.

Share this post


Link to post
Share on other sites