Created
March 19, 2014 13:46
-
-
Save ybakos/9641971 to your computer and use it in GitHub Desktop.
Global variables and functions that need refactored into classes. And an opportunity for composition.
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
// YOUR NAME | |
// Refactoring global variables and functions into appropriate classes. | |
// And an exploration of composition. | |
int carX; | |
int carY; | |
int carW; | |
int carH; | |
int engineX; | |
int engineY; | |
int engineW; | |
int engineH; | |
void setup() { | |
size(500, 500); | |
carX = width / 4; | |
carY = height / 2; | |
carW = 250; | |
carH = 100; | |
engineX = carX + 30; | |
engineY = carY + 30; | |
engineW = 50; | |
engineH = 20; | |
} | |
void draw() { | |
drawCar(); | |
drawEngine(); | |
} | |
void drawCar() { | |
fill(200); | |
rect(carX, carY, carW, carH); | |
fill(33); | |
text("car", carX, carY + 10); | |
} | |
void drawEngine() { | |
fill(100); | |
rect(engineX, engineY, engineW, engineH); | |
fill(255); | |
text("engine", engineX, engineY + 10); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment