Last active
March 21, 2019 02:57
-
-
Save jonesfish/d5968fd03c976e82d88c to your computer and use it in GitHub Desktop.
Revisions
-
jonesfish revised this gist
Oct 6, 2015 . 1 changed file with 12 additions and 7 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,13 @@ final int GO_RIGHT = 0; final int GO_DOWN = 1; final int GO_LEFT = 2; final int GO_UP = 3; float x, y; float w, h; float speed = 5; int state = GO_RIGHT; void setup() { size(500, 500); @@ -16,7 +21,7 @@ void draw() { // If the state is 0, move to the right. switch (state){ case GO_RIGHT: x += speed; // If, while the state is 0, it reaches the right side of the window, change the state to 1 if (x > width-w/2) { @@ -25,23 +30,23 @@ void draw() { } break; case GO_DOWN: y += speed; if (y > height-h/2) { y = height-h/2; state = 2; } break; case GO_LEFT: x -= speed; if (x < w/2) { x = w/2; state = 3; } break; case GO_UP: y -= speed; if (y < h/2) { y = h/2; @@ -53,8 +58,8 @@ void draw() { background(0); // UFO fill(151,37,210); ellipse(x, y, w, h/2); fill(186,0,255); stroke(255); arc(x, y, h*4/5, h*4/5, PI, TWO_PI); } -
jonesfish renamed this gist
Oct 6, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
jonesfish created this gist
Oct 6, 2015 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,60 @@ float x, y; float w, h; float speed = 5; int state = 0; void setup() { size(500, 500); w = 50; h = 30; x = w/2; y = h/2; } void draw() { // If the state is 0, move to the right. switch (state){ case 0: x += speed; // If, while the state is 0, it reaches the right side of the window, change the state to 1 if (x > width-w/2) { x = width-w/2; state = 1; } break; case 1: y += speed; if (y > height-h/2) { y = height-h/2; state = 2; } break; case 2: x -= speed; if (x < w/2) { x = w/2; state = 3; } break; case 3: y -= speed; if (y < h/2) { y = h/2; state=0; } break; } background(0); // UFO fill(151,37,210); ellipse(x, y, 50, 15); fill(186,0,255); stroke(255); arc(x, y, 25, 25, PI, TWO_PI); }