上から降ってくる的を獲得していくゲームです。
スコア表示、タイム表示がうまくいきません。”0”の上に”10”が重なりまたそのうえに”20”が重なり、、、といった具合に数字が重なって表示されてしまいます。重ならないよう表示したいですが、、、。ご教授お願いします。
スコア、タイム表示に関係ある場所に/////////////////をつけています。
buffer 1,80,40
picload "tip.png"
screen 0,500,400
//敵の情報
dim enemy,20
dim enemy_x,20
dim enemy_y,20
//ゲーム開始時
score = 0 /////////////////////開始時の値
timer = 250
*main
gosub *display
gosub *jiki_process
gosub *enemy_appear
gosub *enemy_process
gosub *count ///////////////////////スコアとタイム表示
redraw 1
wait 0.6
redraw 0
goto *main
//画面初期化&自機描画ルーチン
*display
color 0,0,0
boxf 0,0,400,400 //背景塗りつぶし
pos x,y+360
gcopy 1,0,0,40,40 //自機表示
return
//自機の操作ルーチン
*jiki_process
stick key,31
if key & 1:x--
if key & 4:x++
if x < 0 :x = 0
if x > 360:x = 360
if y < 0 :y = 0
if y > 360:y = 360
return
//敵出現ルーチン
*enemy_appear
time++
if (time \ 200) = 0 {
repeat 20
if enemy(cnt) = 0 {
enemy(cnt) = 1
enemy_x(cnt) = rnd(361)
enemy_y(cnt) = -40
enemy_hp(cnt) = 10
break
}
loop
}
return
*enemy_process
//敵の処理
repeat 20
if enemy_y(cnt) > 400 : enemy(cnt) = 0
if enemy(cnt) = 1{
enemy_y(cnt)++
if (abs(x - enemy_x(cnt)) < 40) & (abs(y+360 - enemy_y(cnt)) < 40){
enemy(cnt) = 0
score = score + 10 /////////////////////スコアの加算(的と接触したとき)
}
pos enemy_x(cnt),enemy_y(cnt)
gcopy 1,40,0,40,40
}
loop
return
*count
////////////////////////////////////////////////タイマーとスコアの処理
pos 410,80:mes "タイム:"+timer
timer--
pos 410,40:mes strf("Score:%03d",score)
return