-
-
Save jkwok91/d52b757b87527f7c685d to your computer and use it in GitHub Desktop.
uses classes from before. probably could use some refactoring when my mind is not fried
This file contains 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
/* | |
triangles sliding back and forth | |
*/ | |
int w = 200; | |
int h = 200; | |
color c = color(255); | |
Point center = new Point(w/2,h/2); | |
int rad; | |
int counter1; | |
int counter2; | |
boolean direction1; | |
EqTri1 t1; | |
EqTri2 t2; | |
ArrayList<Point> trackR; | |
ArrayList<Point> trackL; | |
void setup() { | |
size(w,h); | |
background(0); | |
frameRate(30); | |
rad = 30; | |
//draw two triangles | |
Point apexL = new Point(w/2+(int)(rad*(Math.sin(Math.PI/3))),h/2-(int)(rad*3/2)); | |
Point apexR = new Point(w/2-(int)(rad*(Math.sin(Math.PI/3))),h/2+(int)(rad*3/2)); | |
trackR = makeLine(apexR, center); | |
trackL = makeLine(center, apexL); | |
counter1 = trackR.size()-1; | |
counter2 = 0; | |
} | |
void draw() { | |
// sorry this is so ugly; my brain is pretty shot | |
background(0); | |
if (counter1 == 0 && counter2 == trackL.size()-1) { | |
direction1 = false; | |
} | |
if (counter1 == trackR.size()-1 && counter2 == 0) { | |
direction1 = true; | |
} | |
if (direction1) { | |
t2 = new EqTri2(trackR.get(counter1),rad); | |
counter1--; | |
t1 = new EqTri1(trackL.get(counter2),rad); | |
counter2++; | |
} else { | |
t2 = new EqTri2(trackR.get(counter1),rad); | |
counter1++; | |
t1 = new EqTri1(trackL.get(counter2),rad); | |
counter2--; | |
} | |
t1.drawT(); | |
t2.drawT(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment