// グローバル変数 boolean stop=false; boolean play = false; int a = 0; PFont font, font2; PImage retry1, retry2; // クラス Ball b; Bar v; Block l; Item i; Start s; /**************************/ void setup() { size(550, 400); frameRate(20); imageMode(CENTER); v = new Bar(150, 350); b = new Ball(v); l = new Block(); i = new Item(); s = new Start(); font = loadFont("STCaiyun-50.vlw"); font2 = loadFont("Mufferaw-30.vlw"); retry1 = loadImage("retry1.gif"); retry2 = loadImage("retry2.gif"); } void draw() { background(#f8f4e6); if (s.notPlay()) { if (a == 0) { s.display1(); } if (a == 1) { s.display2(); } if (a == 2) { s.display3(); } } else if (stop == false) { if (b.life > 0) { if (l.check()) { play = true; showWinMessage(); } else { l.display(); b.display(); v.display(); b.move(v, a); v.move(mouseX); l.broken(b, v, i); } } else { play = true; showLoseMessage(); } } else if (stop == true) { background(#e8ecef); l.display(); b.display(); v.display(); l.broken(b, v, i); b.x += 0; b.y += 0; v.x += 0; textFont(font); textAlign(CENTER); fill(#a6a5c4); textSize(50); text("PAUSE NOW", width/2, height/2); } } void mouseClicked() { if (!s.notPlay() && b.life > 0) { b.start(); } if (play) { if (450 < mouseX && mouseX < 545 && 310 < mouseY && mouseY < 385) { b.initial(v, a); v.initial(); l.initial(); s.initial(); s.display1(); a = 0; play = false; } } } void keyPressed() { if (keyCode == ENTER) { if (s.notPlay()) { l.level(); } s.start(); if (a == 0) { b.life += 2; } } if (keyCode == UP) { if (a > 0 && a <= 2) { a--; } } else if (keyCode == DOWN) { if (a >= 0 && a < 2) { a++; } } else if (key=='s') { stop=true; l.pauset(); } else if (key=='k') { stop=false; l.pausef(); } } void showLoseMessage() { background(#e6eae3); fill(#274a78); textAlign(CENTER); textSize(80); textFont(font); text("You Lose", width/2, height/2); image(retry1, 500, 350, 100, 80); } void showWinMessage() { background(#fddea5); fill(#e83929); textAlign(CENTER); textSize(80); textFont(font); text("You Win!", width/2, height/2); image(retry2, 500, 350, 100, 80); }