The real trick with this is high school-level science; which you should have done. In the event that you didn't a quick Google search will get you started. To explain how you avoid the 'novice' mindset take the lunar lander example.
Once you have read that [change in position] = [velocity] * [time passed]
it becomes clear that would need to keep track of those variables:
float x, y; // Your X and Y co-ordinates.
float vx, vy; // Your X and Y velocity.
float deltaTime; // Change in time.
Following that you would simply apply the velocity to the position each frame:
// Change X by the velocity multiplied by the time.
x = x + vx * deltaTime;
y = y + vy * deltaTime;
Now we would like to alter the velocity each frame so that we can add gravity. According to the exact same source [change in velocity] = [acceleration] * [time passed]
. Therefore we can apply the exact same principle:
const float gravity = 9.8f; // The gravity of the earth.
// Add gravity to the vertical velocity.
vy = vy + gravity * deltaTime;
// Change X by the velocity multiplied by the time.
x = x + vx * deltaTime;
y = y + vy * deltaTime;
Now you need a way for the player to control his spacecraft. From reading more about basic physics you will learn that motion is the result of force - I can't find a source but [change in acceleration] = ([force] / [mass]) * time
(as far as I remember). So when the player presses a key you would simply set the fx
and fy
variables to something and apply the equation during your update.
Ultimately you need to think about the physics around the objects in your game - and instead of trying to make them move in the way you would think, rather look up the equation.
Future Note: Remember that this is definitely not the best way to do physics (this is called Euler Integration and can lead to some odd scenarios at low frame rates) - you need to look into other ways of doing things (That article has quite a nice write-up on the bare basics as well). However, stick with Euler Integration for now, as it is means you are trying to learn one thing less.
Which games would teach you how to think in the correct mindset?
How would you test that you have done things correctly and with the correct mindset? Insert a Sleep(10 milliseconds)
in your game loop and everything should still move and react the same way as the full framerate.
Finally, please keep well away from 3D (and thereforce Quaternions and Matrices) until you have a good amount of experience with making 2D games work. I would venture to say that quite a few game developers don't actually know how Quaternions or Matrices work - but merely know how to use them - approach them much later on (or never, 2D games are a lot of fun and can be quite successful). You don't really need to know linear algebra and so forth to do this at the basic level (but it really does help, so go to some night classes if you can).
Final bonus: One thing my art teacher always told me is "don't draw what you think you see, draw what you see." The same thing applies here "don't model what you think happens (object.position++
), model what happens (`object.position += velocity * time)" - at least to reasonable limits (you are not modelling a perfectly accurate system, but make something that is a good immitation).