Position and Motion
Position and Motion are intimately linked. This is because :
- Motion is the changing of position.
However, in considering this, we are faced with the fundamental questions :
- What exactly is position?
- How do you determine position 2D video games?
Position
Most of you will already know this answer. A few you may even be familiar with the term pixel zero. What you may not know is that position in 2D game physics is concrete while in real-world physics it is a mushy concept. To illustrate this, let's see the steps a scientist takes to determine position.
- Step 1 : Extend finger.
- Step 2 : Point finger at a (seemingly) fixed point.
- Step 3 : Declare that point zero.
- Step 4 : All other positions is measured from that point.
The Monkey Zero Property
This is the best we can do in the real world. This is because of what I like to call monkey zero property. Imagine for a second (a split second) that we are at the monkey cage at a zoo. I declare a random monkey to be point zero and thus the center of the universe. We can now measure all other points from this grand 'monkey zero'.
But you know how monkeys are — they like to do monkey stuff — swing from tree to tree, run around their cage throwing crap at visitors, smell their fingers and fall off trees, etc. Therefore we can say that monkey zero is always moving and we can't get it to sit still for one freekin' second.
Therefore, we could spend our time chasing monkey zero around with tape measure (and hopefully, tranquilizer gun), or we could look at the big picture and realize that we know, more or less, where monkey zero always is, and with the exception of a mass monkey jailbreak, where he will always be — in the freekin' zoo.
The monkey zero property is not an exaggeration. Here's the two biggest problems :
- The universe does not exist as a grid, so we have to make one up.
- The universe and everything in it is constantly moving.
- Therefore even if you declare point A as the Earth and point B the Moon, both are constantly moving and the distance changing between them.
- Therefore scientists only really know, more or less, where everything is at any given point in time.
If you got extremely technical, even if you declared point A to be the Eiffel Tower and point B to be Mt. Everest, they both are on Earth, which is constantly spinning through the void of space. The relative distance between both may remain the same, but both points are constantly moving and changing position together with the motion of the Earth.
Back to 2D Game Physics
You'll be happy to know that monkey zero and his high-energy antics only effect physicists in the real world (and thus have developed methods for dealing with him, more or less). In 2D game physics, we have it easy — we have pixel zero.
Pixel Zero
Pixel zero is the center of 2D game space. In PlayBasic (by default), pixel zero is located at the top/left corner of the game window. Even if you were to stray away from the default game screen by panning a camera pixel zero does not move. It is forever fixed there, giving us a beacon as to where our game objects really are.
It is entirely possible to send simulated planets hurtling through simulated space and no matter how hard you try, you will not run into monkey zero (assuming you have the math skills). For one, 2D game space is arranged in a grid. It's a grid of pixels. To be able to send the planets spinning "out of control" you have to know their pixel location — and that is based on pixel zero.
Secondly, when you try to do something like this, you begin with an exact measurement. For example, if you send planet A careening off in one direction at speed C and planet B off in another direction at speed D you have to put in the numbers to send them off. Without looking at their location you can take those initial measurements and figure out where they are according to the pixel grid and pixel zero.
In short, because of pixel zero and the pixel grid, 2D game space is never as chaotic and unpredictable as real space. Unless, of course, you get really drunk and blindfold yourself before sitting down in front of the keyboard.
Motion
The original statement about motion, lifted from standard physics, needs to be amended for 2D physics. Originally, it was Motion is the changing of position. In 2D game physics, it is stated :
- Motion is the changing of position in relation to pixel zero.
It must be stated this way because without pixel zero, there can be no motion. There would be no way to change position. We would simply sit in our chairs looking at the screen blankly, wondering what the hell we are going to anchor the x and y locations of a game object to. If we created one, then we will have re-created pixel zero.