我正在组装游戏,游戏是一个角色对象(在这种情况下,它是'X'字符)移动闪避0和1。我堕落的物体是完美的我唯一的问题是,如果有人要向左或向右按住方向,我的坠落物体会停下来以适应玩家物体的新位置。我正在使用irvine库进行诸如readkey之类的触发器,其中几乎所有其他内容都是键盘输入100%我。我不确定为什么它会阻止所有内容完成一行代码,这些代码只在打印周期的第一次执行时执行。任何帮助将非常感激。下面我将发布代码。现在,它运行在一个无限循环上,如果你遇到一个物体就会被打破。
;******* proc to make it easier to reprint the rain;Kilian Proc
print PROC
mov esi,0
mov count, 0; intilize as zero to reset the print proc
PrintAll:
mov ecx, count
mov ebx , 0
cmp esi,4
je four
jmp end4
four:
mov esi , 4
end4:
inLoop2:
mov dl,xArray[ebx]
mov dh,yArray[ebx]
call Gotoxy ;Moves cursor to the position of rain
mov al,rainArray[ebx]
call WriteChar ;Rewrite rain
push ecx
cmp ebx, 0
je xmov
jmp endx
xmov:
call ReadKey ; looks for keyboard input
call RightIf
call LeftIf
endx:
pop ecx
call fall
cmp ecx, 0
jne decrease
jmp endD
decrease:
dec ecx
endD:
inc ebx
cmp ebx, esi
ja endinLoop
jmp inLoop2
endinLoop:
mov eax , 105
call delay
call clrscr
mov dh,23d ;move cursor to character's current position ********* Added to this version by Killian edited by John
mov dl , beginX
call Gotoxy
mov al,'X' ;move X into al *********
call WriteChar ;print it **********
call Crlf
xor al,al ;clear
cmp ecx, 0
je random
mov ebx, 0
jmp inLoop2
random:
mov eax, 5
call RandomRange
mov ebx, eax
cmp ebx , 0
je Increase
jmp PrintAll
Increase:
cmp esi, 4
je PrintAll
inc count
inc esi
jmp PrintAll
EndPrint:
ret
print ENDP
这部分代码正在解决问题所在的所有重要问题。如果您想查看完整代码,可以访问Git Repo
答案 0 :(得分:0)
我的修复是将ReadKey,RightIf和LeftIf的调用放在我再次打印'X'代码的地方:
endinLoop:
mov eax , 105
call delay
call clrscr
mov dh,23d ;move cursor to character's current position ********* Added to this version by Killian edited by John
mov dl , beginX
call Gotoxy
mov al,'X' ;move X into al *********
call WriteChar ;print it **********
call Crlf
xor al,al ;clear
push ecx
call ReadKey
call Rightif
call Leftif
pop ecx
cmp ecx, 0
je random
mov ebx, 0
jmp inLoop2
random: