Skip to content

Instantly share code, notes, and snippets.

@tado
Created May 14, 2018 07:19
Show Gist options
  • Select an option

  • Save tado/429a71ebead973c9a7bf81bd2b67d3c1 to your computer and use it in GitHub Desktop.

Select an option

Save tado/429a71ebead973c9a7bf81bd2b67d3c1 to your computer and use it in GitHub Desktop.
Processing Animation Basic
int NUM = 1000;
PVector location;
PVector velocity;
void setup() {
size(800, 600);
frameRate(60);
colorMode(HSB, 360, 100, 100, 100);
noStroke();
location = new PVector(width/2.0, height/2.0);
velocity = new PVector(random(-10, 10), random(-10, 10));
}
void draw() {
background(0);
fill(120, 100, 100);
location.add(velocity);
ellipse(location.x, location.y, 10, 10);
if (location.x < 0 || location.x > width) {
velocity.x = velocity.x * -1;
}
if (location.y < 0 || location.y > height) {
velocity.y = velocity.y * -1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment