いろいろ試してたんでしたが、敵と弾丸が衝突してもダメージを受けない...
というより別の座標の敵がダメージを受けます...T_T
どなたでもいいので当たり判定の if処理 をどうすればいいのか教えてください!!
お願いします。
#module #deffunc exmes str prm1 txt = prm1 cx = ginfo(22) cy = ginfo(23) color 0, 0, 0 pos ( cx - 1 ), ( cy - 1 ) mes txt pos cx, ( cy - 1 ) mes txt pos ( cx + 1 ), ( cy - 1 ) mes txt pos ( cx - 1 ), cy mes txt pos ( cx + 1 ), cy mes txt pos ( cx - 1 ), ( cy + 1 ) mes txt pos cx, ( cy + 1 ) mes txt pos ( cx + 1 ), ( cy + 1 ) mes txt color 255, 255, 255 pos cx, cy mes txt return #deffunc RegularPolygon int prm1, int prm2, int prm3, int prm4, int prm5 center_x = prm1 center_y = prm2 num_top = prm3 radius = prm4 startθ = prm5 if num_top < 3 { return 1 } if radius < 1 { return 1 } dim arrange_x, 4 dim arrange_y, 4 rad0 = double(360) / num_top repeat num_top rad1 = deg2rad(rad0 * (cnt + 1)) + startθ + 1.5707963 rad2 = deg2rad(rad0 * cnt) + startθ + 1.5707963 arrange_x = center_x + (cos(rad1) * radius), center_x + (cos(rad2) * radius), center_x, center_x arrange_y = center_y - (sin(rad1) * radius), center_y - (sin(rad2) * radius), center_y, center_y gsquare -1, arrange_x, arrange_y loop return 0 #global // *** ウィンドウの作成や設定 *** \\ bgscr 0, ginfo(20), ginfo(21), 0, 0, 0 title "Shape War" // *** 自機の弾丸描画 *** \\ buffer 1 color 255, 0, 0 circle 0, 0, 15, 15, 1 color 0, 0, 0 circle 0, 0, 15, 15, 0 gsel 0 // *** 敵の描画1 *** \\ buffer 100 color 0, 0, 0 boxf 0, 0, 30, 30 color 255, 255, 100 boxf 1, 1, 28, 28 gsel 0 // *** 敵の描画2 *** \\ buffer 101 color 255, 128, 128 circle 0, 0, 30, 30, 1 color 0, 0, 0 circle 0, 0, 30, 30, 0 gsel 0 // *** 敵の描画3 *** \\ buffer 102 color 0, 0, 0 RegularPolygon 31, 31, 5, 32, 0 color 128, 128, 255 RegularPolygon 31, 31, 5, 30, 0 gsel 0 // *** 敵の描画4 *** \\ buffer 103 color 0, 0, 0 RegularPolygon 121, 121, 5, 122, 0 color 128, 128, 255 RegularPolygon 121, 121, 5, 120, 0 gsel 0 // *** 変数宣言 *** \\ stx = 1.0 * ginfo(20) * 0.5 sty = 1.0 * ginfo(21) * 0.5 MyAtkBallSpeed = 3.00 MaxMyAtkBallNumber = 1024 ddim MyAtkBall, MaxMyAtkBallNumber, 6 MaxAllEnemyNumber = 1024 ddim Enemy, MaxAllEnemyNumber, 6 MyMaxSpeed = 5.00 // *** メイン処理 *** \\ randomize repeat redraw 0 color 255, 255, 255 boxf stick key, 256 gosub *draw_myball gosub *draw_enemy gosub *draw_my redraw 1 await 16 time = time + 1 loop // *** 自機の弾丸を描画 *** \\ *draw_myball auto = 1 if (( key = 256 ) | auto = 1 ) & ( time \ 5 = 0 ) { MyAtkBallNumber = MyAtkBallNumber + 1 if MyAtkBallNumber >= MaxMyAtkBallNumber { MyAtkBallNumber = 0 } MyAtkBall(MyAtkBallNumber, 0) = stx + mx MyAtkBall(MyAtkBallNumber, 1) = sty + my MyAtkBall(MyAtkBallNumber, 2) = atan(mousey-sty,mousex-stx)*180/M_PI MyAtkBall(MyAtkBallNumber, 3) = MyAtkBallSpeed MyAtkBall(MyAtkBallNumber, 4) = 1.0 MyAtkBall(MyAtkBallNumber, 5) = 0.0 } MyAtkBallGetNumber = 0 repeat ( MaxMyAtkBallNumber - 1 ) if MyAtkBall(cnt, 4) = 1.0 { MyAtkBall(cnt, 5) = MyAtkBall(cnt, 5) + 1 MyAtkBall(cnt, 0) = MyAtkBall(cnt, 0) + ( MyAtkBall(cnt, 3) * cos( 3.141593 * MyAtkBall(cnt, 2) / 180 )) MyAtkBall(cnt, 1) = MyAtkBall(cnt, 1) + ( MyAtkBall(cnt, 3) * sin( 3.141593 * MyAtkBall(cnt, 2) / 180 )) color 255, 255, 255 gmode 4, 0, 0, 256 pos MyAtkBall(cnt, 0) - mx, MyAtkBall(cnt, 1) - my gcopy 1, 0, 0, 15, 15 pos MyAtkBall(cnt, 0) - mx, MyAtkBall(cnt, 1) - my - 45 if MyAtkBall(cnt, 5) >= 120.0 { MyAtkBall(cnt, 5) = 0.0 MyAtkBall(cnt, 4) = 0.0 } MyAtkBallGetNumber = MyAtkBallGetNumber + 1 } loop return // *** 敵の描画 *** \\ *draw_enemy font "メイリオ", 30, 1 repeat ( MaxAllEnemyNumber - 1 ) if Enemy(cnt, 3) = 0 { Enemy(cnt, 0) = 1.0 * rnd(10000) Enemy(cnt, 1) = 1.0 * rnd(10000) if rnd(10) = 0 { Enemy(cnt, 2) = 0.0 } if rnd(25) = 0 { Enemy(cnt, 2) = 1.0 } if rnd(50) = 0 { Enemy(cnt, 2) = 2.0 } if rnd(100) = 0 { Enemy(cnt, 2) = 3.0 } Enemy(cnt, 3) = 1.0 if Enemy(cnt, 2) = 0 { EnemyMaxHP = 10 } if Enemy(cnt, 2) = 1 { EnemyMaxHP = 30 } if Enemy(cnt, 2) = 2 { EnemyMaxHP = 100 } if Enemy(cnt, 2) = 3 { EnemyMaxHP = 3000 } Enemy(cnt, 4) = 1.0 * EnemyMaxHP Enemy(cnt, 5) = Enemy(cnt, 4) } if Enemy(cnt, 0) - mx >= -500 & Enemy(cnt, 1) - my >= -500 & Enemy(cnt, 0) - mx <= ( ginfo(20) + 500 ) & Enemy(cnt, 1) - my <= ( ginfo(21) + 500 ) { if Enemy(cnt, 3) = 1 { if Enemy(cnt, 2) = 0 { color 255, 255, 255 gmode 4, 0, 0, 256 pos Enemy(cnt, 0) - mx, Enemy(cnt, 1) - my gcopy 100, 0, 0, 30, 30 } if Enemy(cnt, 2) = 1 { color 255, 255, 255 gmode 4, 0, 0, 256 pos Enemy(cnt, 0) - mx, Enemy(cnt, 1) - my gcopy 101, 0, 0, 30, 30 } if Enemy(cnt, 2) = 2 { color 255, 255, 255 gmode 4, 0, 0, 256 pos Enemy(cnt, 0) - mx, Enemy(cnt, 1) - my gcopy 102, 0, 0, 60, 60 } if Enemy(cnt, 2) = 3 { color 255, 255, 255 gmode 4, 0, 0, 256 pos Enemy(cnt, 0) - mx, Enemy(cnt, 1) - my gcopy 103, 0, 0, 240, 240 pos Enemy(cnt, 0) - mx - 11, Enemy(cnt, 1) - my - 45 exmes "Alpha Pentagon" } pos Enemy(cnt, 0) - mx - 11, Enemy(cnt, 1) - my - 100 if Enemy(cnt, 5) < Enemy(cnt, 4) { if Enemy(cnt, 2) = 0 | Enemy(cnt, 2) = 1 { if Enemy(cnt, 5) > 0 { color 100, 100, 100 boxf ( Enemy(cnt, 0) - mx - 10 ), ( Enemy(cnt, 1) - my + 32 ), ( Enemy(cnt, 0) - mx + 40 ), ( Enemy(cnt, 1) - my + 38 ) color 128, 0, 0 boxf ( Enemy(cnt, 0) - mx - 8 ), ( Enemy(cnt, 1) - my + 34 ), ( Enemy(cnt, 0) - mx + 38 ), ( Enemy(cnt, 1) - my + 36 ) color 0, 192, 0 boxf ( Enemy(cnt, 0) - mx - 8 ), ( Enemy(cnt, 1) - my + 34 ), (( Enemy(cnt, 0) - mx - 8 ) + ( Enemy(cnt, 5) / Enemy(cnt, 4) ) * 46 ), ( Enemy(cnt, 1) - my + 36 ) } } if Enemy(cnt, 2) = 2 { if Enemy(cnt, 5) > 0 { color 100, 100, 100 boxf ( Enemy(cnt, 0) - mx ), ( Enemy(cnt, 1) - my + 62 ), ( Enemy(cnt, 0) - mx + 60 ), ( Enemy(cnt, 1) - my + 68 ) color 128, 0, 0 boxf ( Enemy(cnt, 0) - mx + 2 ), ( Enemy(cnt, 1) - my + 64 ), ( Enemy(cnt, 0) - mx + 58 ), ( Enemy(cnt, 1) - my + 66 ) color 0, 192, 0 boxf ( Enemy(cnt, 0) - mx + 2 ), ( Enemy(cnt, 1) - my + 64 ), (( Enemy(cnt, 0) - mx ) + ( Enemy(cnt, 5) / Enemy(cnt, 4) ) * 46 ), ( Enemy(cnt, 1) - my + 66 ) } } if Enemy(cnt, 2) = 3 { if Enemy(cnt, 5) > 0 { color 100, 100, 100 boxf ( Enemy(cnt, 0) - mx ), ( Enemy(cnt, 1) - my + 223 ), ( Enemy(cnt, 0) - mx + 240 ), ( Enemy(cnt, 1) - my + 231 ) color 128, 0, 0 boxf ( Enemy(cnt, 0) - mx + 2 ), ( Enemy(cnt, 1) - my + 225 ), ( Enemy(cnt, 0) - mx + 238 ), ( Enemy(cnt, 1) - my + 229 ) color 0, 192, 0 boxf ( Enemy(cnt, 0) - mx + 2 ), ( Enemy(cnt, 1) - my + 225 ), (( Enemy(cnt, 0) - mx ) + ( Enemy(cnt, 5) / Enemy(cnt, 4) ) * 239 ), ( Enemy(cnt, 1) - my + 229 ) } } } } } ////////////////////////////////////////// 当たり判定 /////////////////////////////////////// { Enemy(cnt, 5) = Enemy(cnt, 5) - 1.0 } if Enemy(cnt, 5) <= 0.0 { Enemy(cnt, 3) = 0.0 if Enemy(cnt, 2) = 0 { score = score + 10 } if Enemy(cnt, 2) = 1 { score = score + 25 } if Enemy(cnt, 2) = 2 { score = score + 130 } if Enemy(cnt, 2) = 3 { score = score + 3000 } } loop return // *** 自機を描画 *** \\ *draw_my color 255, 0, 0 circle stx - 30, sty - 30, stx + 30, sty + 30, 1 color 0, 0, 0 circle stx - 30, sty - 30, stx + 30, sty + 30, 0 getkey keyW, 'W' getkey keyA, 'A' getkey keyS, 'S' getkey keyD, 'D' brake = ( 0.05 ) if keyW = 1 { mmyy = mmyy + 0.1 my = my - ( mmyy + 1.0 ) if mmyy >= MyMaxSpeed { mmyy = MyMaxSpeed } } else { mmyy = mmyy - brake my = my - mmyy if mmyy <= 0.0 { mmyy = 0.0 } } if keyA = 1 { mmyx = mmyx + 0.1 mx = mx - ( mmyx + 1.0 ) if mmyx >= MyMaxSpeed { mmyx = MyMaxSpeed } } else { mmyx = mmyx - brake mx = mx - mmyx if mmyx <= 0.0 { mmyx = 0.0 } } if keyS = 1 { pmyy = pmyy + 0.1 my = my + ( pmyy + 1.0 ) if pmyy >= MyMaxSpeed { pmyy = MyMaxSpeed } } else { pmyy = pmyy - brake my = my + pmyy if pmyy <= 0.0 { pmyy = 0.0 } } if keyD = 1 { pmyx = pmyx + 0.1 mx = mx + ( pmyx + 1.0 ) if pmyx >= MyMaxSpeed { pmyx = MyMaxSpeed } } else { pmyx = pmyx - brake mx = mx + pmyx if pmyx <= 0.0 { pmyx = 0.0 } } color 0, 0, 0 pos 10, 10 font "メイリオ", 30, 1 exmes "Score:" + score return