quick question about moving objects

Posted By: elegant_mistake

quick question about moving objects - 01/06/11 22:03

Hey I'm typing out some old AUM workshops to improve my skills. I was just wondering if anybody can explain to me how the following two lines of code work:

Code:
player_speed.x = 20 * mouse_force.y * time_step;
player_speed.y = -15 * mouse_force.x * time_step;



I understand what it does (it moves a little ship up, down, left, and right) but I don't understand why the player_speed.x is controlled by mouse_force.y. I thought it would be mouse_force.x.

If anybody has the time to answer this dumbass question, that would be really awesome.
Posted By: Superku

Re: quick question about moving objects - 01/06/11 22:11

mouse_force.y != 0 is true when you move the mouse up and down (push/ pull it from/ to you).
mouse_force.x != 0 is true when you move the mouse left or right.

The code seems to move the player upwards with player_speed.x, so you need to control the latter variable with the y-coordinate of the mouse speed vector.
© 2023 lite-C Forums