We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › dont go outside background size
Page Index Toggle Pages: 1
dont go outside background size (Read 587 times)
dont go outside background size
May 2nd, 2010, 9:24am
 
Hi, guys im trying to make a cube go around my background size which is (300,300), using up,down,left and right.

but i dont know how to make it not leave the screen, i mean, i tryed used constrain but i dont know how use it very well, thx for the help.

PS: im doing the keys with a void keypressed, and then by "ifs"
Re: dont go outside background size
Reply #1 - May 2nd, 2010, 1:25pm
 
constrain(posX, 0, width);

isn't enough. Instead, try:

posX = constrain(posX, 0 width);
Page Index Toggle Pages: 1