Created
August 26, 2011 10:01
-
-
Save atleastimtrying/1173118 to your computer and use it in GitHub Desktop.
A basic processing sketch for nick
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int x,y, xVelocity; // our three variables that we need to keep track of | |
void setup(){ | |
size(320,240); //size of the app | |
smooth(); // makes circles anti aliased | |
noStroke(); // means there is no outer line on our circle | |
fill(100,100,150); // the colour of the ball | |
background(240); // the background | |
xVelocity = 1; | |
x = width/2; // width is the width of the sketch its always available | |
y = height/2; // same with height | |
} | |
void draw(){ | |
background(240); | |
if(x > width || x < 0){// if the x is greater than the width of the sketch (x > width) or (||) if the x is less than zero (x < 0) | |
xVelocity *= -1;// change the xvelocity to its inverse, so for this case it will be 1 or -1 | |
} | |
x += xVelocity; // increase the x by the xVelocity | |
ellipse(x,y,20,20); // draw an ellipse 20px wide and high at x and y | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment