// Cavern Runner P5 // Based off the popular game created by John Beech - http://mkv25.net/ // Created by John Beech - http://mkv25.net/ void setup() { size(400, 220); reset(); } void loop() { // Clear background background(172, 168, 153); // Draw title String title = "CAVERN RUNNER"; textFont(fontImpact, 35); textMode(ALIGN_CENTER); fill(255, 0, 0, 180); text(title, int(width/2), 30); MainMenu.checkStates(); MainMenu.draw(); SideMenu.checkStates(); SideMenu.draw(); } // Define global variables int scroll_speed, cavern_detail, cavern_gap, health, cavern_num, roof_y, floor_y, points; // Menu classes, definitions in reset cr_menu_main MainMenu = new cr_menu_main(); cr_menu_main_test SideMenu = new cr_menu_main_test(); // Fonts BFont fontImpact; // The re-callable version of setup; void reset() { // Set colour mode colorMode(RGB, 255, 255, 255); background(172, 168, 153); // Define menus /* High scores cr_menu menu_highscores = new cr_menu(2, false, 180); menu_highscores.items[0] = new cr_menu_item("Main Menu", "cr_hide_highscores"); menu_highscores.items[1] = new cr_menu_item("Play", "cr_play_start"); // Instructions cr_menu menu_instructions = new cr_menu(2, false, 180); menu_instructions.items[0] = new cr_menu_item("Main Menu", "cr_hide_instructions"); menu_instructions.items[1] = new cr_menu_item("Play", "cr_play_start"); // Pause cr_menu menu_pause = new cr_menu(2, true, 70); menu_pause.items[0] = new cr_menu_item("Play", "cr_play_resume"); menu_pause.items[1] = new cr_menu_item("Quit to Main Menu", "cr_main_menu"); // Load fonts */ fontImpact = loadFont("Impact.vlw"); } // Cavern runner objects class cr_ship { void draw(int x, int y) { // Draw ship } } public class cr_menu_main extends cr_menu { // Data for this menu boolean _visible, _vertical; int _y; String items[] = new String[4]; boolean states[] = new boolean[4]; cr_menu_main () { _visible = true; _vertical = true; _y = 50; items[0] = "Play"; items[1] = "High Scores"; items[2] = "Instructions"; items[3] = "Websites"; for(int i=0; i x1 && mouseX < x2 && mouseY > y1 && mouseY < y2) { states[i] = true; } else { states[i] = false; } } } } }