class Menus { boolean drawRectWithMouseColission(float x, float y, float rectwidth, float rectheight) { // Draw A Rect rectMode(CENTER); rect(x, y, rectwidth, rectheight); rectMode(CORNER); // Check it for collission if((mouseX > x - rectwidth/2 && mouseX < x + rectwidth/2) && (mouseY > y - rectheight/2 && mouseY < y + rectheight/2)) { return true; } else { return false; } } } // Julia class MainMenu extends Menus { void playButton(float x, float y, float w, float h) { fill(100, 100, 100); if(drawRectWithMouseColission(x, y, w, h) && mousePressed) { ismenu = false; ispause = false; isgame = true; } fill(0); textAlign(CENTER, CENTER); textSize(32); text("Play", x, y); } void statsButton(float x, float y, float w, float h) { fill(100, 100, 100); if(drawRectWithMouseColission(x, y, w, h) && mousePressed) { ismenu = false; isstats = true; } fill(0); textAlign(CENTER, CENTER); textSize(32); text("Stats", x, y); } void drawMenu() { background(40); // color maincolor = color(100, 100, 100); playButton(300, 300, 150, 50); statsButton(300, 400, 150, 50); textSize(100); textAlign(CENTER, CENTER); text("Save Bob", 300, 200); } void draw() { println("test"); } } // Julia, Max, Marla, Chris class Stats extends Menus { int trees_sawed = 0; int best_game_time = 0; int game_time = 0; void menuButton() { fill(100, 100, 100); if(drawRectWithMouseColission(300, 300, 150, 50) && mouse_released) { ismenu = true; isgame = false; isstats = false; } fill(0); textSize(32); textAlign(CENTER, CENTER); text("Main Menu", 300, 300); } void draw() { background(50); menuButton(); textAlign(LEFT); textSize(24); text("Best Game Time", 100, 50); text(best_game_time, 500, 50); text("Trees Sawed: " , 100, 70); text(trees_sawed, 500, 70); text("Insgesamt Spielzeit", 100, 90); text(game_time, 500, 90); } } // Chris class StopWatchTimer { int startTime = 0, stopTime = 0, pauseTime = 0; boolean running = false; boolean pause = false; void start() { startTime = millis(); running = true; } void stop() { stopTime = millis(); running = false; } void pause_start() { if (!pause) { pauseTime = millis(); pause = true; } } void resume() { if (pause) { startTime = startTime + (millis() - pauseTime); pauseTime = 0; pause = false; } } int getElapsedTime() { int elapsed; if (running) { elapsed = (millis() - startTime); } else { elapsed = (stopTime - startTime); } return elapsed; } int second() { return (getElapsedTime() / 1000) % 60; } int minute() { return (getElapsedTime() / (1000*60)) % 60; } int hour() { return (getElapsedTime() / (1000*60*60)) % 24; } }