Created
October 8, 2014 14:41
-
-
Save rlieberman/447e0878627b3a38197b to your computer and use it in GitHub Desktop.
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
Hexagram h1; | |
Hexagram h2; | |
Hexagram h3; | |
Hexagram h4; | |
Hexagram h5; | |
Hexagram h6; | |
Hexagram h7; | |
void setup () { | |
size (600, 600); | |
//declare a new hexagram, set the pivot point at x,y, the color, the line weight | |
//also declare whether it's broken / unbroken and if it moves horizontally or vertically | |
h1 =new Hexagram (20, 20, #01FFCD, 4, true, false); | |
h2 =new Hexagram (200, 20, #FFF94B, 18, false, false); | |
h3 =new Hexagram (240, 400, #FF3591, 15, true, false); | |
h4 =new Hexagram (300, 300, #35F3FF, 12, true, true); | |
h5 =new Hexagram (100, 500, #0A00FE, 6, true, true); | |
h6 =new Hexagram (10, 100, #B535FF, 16, true, true); | |
h7 = new Hexagram (width/2, 250, #86E002, 9, true, false); | |
} | |
void draw () { | |
frameRate (20); | |
background (0); | |
h1.display(); | |
h1.moveY (); | |
h2.display(); | |
h2.moveY (); | |
h3.display(); | |
h3.moveY (); | |
h4.display(); | |
h4.moveY (); | |
h5.display(); | |
h5.moveY (); | |
h6.display(); | |
h6.moveY (); | |
h7.display (); | |
h7.moveY (); | |
} | |
class Hexagram { | |
//pivot point aka top left corner of the whole hexagram | |
float mPivotX; | |
float mPivotY; | |
color mC; | |
float mLineWeight; | |
boolean mBroken; | |
boolean mHalfBroken; | |
boolean mMoveY; | |
Hexagram (float pivotX, float pivotY, color c, float lineWeight, boolean broken, boolean moveY) { | |
mPivotX = pivotX; | |
mPivotY = pivotY; | |
mC = c; | |
mLineWeight = lineWeight; | |
mBroken = broken; | |
mMoveY = moveY; | |
} | |
void display () { | |
float spacing = mLineWeight*2; | |
float lineLength = (mLineWeight*6) + (spacing*4); | |
//draw the hexagram using variables!!!! | |
strokeCap (SQUARE); | |
stroke (mC); | |
strokeWeight (mLineWeight); | |
line (mPivotX, mPivotY, mPivotX + lineLength, mPivotY); | |
line (mPivotX, mPivotY+spacing, mPivotX + lineLength, mPivotY+spacing); | |
line (mPivotX, mPivotY+(2*spacing), mPivotX + lineLength, mPivotY+(2*spacing)); | |
line (mPivotX, mPivotY+(3*spacing), mPivotX + lineLength, mPivotY+(3*spacing)); | |
line (mPivotX, mPivotY+(4*spacing), mPivotX + lineLength, mPivotY+(4*spacing)); | |
line (mPivotX, mPivotY+(5*spacing), mPivotX + lineLength, mPivotY+(5*spacing)); | |
//draw the rectangle in the center if it's declared a broken one | |
if (mBroken == true) { | |
stroke (0); | |
line ((mPivotX + lineLength/2), (mPivotY - mLineWeight), (mPivotX + lineLength/2), mPivotY+ mLineWeight+(spacing*5)); | |
} | |
} | |
void moveY () { | |
float ySpeed = 1 + mLineWeight/2; | |
float xSpeed = 4; | |
if (mMoveY == true) { | |
mPivotY = mPivotY + ySpeed; | |
} | |
else { | |
mPivotX = mPivotX + xSpeed; | |
} | |
//how can I get these to bounce? I am having trouble, they keep getting stuck | |
//not sure where to put it in the conditional | |
//if it moves below the screen, set the Y position to 0 | |
if (mPivotY > height) { | |
mPivotY = 0; | |
} | |
//if it moves to the right of the screen, set the X position to 0 | |
if (mPivotX > width) { | |
mPivotX = 0; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment