Skip to content

Instantly share code, notes, and snippets.

@sabotai
Created September 1, 2016 20:32
Show Gist options
  • Save sabotai/b365f4faad1eb358e68211d323c9329c to your computer and use it in GitHub Desktop.
Save sabotai/b365f4faad1eb358e68211d323c9329c to your computer and use it in GitHub Desktop.
GD105 Week 2 - Variables
//declare a new int called howManyHoursOfSleep and assign it a value of 6
int howManyHoursOfSleep = 6;
void setup(){ //this runs once
size(1920,1080); //make the windows this size
//i could also assign a value in here
//howManyHoursOfSleep = 6;
}
void draw(){ //everythins inside here runs many times per second
background(100,1,90); //draw this background color at the beginning of each frame
//each time this runs, add 1 to the value of howManyHoursOfSleep
howManyHoursOfSleep = howManyHoursOfSleep + 1;
//since we cant really tell visually, use the console debug command to let us know what that value is
println(howManyHoursOfSleep + " hours of sleep");
//draw our rectangle at 100 on the x axis, 100 on the y axis
//make it (10*howManyHoursOfSleep) pixels wide and 10 pixels tall
rect(100,100,10*howManyHoursOfSleep,10);
//draw my ellipse perfectly in the center of the screen
//the width will change with where the cursor position is on the Y axis
//the height will be exactly half that of the window
ellipse(width/2,height/2,mouseY,height/2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment