Advertisement
Guest User

Untitled

a guest
Feb 28th, 2020
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. PImage dinosaur1;
  2. PImage dinosaur2;
  3. PImage cactus1;
  4. PImage cactus2;
  5. //PImage dinoGame tital screen
  6. int x = 600;
  7. int state =0;
  8. final int MENU_SCREEN =0;
  9. final int GAME_SCREEN =1;
  10. int timer = 0;
  11. int y = 150;
  12. boolean jumping = false;
  13. int jumpingSpeed = 1;
  14. void setup() {
  15. size(600, 400);
  16. dinosaur1 = loadImage("dinosaur1.png");
  17. dinosaur2 = loadImage("dinosaur2.png");
  18. cactus1 = loadImage( "cactus1.png");
  19. cactus2 = loadImage( "cactus2.png");
  20. //dino game tital screen = load
  21. }
  22.  
  23. void draw() {
  24. if (keyPressed) {
  25. state = GAME_SCREEN;
  26. }
  27. switch(state) {
  28. case MENU_SCREEN:
  29. background(255);
  30. fill(0);
  31. textSize(40);
  32. text("No internet connection...", 50, 100);
  33. textSize(10);
  34. image(dinosaur1, 50, y, 50, 50);
  35. strokeWeight(4);
  36. stroke(70);
  37. line(0,200,600,200);
  38. break;
  39. case GAME_SCREEN:
  40. background(255);
  41. timer++;
  42. if (timer < 50) {
  43. image(dinosaur1, 50, y, 50, 50);
  44. } else if (timer >+100) {
  45. timer = 0;
  46. } else if (timer >=50) {
  47. image(dinosaur2, 50, y, 50, 50);
  48. }
  49.  
  50. //jump
  51. if (keyCode == UP && keyPressed&& jumping == false) {
  52. jumping= true;
  53. jumpingSpeed = 2;
  54. }
  55. if (jumping) {
  56. y-= jumpingSpeed;
  57. }
  58. if (y <= 50) {
  59. jumpingSpeed = -2;
  60. }
  61. if (y == 150) {
  62. jumpingSpeed = 0;
  63. jumping = false;
  64. }
  65. //cactus1
  66. image(cactus1, x, 136, 40, 60);
  67. x-= 3;
  68. //image(cactus2,200,50);
  69.  
  70.  
  71. strokeWeight(4);
  72. stroke(70);
  73. line(0,200,600,200);
  74. break;
  75. }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement