Created
November 8, 2015 18:33
-
-
Save shivshank/79ef6d2d7780cb69676a to your computer and use it in GitHub Desktop.
A simple 2D Java Renderer (incomplete example implemenation)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* An example implemenation of data structures to support a 2D Renderer in (semi) Java... */ | |
class abstract Body { | |
public Vector2f posNext; | |
public Vector2f posPrev; | |
/** | |
* The actual position of the object at time t = t0 + dt * alpha. | |
*/ | |
protected Vector2f pos = new Vector2f(0f, 0f); | |
protected void interpolatePos(float alpha) { | |
// Maybe everything should be converted to double and then back to float? | |
// Not sure if that will help precision.. I don't even think the precision really matters here, though. | |
pos.x = posPrev.x + alpha * (posNext.x - posPrev.x); | |
pos.y = posPrev.y + alpha * (posNext.y - posPrev.y); | |
} | |
public abstract void draw(double alpha); | |
} | |
/** | |
* A Particle is a simple colored polygon. | |
*/ | |
class Particle { | |
} | |
class Sprite { | |
} | |
class Mesh { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment