Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PImage startscreen, backImg, birdImg, wallImg, startImg;
- PFont title;
- int stage;
- int screensizex = 1728;
- int screensizey = 972;
- int gamestate = 1, score = 0, highScore = 0, x = -200, y, vy = 0, wx[] = new int[2], wy[] = new int[2];
- void setup(){
- stage = 1;
- size(1728,972);
- }
- void draw(){
- if(stage==1){
- startscreen = loadImage("Tesla.jpg");
- backImg =loadImage("background.png");
- birdImg =loadImage("bird.png");
- wallImg =loadImage("wall.png");
- startImg=loadImage("menu.png");
- image(startscreen, 0,0, screensizex, screensizey);
- title = createFont("font",1000,true);
- textAlign(CENTER);
- text("BLA BLA!",100,150);
- text("Test text", 100, 170);
- println(stage);
- if(keyPressed) {
- if (key == '1') {
- stage = 1;
- }
- else if (key == '2') {
- stage = 2;
- gamestate = 0;
- }
- else if (key == '3') {
- stage = 3;
- }
- }
- }
- if (stage == 2){
- println(stage);
- fill(0);
- if(gamestate == 0) {
- imageMode(CORNER);
- image(backImg, x, 0);
- image(backImg, x+backImg.width, 0);
- x -= 6;
- vy += 1;
- y += vy;
- if(x == -1800) x = 0;
- for(int i = 0 ; i < 2; i++) {
- imageMode(CENTER);
- image(wallImg, wx[i], wy[i] - (wallImg.height/2+100));
- image(wallImg, wx[i], wy[i] + (wallImg.height/2+100));
- if(wx[i] < 0) {
- wy[i] = (int)random(200,height-200);
- wx[i] = width;
- }
- if(wx[i] == width/2) highScore = max(++score, highScore);
- if(y>height||y
- <0||(abs(width/2-wx[i])
- <25 && abs(y-wy[i])>100)) gamestate=1;
- wx[i] -= 6;
- }
- image(birdImg, width/2, y);
- text(""+score, width/2-15, 700);
- }
- else {
- imageMode(CENTER);
- image(startImg, width/2,height/2);
- text("High Score: "+highScore, 50, width);
- }
- }
- if (mousePressed == true) {
- vy = -17;
- if(gamestate==1) {
- wx[0] = 600;
- wy[0] = y = height/2;
- wx[1] = 900;
- wy[1] = 600;
- x = gamestate = score = 0;
- }
- }
- if(keyPressed) {
- if (key == '1') {
- stage = 1;
- }
- else if (key == '2') {
- stage = 2;
- gamestate = 0;
- }
- else if (key == '3') {
- stage = 3;
- }
- }
- if (stage == 3){
- background(0,255,0); //green
- println(stage);
- if(keyPressed) {
- if (key == '1') {
- stage = 1;
- }
- else if (key == '2') {
- stage = 2;
- gamestate = 0;
- }
- else if (key == '3') {
- stage = 3;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement