Developing a game that has often repetitious code that I cant simplify.
Example of what I do normaly
Square object;
GL11.glPushMatrix(); // Pushes a matrix stack down by one. This allows us to rotate our object freely
GL11.glTranslated(object.x, object.y, 0); // Move object to its position
object.drawToScreen(); // Draws the object
GL11.glPopMatrix(); // Pushes a matrix stack up by one, prevents the translation from affecting other objects in the scene
The above code gets bulky and needs to be repeated often. What I want to do
Square object;
bumpMatrix()
{ // implies GL11.glPushMatrix();
GL11.glTranslated(object.x, object.y, 0); // Move object to its position
object.drawToScreen(); // Draws the object
} // implies GL11.glPopMatrix();
Is there a way to make this happen? I swear I've seen something like it somewhere before in Java. It would allow me to make a single function and not have to Copy/Paste the same group of code several times, just call that function.
Aucun commentaire:
Enregistrer un commentaire