Translate not working as exspected

edited January 2015 in Questions about Code

The code below should move the box to the right and make it rotate while it does it. the goal is to make it so that it looks like it is rolling. However, the box rotates, but does not move. I am not sure what I could be doing wrong.

float y=0;
void setup()

void draw()

Perhaps it is just my computer. Can someone confirm that they see a box that does not move to the right, but does rotate to the right?


  • You are translating. You can prove this to yourself by commenting out the call to translate() and running your program again.

    But your problem is that you're using int division. What is the value of (50/90)? Use a print statement to find out, if you aren't sure.

    You should see that (50/90) is always 0, since ints can't hold decimal values. The solution is to use floats instead of ints. Try (50.0/90.0) instead.

Sign In or Register to comment.