これを実行してるときにスペースを押すと左上にメニューが開いて、ドラクエの選択画面みたいなのがでるはずなんですけど、長押しの時はできてたのに、一回だけ検出するようにしたらメニューを開けなくなってしまいました。
一回だけにしたい理由は、長押しの状態だと、たとえばアイテムのらんを開いたときに次のページのポーションまで一緒に選んでしまうからです。
困っているのは、ラべル*command以降のstickとかです。教えてくれる方いませんか。
randomize
screen 0,640,640,,0,0
横=40:縦=40
sdim bag,5,5
repeat 5
bag(cnt)=1
loop
sdim masu,2,横,縦
playerx=20:playery=2:masu(playerx,playery)="@";プレイヤーの初期位置
*idounoato
repeat 縦
ct=cnt
repeat 横
masu(cnt,ct)="";白紙にする
loop
loop
repeat 800
x=rnd(40)
y=rnd(40)
masu(x,y)="壁";壁を書いて
loop
repeat 5
x=rnd(40)
y=rnd(40)
masu(x,y)="1"
loop
x=rnd(40)
y=rnd(40)
masu(x,y)="移";移動を書く
*main
redraw 0
color 0,0,0:boxf
repeat 縦
ct=cnt
repeat 横:color 255,255,255:pos 16*cnt,16*ct : mes masu(cnt,ct):loop
loop
gosub *idouseigyo
gosub *map_move;masu()に@を入れる前にこれが必要
color 255,255,255:masu(playerx,playery)="@"
gosub *command
redraw 1
await 100
goto *main
*idouseigyo
stick key,15
if key=1{
playerx--;左
if playerx<0:playerx++:goto *jump1;画面から出ないようにする
if masu(playerx,playery)="壁":playerx++:goto *jump1;障害物がある場合移動しない
masu(playerx+1,playery)="";左に移動した場合 右にいた時のを消す
}
if key=2{
playery--;上
if playery<0:playery++:goto *jump1;画面から出ないようにする
if masu(playerx,playery)="壁":playery++:goto *jump1;障害物がある場合移動しない
masu(playerx,playery+1)="";上に移動した場合 下にいた時のを消す
}
if key=4{
playerx++;右
if playerx>横-1:playerx--:goto *jump1;画面から出ないようにする -1は必要
if masu(playerx,playery)="壁":playerx--:goto *jump1;障害物がある場合移動しない
masu(playerx-1,playery)="";右に移動した場合 左にいた時のを消す
}
if key=8{
playery++;下
if playery>縦-1:playery--:goto *jump1;画面から出ないようにする -1は必要
if masu(playerx,playery)="壁":playery--:goto *jump1;障害物がある場合移動しない
masu(playerx,playery-1)="";下に移動した場合 上にいた時のを消す
}
*jump1
return
*map_move
if masu(playerx,playery)="移"{
goto *idounoato
}
return
*command
stick key_space,0
if key_space=16{
arrow_pos=0
command_sw=1
goto *menu
}
return
*menu
redraw 0
color 0,0,0:boxf 0,0,100,100
color 255,255,255
pos 20,0:mes "壁を掘る"
pos 20,20:mes "アイテム"
pos 20,40:mes ""+HP
pos 0,20*arrow_pos:mes "→"
stick arrow_key
if arrow_key = 2{;上
arrow_pos--
if arrow_pos<0:arrow_pos++
}
if arrow_key = 8{;下
arrow_pos++
if arrow_pos>1:arrow_pos--
}
stick esc_key;メニューを閉じる
if esc_key=128:goto *main
stick key_enter;決定
if key_enter=32&&arrow_pos=0{;壁を掘るを選んでる
*uketuke
redraw 0
color 255,0,0
pos playerx*16,playery*16-10:mes "↑"
pos playerx*16+10,playery*16:mes "→"
pos playerx*16,playery*16+10:mes "↓"
pos playerx*16-10,playery*16:mes "←"
stick arrow_key
if masu(playerx-1,playery)=""&&masu(playerx,playery-1)=""&&masu(playerx+1,playery)=""&&masu(playerx,playery+1)="":goto *main;4方に壁がないならもどる
if arrow_key=1&&masu(playerx-1,playery)="壁":masu(playerx-1,playery)="":goto *main;左
if arrow_key=2&&masu(playerx,playery-1)="壁":masu(playerx,playery-1)="":goto *main;上
if arrow_key=4&&masu(playerx+1,playery)="壁":masu(playerx+1,playery)="":goto *main;右
if arrow_key=8&&masu(playerx,playery+1)="壁":masu(playerx,playery+1)="":goto *main;下
redraw 1
await 100
goto *uketuke
}
if key_enter=32&&arrow_pos=1{
*uketuke2
redraw 0
color 0,0,0:boxf 100,0,200,100
repeat 5
pos 120,20*cnt:color 255,255,255:mes ""+bag(cnt)
loop
color 255,255,255 :pos 100,20*arrow_pos:mes "→"
stick arrow_key
if arrow_key = 2{;上
arrow_pos--
if arrow_pos<0:arrow_pos++
}
if arrow_key = 8{;下
arrow_pos++
if arrow_pos>4:arrow_pos--
}
stick esc_key;メニューを閉じる
if esc_key=128:goto *main
stick key_enter;決定
if key_enter=32{
if bag(arrow_pos)=1:HP+=20;ポーションで体力20回復
goto *main
}
await 100
redraw 1
goto *uketuke2
}
redraw 1
await 100
goto *menu