①:実行した画面において"Fight(戦う)"と"Run(にげる)"を選択し、戦うを選択した際、技を選び、お互いのHPが減るプログラムを書いています。しかし"Fight"を選択しただけでHPが減ってしまいます。プログラムを見直しても原因がわかりません。どこを直すべきか教えていただきたいです。 ②:①と同様に"Run"を選択した場合はゲームオーバー画面となり、そこでタイトルに戻るようにプログラムしたいのですが、なぜか直接タイトルに戻ってしまいます。プログラムのどこを変更したら良いでしょうか?教えていただきたいです。
Processing
1 2![使用しているいらすとやの敵キャラ画像です](f7cce1c0e00dfb8728e352930b89608c.png) 3![味方キャラの画像です](ebbee74ec855ad0421552dd8b2f5c390.png) 4 5PImage pictureBull; 6PImage pictureMe; 7float scale1 = 0.2; 8float scale2 = 0.2; 9 10int scene = 1; 11int myHP = 15; 12int opoHP = 20; 13 14int BR = 3; 15int BC = 2; 16int Pro; 17int Hea; 18int BullHorn = 2; 19 20void setup() { 21 size(480, 480); 22 23 pictureBull = loadImage("Bull.png"); 24 pictureMe = loadImage("me.png"); 25 26} 27 28void mousePressed() { 29 if (mousePressed) { 30 31 if (scene == 1) { 32 if (mouseX >= 50 && mouseX < 250 && mouseY <= 300 && mouseY > 200) {//fight 33 scene = 2; 34 } 35 if (mouseX >= 250 && mouseX < 400 && mouseY <= 400 && mouseY > 200) {//run 36 scene = 6; 37 } 38 } 39 if (scene == 2) { //send out 40 if (mouseX >= 330 && mouseX < 440 && mouseY <= 317 && mouseY > 287) {//gray filter 41 scene = 3; 42 } 43 } 44 if (scene == 3) { //click attack or run command 45 if (mouseX >= 10 && mouseX < 85 && mouseY <= 415 && mouseY > 380 ) { //attack 46 scene = 4; 47 } 48 if (mouseX >= 10 && mouseX < 85 && mouseY <= 480 && mouseY > 415 ) { //run 49 scene = 6; 50 } 51 } 52 if (scene == 4) {//select move 53 if (mouseX >= 10 && mouseX < 85 && mouseY <= 415 && mouseY > 380 ) { 54 opoHP = opoHP - BR; //[Move]BoneRush 55 myHP = myHP - BullHorn; //damage 56 } 57 if (mouseX >= 10 && mouseX < 85 && mouseY <= 450 && mouseY > 415 ) { 58 opoHP = opoHP - BC; //[Move]BoneCrash 59 myHP = myHP - BullHorn; //damage 60 } 61 if (mouseX >= 85 && mouseX < 160 && mouseY <= 415 && mouseY > 380 ) { 62 myHP = myHP + 3; //[Move]Heal 63 } 64 if (mouseX >= 85 && mouseX < 160 && mouseY <= 450 && mouseY > 415 ) { 65 myHP = myHP + 4; //[Move]Heal2 66 } 67 } 68 if (scene == 6) { //dead 69 if (mouseX >= 0 && mouseX < 480 && mouseY <= 480 && mouseY > 380) { 70 scene = 1; 71 72 } 73 } 74 if (scene == 4 && opoHP <= 0 || scene == 4 && myHP <= 0 || scene == 4 && myHP <= 0 && opoHP <= 0) { // 75 if (mouseX >= 150 && mouseX < 280 && mouseY <= 250 && mouseY > 150) { 76 scene = 1; 77 } 78 } 79 } 80} 81 82void draw() { 83 if (scene == 1) {//Select Fight or Run 84 background(#E8DC98); 85 fill(0); 86 textSize(20); 87 text("A monster is approaching you ...", 100, 100); 88 text("Fight Now ?", 100, 150); 89 noFill(); 90 rect(50, 200, 400, 100); 91 line(250, 200, 250, 300); 92 textSize(50); 93 text("Fight", 80, 270); 94 text("Run", 300, 270); 95 } 96 97 if (scene == 2) {//Just send out my monster 98 background(#87CE95); 99 //field objects 100 stroke(0); 101 fill(255); 102 ellipse(340, 370, 250, 80); //my field 103 ellipse(140, 160, 120, 40); //opponent's field 104 rect(10, 380, 150, 70); //my command box 105 textSize(20); 106 fill(0); 107 text("Fight", 25, 405); 108 text("Run", 25, 440); 109 line(85, 380, 85, 450); 110 line(10, 415, 160, 415); 111 fill(255); //my HP box 112 rect(10, 335, 100, 40); 113 textSize(22); 114 fill(0); 115 text("HP : " + myHP, 20, 362); 116 fill(255); //opponent's HP box 117 rect(300, 90, 100, 40); 118 textSize(22); 119 fill(0); 120 text("HP : " + opoHP, 310, 118); 121 fill(255);//opponent name 122 rect(300, 50, 170, 40); 123 fill(0); 124 text("The Killer Bull", 310, 80); 125 //characters 126 image(pictureBull, 75, 30, pictureBull.width * scale1, pictureBull.height * scale1);//Bull 127 //filter 128 fill(0, 0, 0, 128); 129 rect(0, 0, 480, 480); 130 //Massage 131 fill(#FFC9D0); 132 rect(330, 287, 110, 30); 133 fill(0); 134 textSize(20); 135 text("Send Out", 340, 310); 136 } 137 138 if (scene == 3) {//select fight or run 139 background(#87CE95); 140 //field objects 141 stroke(0); 142 fill(255); 143 ellipse(340, 370, 250, 80); //my field 144 ellipse(140, 160, 120, 40); //opponent's field 145 rect(10, 380, 150, 70); //my command box 146 textSize(20); 147 fill(0); 148 text("Fight", 25, 405); 149 text("Run", 25, 440); 150 line(85, 380, 85, 450); 151 line(10, 415, 160, 415); 152 fill(255); //my HP box 153 rect(10, 335, 100, 40); 154 textSize(22); 155 fill(0); 156 text("HP : " + myHP, 20, 362); 157 fill(255); //opponent's HP box 158 rect(300, 90, 100, 40); 159 textSize(22); 160 fill(0); 161 text("HP : " + opoHP, 310, 118); 162 fill(255);//opponent name 163 rect(300, 50, 170, 40); 164 fill(0); 165 text("The Killer Bull", 310, 80); 166 //characters 167 image(pictureBull, 75, 30, pictureBull.width * scale1, pictureBull.height * scale1);//Bull 168 image(pictureMe, 280, 220, pictureMe.width * scale2, pictureMe.height * scale2);//me 169 } 170 171 if (scene == 4) {//fight command and select move 172 background(#87CE95); 173 //field objects 174 stroke(0); 175 fill(255); 176 ellipse(340, 370, 250, 80); //my field 177 ellipse(140, 160, 120, 40); //opponent's field 178 rect(10, 380, 150, 70); //my command box 179 textSize(15); 180 fill(0); 181 text("BoneRush", 13, 405); 182 text("BoneClub", 13, 440); 183 text("Heal", 95, 405); 184 text("Heal2", 95, 440); 185 line(85, 380, 85, 450); 186 line(10, 415, 160, 415); 187 fill(255); //my HP box 188 rect(10, 335, 100, 40); 189 textSize(22); 190 fill(0); 191 text("HP : " + myHP, 20, 362); 192 fill(255); //opponent's HP box 193 rect(300, 90, 100, 40); 194 textSize(22); 195 fill(0); 196 text("HP : " + opoHP, 310, 118); 197 fill(255);//opponent name 198 rect(300, 50, 170, 40); 199 fill(0); 200 text("The Killer Bull", 310, 80); 201 //characters 202 image(pictureBull, 75, 30, pictureBull.width * scale1, pictureBull.height * scale1);//Bull 203 image(pictureMe, 280, 220, pictureMe.width * scale2, pictureMe.height * scale2);//me 204 } 205 206 if (scene == 5) { 207 background(#87CE95); 208 //field objects 209 stroke(0); 210 fill(255); 211 ellipse(340, 370, 250, 80); //my field 212 ellipse(140, 160, 120, 40); //opponent's field 213 rect(10, 380, 150, 70); //my command box 214 textSize(15); 215 fill(0); 216 text("BoneRush", 13, 405); 217 text("Protect", 20, 440); 218 text("Reflect", 95, 405); 219 text("BoneClub", 88, 440); 220 line(85, 380, 85, 450); 221 line(10, 415, 160, 415); 222 fill(255); //my HP box 223 rect(10, 335, 100, 40); 224 textSize(22); 225 fill(0); 226 text("HP : " + myHP, 20, 362); 227 fill(255); //opponent's HP box 228 rect(300, 90, 100, 40); 229 textSize(22); 230 fill(0); 231 text("HP : " + opoHP, 310, 118); 232 fill(255);//opponent name 233 rect(300, 50, 170, 40); 234 fill(0); 235 text("The Killer Bull", 310, 80); 236 //characters 237 image(pictureBull, 75, 30, pictureBull.width * scale1, pictureBull.height * scale1);//Bull 238 image(pictureMe, 280, 220, pictureMe.width * scale2, pictureMe.height * scale2);//me 239 } 240 241 if (scene == 6) {//Game Over 242 background(#9B1B2C); 243 fill(0); 244 textSize(28); 245 text("The monster stabbed behind you ", 10, 50); 246 text("by a big horn", 40, 80); 247 fill(255); 248 textSize(60); 249 text("You Dead", 70, 240); 250 fill(#FF6A7E); 251 rect(0, 380, 480, 480); 252 textSize(35); 253 fill(0); 254 text("Click Here", 290, 440); 255 }
・ソースコードは```で囲んでください。表示が崩れるのと、ソースコードのコピーが面倒になってしまうので...
・画像は```で囲んだ外側に配置してください。
・おそらく、一番外側の括弧が対応していない(最後の括弧が足りない)と思われます。
質問の編集が可能ですので、よろしくお願いいたします。
回答2件
あなたの回答
tips
プレビュー