Very Basic Coding Question..
in
Programming Questions
•
1 year ago
Hello...
I know it probably isn't the most efficient way to do this... But I just want it to work... T_T
I'm very new to Processing and I'm having trouble trying to rotate my drawing on the Y-axis...
Basically, I'm trying to get the fish to flip over when it gets to the left side of the window.
I have:
- import processing.opengl.PGraphicsOpenGL;
- int fishX = 247;
- int fishY = 138;
- int x;
- int changeX = 1;
- void setup() {
- background(231, 253, 255);
- size(800, 400, OPENGL);
- smooth();
- }
- void draw() {
- x = x + changeX;
- int newWid = width-fishX;
- translate (newWid-x, height/2-fishY/2);
- if (x < 0 || x > width-fishX) {
- changeX = changeX * -1;
- if (x < 0) {
- rotateY(PI);
- }
- else {
- rotateY(0);
- }
- }
- fish(); }
while fish() is just a method I created to draw my fish..
My code isn't working.. the fish just bounces off the left wall and continues backwards....
What am I doing wrong? Do I need push and popMatrix()?
Thank you!
1