Advertisement
Guest User

Untitled

a guest
Nov 20th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. // We control wich screen is active by settings / updqting
  2. // gameScreen variable. We display the correct screen according
  3. // to the value of this variable.
  4. //
  5. // 0: Initial Screen
  6. // 1: Game Screen
  7. // 2: Game-over Screen
  8.  
  9. int GameScreen = 0;
  10.  
  11.  
  12. void setup() {
  13. size (500, 500);
  14. }
  15.  
  16. void draw() {
  17. // Display the contents of the current screen
  18. if (gamescreen == 0) {
  19. initScreen();
  20. } else if (gameScreen == 1) {
  21. gameScreen();
  22. } else if (gameScreen == 2) {
  23. gameOverScreen();
  24. }
  25. }
  26.  
  27. /************ SCREEN CONTENTS **********/
  28.  
  29. void initScreen() {
  30. // codes of initial screen
  31. background(0);
  32. textAlign(CENTER);
  33. text("Click to start", height/2, width/2);
  34. }
  35.  
  36. void gameScreen() {
  37. // codes of game screen
  38. background(255);
  39. }
  40.  
  41. void gameOverScreen () {
  42. // codes for game over screen
  43. }
  44.  
  45. /******* INPUTS ********/
  46.  
  47. public void mousePressed() {
  48. // if we are on the initial screen zhen clicked, start the game
  49. if (gameScreen==0) {
  50. startGame();
  51. }
  52. }
  53.  
  54.  
  55. /*********** OTHER FUNCTIONS *********/
  56. // This method sets the necessary variables to start the game
  57. void startGame() {
  58. gameScreen=1;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement