[Tutor] converting processing code to python code
Steve Willoughby
steve at alchemy.com
Mon Dec 1 22:02:02 CET 2008
On Mon, Dec 01, 2008 at 12:59:23PM -0800, Steve Willoughby wrote:
> > void drawSquare1() {
> > if(x1<0 || x1>width-size) {
> > x1Speed = -x1Speed;
> > }
> >
> > if(y1<0 || y1>height-size) {
> > y1Speed = -y1Speed;
> > }
>
> def drawSquare1():
> if (x1 < 0 or x1 > width-size):
> x1 += x1Speed
> y1 += y1Speed
> rect(x1, y1, size, size)
I think my eyes skipped somewhere while copying that
over. The exact translation of that code snippet would
of course have been:
def drawSquare1():
if x1 < 0 or x1 > width-size:
x1Speed = -x1Speed
if y1 < 0 or y1 > height-size:
y1Speed = -y1Speed
Sorry 'bout that.
--
Steve Willoughby | Using billion-dollar satellites
steve at alchemy.com | to hunt for Tupperware.
More information about the Tutor
mailing list