Legacy GM Apply force without use box2d and general confusion.

P

plaguebreath

Guest
Hi everyone first of all sorry for my bad english, I am here because I have problems to simulate some physics for a little project 2d I'm working into. Basically I have a rectangle that rapresent my object I want to move with width of 160pixel. Now I want to use someone real proportion so I set on my project (sidescroll like Mario with a fly rectangle) that 1mt is equal to 32px.
The rectangle can be moved freely and rotated and as an example I set to it a weight of 550kg, now I just add the check for press the D and A button that will increment the speed of the airplane, but I not use motion_add for that, I've seen here in the forum that the equivalent is increment of h and v speed like that:

Code:
//Equivalent to motion_add(dir, spd)
hspeed += spd*cos(pi/180*dir);
vspeed -= spd*sin(pi/180*dir);
so in my code I used in every step:

Code:
spd += spdacc;
hspd = (spd*cos(degtorad(dir)));
vspd = (spd*sin(degtorad(dir)));
//motion_add(dir,spdacc);
x += hspd;
y -= vspd;
spdacc is a variable changed by pressing A or D that increase number of px moved per step range between 0 and 1 with step of 0.01
Now I would like to convert the actual spd (if substitute motion_add and check the value of object speed is same) into m/s so I just do (spd * 60)/32 right ?
Ok now let's say I want to substitute the spdacc with a force to apply to the plane direction (Thrust) like the
physics_apply_force, how I have to work it out ? And what about apply a force on the opposite direction of movement of my rectangle ?
I am totally bad on vector and physics so help me understand.
Thank you for the patience and hope you understand my problem.

Addition: I think I am wrong on my assumtion that motion_add will be useful for me, if I want to adding constantly 0.1 spd on direction 0 is all working good, if I doing it with direction variable the spd resulting is not anymore incremented by 0.1, correct ?
 
Last edited by a moderator:
Top