Hey, Glenshope.
First things first: If you want to post code just stick it inside handy-dandy
pre tags. That'll preserve your formatting.
Like
so.
Anyway, the main issue that you have here is that you're working with integers, and small integers don't work well with physics simulations. You have to remember that integers, VergeC's number format, can't represent fractional bits at all. If a mathematical operation produces a fractional part, it's truncated - just thrown away. So, for example, (1/2) becomes 0, no matter what.
We get around this with what's called "fixed point" arithmetic. If you want an in-depth description, it'd be best to look it up, but basically you choose a multiplier and assume that your numbers that require fractional parts are multiplied by this.
In your case, you'd want to store force, position, velocity, and acceleration as a fixed point number. One of the easiest (but not super-precise) ways of doing this is to just treat 1000 as 1 ... so when you are adding 1 to your force, for example, add 1000 instead. When you're going to print out the string, you need to convert it back to actual screen coordinates, so you divide x and y by 1000.
More specifically, here are the changes you'll need:
int x = (ImageWidth(screen) / 2) * 1000; //Initial Hello World Position
int y = (ImageHeight(screen) / 2) * 1000;
if (up) // If up arrow is pressed
{
ForceY -= 1 * 1000; // Decrease y force
}
else if (down) // If down arrow is pressed
{
ForceY += 1 * 1000; // Increase y force
}
if (left) // If left arrow is pressed
{
ForceX -= 1 * 1000; // Decrease x coordinate
}
else if (right) // If right arrow is pressed
{
ForceX += 1 * 1000; // Increase x coordinate
}
x += velocityx + (accelerationX/2); // remember that (1/2) == 0!
PrintCenter(x/1000, y/1000, screen, 0, "Hello World!");
I haven't tested that code specifically (I do fixed-point slightly differently myself; I tend to use bit shifts but they're somewhat more confusing so disregard this sentence if you don't understand what I mean) but it should work.
You might want to add a bit less force each iteration; currently it speeds up mighty fast. But now that you're using fixed-point, you can just add 200 or something rather than 1000. :)
Did that help out any or did I just confuse the issue more?