#module // 時間を正確に測るためのAPI #uselib "kernel32.dll" #func QueryPerformanceFrequency "QueryPerformanceFrequency" var #func QueryPerformanceCounter "QueryPerformanceCounter" var #deffunc __init_await ddim fr, 1 ddim tm, 1 ddim tm2, 1 ddim wt, 1 ddim xtm, 1 ddim xfr, 1 QueryPerformanceFrequency fr if stat = 0 : return 1 xfr = double(strf("%I64u", fr)) QueryPerformanceCounter tm xtm = double(strf("%I64u", tm)) return 0 #undef await// 既存のawait命令を消す(いままでのawait命令を使用する場合はawait@hspで呼び出せます) #deffunc await double wc wait 0 if wc <= 0.0 {// await 0やawait -1で現在の時刻(?)を基準に設定 QueryPerformanceCounter tm xtm = double(strf("%I64u", tm)) return } wt = xfr * wc / 1000 xtm += wt repeat QueryPerformanceCounter tm2 if double(strf("%I64u", tm2)) - xtm >= wt : break loop return #global __init_await if stat : dialog "エラー", 1 : end await 0// 基準設定。これを音ゲーのループの前に置く。 /**/ *音楽宣言 mmload "初期素材\\タン.wav",1,0 *配列宣言 dim 譜面,5 sdim 譜面_load,5 dim cut,5 dim humen,5,50 dim humen_flg,5,60 dim humen_y,5,60 dim humen_x,5,60 dim key,50 dim key_gata,50 dim x,50 dim y,50 dim hakusen_y,4 /**/ //譜面設定 譜面_load(1)="00000001000000000001000000000001000000000001" 譜面_load(2)="" 譜面_load(3)="" 譜面_load(4)="" humen_dy=10 tenpo=185 kannkaku_set=10000000 hakusen_y(3)=50+240 hakusen_y(2)=50+120 hakusen_y(1)=50 for i,1,5,1 repeat 30 humen_x(i,cnt)=0 humen_y(i,cnt)=0 loop x(i)=0 y(i)=0 next *音ゲー_main gosub *背景の初期化 gosub *キー判定 gosub *譜面の精製 gosub *譜面表示 gosub *拍線 for i,1,5,1 pos 0,20*i color 255,255,255 mes 譜面(i) next color 20,100,250 pos 200,100 mes ""+score+":\n"+conbo+":" mes "BMP:"+tenpo+"\n"+humen_y(1,2)+"" mes hakusen_y(1) redraw 0 await 60000/tenpo/9 redraw 1 goto *音ゲー_main *拍線 color 255,255,255 line 51,hakusen_y(1),253,hakusen_y(1) line 51,hakusen_y(2),253,hakusen_y(2) color 250,10,0 line 51,hakusen_y(3),253,hakusen_y(3) for i,1,4 if hakusen_y(i)>=380 : hakusen_y(i)=20 hakusen_y(i)+=humen_dy next return *背景の初期化 color :boxf 51,21,253,379 //背景 color 255,255,0 line 50,20,254,20 line 50,20,50,380 line 254,20,254,380 color 10,0,255 line 101,20,101,380 line 152,20,152,380 line 203,20,203,380 return *キー判定 getkey key(1),68 getkey key(2),70 getkey key(3),74 getkey key(4),75 getkey key(5),27 if key(5)=1 : await 0 : goto *配列宣言 repeat 60 if key(i)>=1 & key_gata(i)=0{ kaisuu_key(i)++ if i=1 : gradf 52,21,49,360,1,$000000,$fcfb7e if i=2 : gradf 103,21,49,360,1,$000000,$7ffc7f if i=3 : gradf 154,21,49,360,1,$000000,$fc7e7e if i=4 : gradf 205,21,49,360,1,$000000,$7ef5fc if humen_y(i,cnt) <= 388 & humen_y(i,cnt) >=378 { humen_flg(i,cnt) = 0 humen_y(i,cnt)=500 score=score+100+conbo*5/3 conbo++ key_gata(i)=1 color 0,0,0 boxf 50,400,300,415 color 170,170,100 pos i*50+8,400 mes "GREAT" mmplay 1 } if humen_y(i,cnt) <= 377 & humen_y(i,cnt) >=358 { humen_flg(i,cnt) = 0 humen_y(i,cnt)=500 score=score+50+conbo*5/3 conbo++ key_gata(i)=1 color 0,0,0 boxf 50,400,300,415 color 170,170,100 pos i*50+8,400 mes "GOOD" mmplay 1 } if kaisuu_key(i)>=3 & key_gata(i)=0 : key_gata(i)=1 : kaisuu_key(i)=0 } if key(i)=0 & key_gata(i)=1 : key_gata(i)=0 loop return *譜面の精製 for i,1,5,1 譜面(i)=int(strmid(譜面_load(i),cut(i),1)):cut(i)++ next return *譜面表示 for i,1,5,1 gosub *キー判定 if 譜面(i)=1{ repeat 60 if humen_flg(i,cnt) = 0 { humen_flg(i,cnt) = 1 humen_x(i,cnt) = (x(i) + 20) humen_y(i,cnt) = y(i) break } loop } next for i,1,5,1 repeat 60 if i=1 : color 255,0,138 if i=2 : color 250,250,10 if i=3 : color 10,250,0 if i=4 : color 10,250,250 if humen_flg(i,cnt)=1{ color 250,10,0 boxf 51*i,humen_y(i,cnt)-2,51*i+49,humen_y(i,cnt)+2 humen_y(i,cnt)+=humen_dy if humen_y(i,cnt)>=388{ humen_flg(i,cnt) = 0 humen_y(i,cnt)=500 color 0,0,0 boxf 50,400,300,415 color 170,170,100 pos i*50+8,400 mes "MISS" } } loop next return
左からDFJKですがなぜかあたり判定がうまくいきません
どこか悪いところありますか?