Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // We control wich screen is active by settings / updqting
- // gameScreen variable. We display the correct screen according
- // to the value of this variable.
- //
- // 0: Initial Screen
- // 1: Game Screen
- // 2: Game-over Screen
- int GameScreen = 0;
- void setup() {
- size (500, 500);
- }
- void draw() {
- // Display the contents of the current screen
- if (gamescreen == 0) {
- initScreen();
- } else if (gameScreen == 1) {
- gameScreen();
- } else if (gameScreen == 2) {
- gameOverScreen();
- }
- }
- /************ SCREEN CONTENTS **********/
- void initScreen() {
- // codes of initial screen
- background(0);
- textAlign(CENTER);
- text("Click to start", height/2, width/2);
- }
- void gameScreen() {
- // codes of game screen
- background(255);
- }
- void gameOverScreen () {
- // codes for game over screen
- }
- /******* INPUTS ********/
- public void mousePressed() {
- // if we are on the initial screen zhen clicked, start the game
- if (gameScreen==0) {
- startGame();
- }
- }
- /*********** OTHER FUNCTIONS *********/
- // This method sets the necessary variables to start the game
- void startGame() {
- gameScreen=1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement