脱出ゲームでの部屋にいる状態で周囲を見渡すことをしたいのですが
以下の状態では行うことができません。
何を付け足せばいいのか詳しい方教えてください。
import processing.sound.*;
PFont myFont;
PImage doorImg, wallImg, floorImg, clockImg, keyImg;
SoundFile jiggleSound, clankSound, openSound,rightimg;
Item door, clock, theKey;
boolean solvedFlg = false;
boolean searchFlg = false;
boolean keyFlg = false;
String message = "";
int stat=0; //画面状態を表す状態変数
int x1=0, y1;
int a=1;
void setup() {
size(480, 480);
background(255, 255, 255);
fill(0, 0, 0);
noStroke();
frameRate(40);
myFont = createFont("YuGothic", 24, true);
textFont(myFont);
y1=height;
doorImg = loadImage("sign_door.jpg");
wallImg = loadImage("01murocrep512.jpg");
floorImg = loadImage("metal_s01.png");
clockImg = loadImage("BlackAndWhite2_S.png");
keyImg = loadImage("key.png");
jiggleSound = new SoundFile(this, "LockedDoorHandleJiggle.wav");
clankSound = new SoundFile(this, "dropmetalthing.ogg");
openSound = new SoundFile(this, "closing door.ogg");
door = new Item(doorImg, 150, 133, 6);
clock = new Item(clockImg, 350, 100, 50);
theKey = new Item(keyImg, 350, 310, 7);
}
void draw() {
background(0);
switch(stat) {
case 0: //状態変数が0(つまり画面がTitle)のときの動作
fill(255);
textSize(48);
text("密室からの脱出", 75, 240);
textSize(24);
text("Click with mouse", 140, 300);
break;
case 1: //ゲーム画面
image(wallImg, 0, 0, 480, 300);
image(floorImg, 0, 300, 480, 150);
door.draw();
clock.draw();
if (searchFlg && !keyFlg) { theKey.draw(); } if (solvedFlg) { fill(0); textSize(48); text("CLEAR!", 100, 240); } fill(255); text(message, 10, 475); break;
case 2: //ゲーム画面
image(wallImg, 0, 0, 480, 300);
image(floorImg, 0, 300, 480, 150);
case 3: //ゲーム画面
image(wallImg, 0, 0, 480, 300);
image(floorImg, 0, 300, 480, 150);
}
}
class Item {
PImage img;
int xpos;
int ypos;
int scale;
Item(PImage _img, int _xpos, int _ypos, int _scale) {
img = _img;
xpos = _xpos;
ypos = _ypos;
scale = _scale;
}
void draw() {
int imgWidth = img.width / scale;
int imgHeight = img.height / scale;
image(img, xpos, ypos, imgWidth, imgHeight);
}
boolean isIn(int x, int y) {
if (x >= xpos && x <= xpos + img.width / scale &&
y >= ypos && y <= ypos + img.height / scale) {
return true;
} else {
return false;
}
}
}
void mousePressed() {
switch(stat) {
case 0:
if (mouseX<width) {
x1=0; //次の状態で必要な変数の初期化
stat=1;//ゲーム画面1状態に移る
}
break;
case 1:
message = "";
if (solvedFlg) {
return;
}
if (door.isIn(mouseX, mouseY)) { if (keyFlg) { solvedFlg = true; openSound.play (); } else { jiggleSound.play (); message = "鍵がかかっている。"; } } if (clock.isIn(mouseX, mouseY)) { if (!searchFlg) { searchFlg = true; clankSound.play (); message = "何かが落ちたようだ…"; } } if (theKey.isIn(mouseX, mouseY)) { if (searchFlg && !keyFlg) { keyFlg = true; message = "鍵を見つけた!"; if(mouseX > 400){ stat = 2; if(mouseX < 20){ stat = 4; } } } }
case 2:
if(mouseX > 400){
stat = 3;
if(mouseX < 20){ stat = 1; } }
case 3:
if(mouseX > 400){
stat = 4;
if(mouseX < 20){ stat = 2; } }
case 4:
if(mouseX > 400){
stat = 1;
if(mouseX < 20){ stat = 3; } }
}
}
あなたの回答
tips
プレビュー