我是 Pascal 的初学者,我正在开发一个小型 WIngraph 游戏。在游戏的某个时刻,角色(即一个方块)必须躺下(方块得到其原始高度的一半)。我希望在按住向下箭头键时发生这种情况,但我实现它的方式实际上并没有奏效。我遇到的另一个问题是我不知道如何同时读取键(例如,向右跑和跳跃时需要这样做)。
这就是我尝试编写它的方式:
procedure joystick;
begin
key:=readkey;
case key of
#0:begin
key:=readkey;
case key of
#80:with block do
begin
y1:=y2-100; //make it get half of its height
repeat
moveblock; //these are the drawing routines.
moveball; //they are in another procedure, which is the 'main loop'
collisioncheck;
draw; //i expected the code to run inside here with the block's
alternateball; //height changed, and as soon as the arrow key gets released
updateGraph(updateNow); //it should go back to the 'main loop'
killball;
delay(10);
until keypressed = false; //<--thats what i think is not working
y1:=y2-200; //this would make the block get normal again
end;
end;
end;
end;
我希望代码在按键被按下时运行良好,一旦它被释放,块应该得到它的正常高度,然后程序将根据它的主循环运行,但在这个过程之外。
一切正常,除了那个拿钥匙的东西。