- #1
avgprogrammerjo
- 2
- 0
Hy guys, I program as an hobby, and have recently gotten into game programing. As I'm to young to have taken any physics classes(I'm doubling up in science to take physics my junior year), I have had to self teach myself what I have learned so far. I am posting it here as I think I will get more of a response that I am looking for, and that is the physics part of it. So I will convert the simple physics part of my program to plain english so you can help me even if you don't know programming.
Now for the part that is hard to separate from the program. In the program I have it so that if the acceleration is positive it will subtract the friction, and add if negative(going in the left on x axis, or down on y).
I will give you the positive example
Now for some reason that doesn't seem to be working.
If you don't understand the equations I have layed out, please let me know where and why, as I'm sure I could miss something as it all programing language seems like my second language.
Also is there a more "realistic" way of doing it. I want my objects to be as realistic as possible.
Thanks,
Joe
Code:
// find volume and mass
// first we will find volume = h * w
volume = w * h;
// now let's find mass = V * D
mass = volume * density;
// now we are going to find the gravity of the object using force = mass * 9.8(earth grav)
wieght = mass * (g_force * 9.8);
// find friction
friction = friction_coe * wieght;
I will give you the positive example
Code:
y_var = (y_force - friction) / mass
x_var = (x_force - friction / mass
y = y + y_var
x = x + x_var
Now for some reason that doesn't seem to be working.
If you don't understand the equations I have layed out, please let me know where and why, as I'm sure I could miss something as it all programing language seems like my second language.
Also is there a more "realistic" way of doing it. I want my objects to be as realistic as possible.
Thanks,
Joe