Best method: Translation vs Separate Image
in
Programming Questions
•
2 years ago
Hi all,
I'm using this function to along side others to create some 2D terrain. It displays an upwards slope when the argument is 0 and flips to make a downward slope when the argument is 1. I have many of these for all sorts of shapes, 14 images in total.
void slope(int i) {
pushMatrix();
translate(x+64, y);
scale(-i, 1);
image(terrainImages[7], 0, 0);
popMatrix();
}
My question is:
These are simple images of 1 or 2 colours and a width/height of 64,64.
Am I really helping matters by not using twice the images or is all the extra pushing, popping and translation just cancelling that out? Especially seeing as on half the images I don't actually do any scaling or translation of any use. Would it be a better approach to overload the function?
void slope(int i) {
pushMatrix();
translate(x+64, y);
scale(-i, 1);
image(terrainImages[7], 0, 0);
popMatrix();
}
void slope() {
image(terrainImages[7], x, y);
}
I'd appreciate your thoughts on this, and if you have a better way approach I'd love to hear it.
Thanks
Dave
1