Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions code/Makey_Makey_Platformer.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
PShape easyButton;
PShape mediumButton;
PShape hardButton;
PShape exitButton;
int screen;
void setup(){
fullScreen();
textAlign(CENTER,CENTER);
drawMainScreen();
}

void draw(){

}

void drawMainScreen(){
screen = 0;
background(255);
String title = "Makey Makey Platformer";
textSize(128);
fill(0, 0, 0);
text(title, width/2, height/4);
easyButton = drawButton(width/2 - 75, height/2, 150, 80, "Easy", 0, 170, 0);
mediumButton = drawButton(width/2 - 75, height/2 + 100, 150, 80, "Medium", 255, 255, 0);
hardButton = drawButton(width/2 - 75, height/2 + 200, 150, 80, "Hard", 255, 0, 0);
drawExit();
}
void drawLevelSelect(){
drawExit();

}
void drawExit(){
exitButton = drawButton(0, height-80, 100, 80, "Exit", 255, 0, 0);
}

PShape drawButton(int x, int y, int wide, int high, String name, int color1, int color2, int color3){
PShape border = createShape(RECT, x, y, wide, high);
border.setFill(color(0,0,0));
border.setStroke(false);
shape(border);

PShape mainButton = createShape(RECT, x + 10, y + 10, wide - 20, high - 20);
mainButton.setFill(color(color1, color2, color3));
mainButton.setStroke(false);
shape(mainButton);

fill(0);
textSize(32);
text(name, x + wide/2, y + high/2);

return mainButton;
}

void mousePressed(){
if(screen == 0 && overButton(width/2 - 75, height/2, 150, 80)){
background(color(0, 170, 0));
changeScreen();
drawLevelSelect();
} else if(screen == 0 && overButton(width/2 - 75, height/2 + 100, 150, 80)){
background(color(255, 255, 0));
changeScreen();
drawLevelSelect();
} else if(screen == 0 && overButton(width/2 - 75, height/2 + 200, 150, 80)){
background(color(255, 0, 0));
changeScreen();
drawLevelSelect();
} else if(screen == 0 && overButton(0, height-80, 100, 80)){
exit();
} else if(screen == 1 && overButton(0, height-80, 100, 80)){
drawMainScreen();
}
}

boolean overButton(int x, int y, int w, int h) {
return (mouseX > x && mouseX < x + w &&
mouseY > y && mouseY < y + h);
}
void changeScreen(){
screen++;
}