Sunday, May 27, 2012

Early build is a buggy, bouncy physics engine

This is the very first build of Kromapoka. It's only a physics engine at the moment but I have great ideas for this platformer. It is written in Java and is my final project in AP Computer Science A. Even after I turn this in, I will continue working on it and plan on selling it to pay for college. Cornell is expensive...

The bounciness is a soon-to-be-fixed bug. There are two types of contact force. One for impact and one for non-impact (no velocity in the direction of the block). I have yet to implement non-impact force. So, that's why the player bounces

Why Kromapoka? What a weird name, right?

One of the main story elements of this game will be that a yet-to-be-named baddie has stolen all the color from the world and you must bring it back. Color restoration.

color --greek--> chr├│̱ma
restoration --greek--> apokat├ístasi̱

 I changed chroma to kroma because Google thought Chromapoka was a misspelling of Chromebook.

I put a lot of work into my physics engine so that it matched classic Newtonian physics. You know, all that stuff your high school physics teacher taught you. Forces, DVATs, and the like. For each frame, the player (and other objects soon) has all the forces on him summed up and from there the position delta is calculated like so:

        xPos += velocity.getX() * dt + .5 * acceleration.getX() * Math.pow(dt, 2);
        yPos += velocity.getY() * dt + .5 * acceleration.getY() * Math.pow(dt, 2);

I won't reveal too much of my code in general, but this is nothing special. What's special about this platformer? Why didn't I jump in that video? Maybe both of these questions have the same answer.

No comments:

Post a Comment