Advertisement
Guest User

hep

a guest
Apr 24th, 2017
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.56 KB | None | 0 0
  1. PImage startscreen, backImg, birdImg, wallImg, startImg;
  2. PFont title;
  3. int stage;
  4. int screensizex = 1728;
  5. int screensizey = 972;
  6. int gamestate = 1, score = 0, highScore = 0, x = -200, y, vy = 0, wx[] = new int[2], wy[] = new int[2];
  7.  
  8.  
  9. void setup(){
  10.   stage = 1;
  11.   size(1728,972);
  12.  
  13. }
  14. void draw(){
  15.   if(stage==1){
  16.     startscreen = loadImage("Tesla.jpg");
  17.     backImg =loadImage("background.png");
  18.     birdImg =loadImage("bird.png");
  19.     wallImg =loadImage("wall.png");
  20.     startImg=loadImage("menu.png");
  21.     image(startscreen, 0,0, screensizex, screensizey);
  22.     title = createFont("font",1000,true);
  23.     textAlign(CENTER);
  24.     text("BLA BLA!",100,150);
  25.     text("Test text", 100, 170);
  26.     println(stage);
  27.    
  28.   if(keyPressed) {
  29.       if (key == '1') {
  30.         stage = 1;
  31.   }
  32.        else if (key == '2') {
  33.         stage = 2;
  34.         gamestate = 0;
  35.     }
  36.            else if (key == '3') {
  37.         stage = 3;
  38.     }
  39.   }
  40.   }
  41.    
  42.   if (stage == 2){
  43.     println(stage);
  44.     fill(0);
  45.     if(gamestate == 0) {
  46.     imageMode(CORNER);
  47.     image(backImg, x, 0);
  48.     image(backImg, x+backImg.width, 0);
  49.     x -= 6;
  50.     vy += 1;
  51.     y += vy;
  52.     if(x == -1800) x = 0;
  53.     for(int i = 0 ; i < 2; i++) {
  54.       imageMode(CENTER);
  55.       image(wallImg, wx[i], wy[i] - (wallImg.height/2+100));
  56.       image(wallImg, wx[i], wy[i] + (wallImg.height/2+100));
  57.       if(wx[i] < 0) {
  58.         wy[i] = (int)random(200,height-200);
  59.         wx[i] = width;
  60.       }
  61.       if(wx[i] == width/2) highScore = max(++score, highScore);
  62.       if(y>height||y
  63. <0||(abs(width/2-wx[i])
  64.   <25 && abs(y-wy[i])>100)) gamestate=1;
  65.       wx[i] -= 6;
  66.     }
  67.     image(birdImg, width/2, y);
  68.     text(""+score, width/2-15, 700);
  69.   }
  70.   else {
  71.     imageMode(CENTER);
  72.     image(startImg, width/2,height/2);
  73.     text("High Score: "+highScore, 50, width);
  74.   }
  75. }
  76. if (mousePressed == true) {
  77.   vy = -17;
  78.   if(gamestate==1) {
  79.     wx[0] = 600;
  80.     wy[0] = y = height/2;
  81.     wx[1] = 900;
  82.     wy[1] = 600;
  83.     x = gamestate = score = 0;
  84.   }
  85. }
  86.    
  87.  
  88.  
  89.   if(keyPressed) {
  90.       if (key == '1') {
  91.         stage = 1;
  92.   }
  93.        else if (key == '2') {
  94.         stage = 2;
  95.         gamestate = 0;
  96.     }
  97.            else if (key == '3') {
  98.         stage = 3;
  99.     }
  100.   }
  101.  
  102.   if (stage == 3){
  103.     background(0,255,0); //green
  104.     println(stage);
  105.  
  106.  
  107.  
  108.   if(keyPressed) {
  109.       if (key == '1') {
  110.         stage = 1;
  111.   }
  112.        else if (key == '2') {
  113.         stage = 2;
  114.         gamestate = 0;
  115.     }
  116.            else if (key == '3') {
  117.         stage = 3;
  118.     }
  119.   }
  120.             }
  121.  
  122.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement