KeyPressed (関数)
Format
keypressed ( expression )
説明
KeyPressed関数は、キーが現在押されている場合はtrueまたはfalseの値を返すか、現在押されているキーの数を返します。 キーボードバッファをクリアするキー関数とは異なり、KeyPressed関数はクリアしません。 これにより、はるかに応答性の高いゲームを作成したり、キーボードを他の用途に使用したりできます。
一般的なキーコードのリストについては、key関数を参照してください。または、完全なリストコードについては、こちらを参照してください。
例
ar_down=16777237
ar_up=16777235
ar_left=16777234
ar_right=16777236
fastgraphics
x = 150
y = 150
color blue
print "use arrows to move the ball, space to exit"
while not keypressed(32)
if keypressed(ar_down) then y = y + 1
if keypressed(ar_up) then y = y - 1
if keypressed(ar_right) then x = x + 1
if keypressed(ar_left) then x = x - 1
# keep x and y in bounds 0-300
x = (x + 300) % 300
y = (y + 300) % 300
# draw ball
clg
circle x,y,10
refresh
end while
コメント
最新を表示する
NG表示方式
NGID一覧