当角色在装配中移动时如何改变方向 [英] how to change direction while character is moving in assembly

查看:76
本文介绍了当角色在装配中移动时如何改变方向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个代码

i have this code

.model small
.data
var db  '@', '$'

delaytime db 10
total db 0
col db 40
row db 12
.stack 100h
.code
delay proc
    mov ah, 00
    int 1Ah
    mov bx, dx

jmp_delay:
    int 1Ah
    sub dx, bx
    cmp dl, delaytime
    jl jmp_delay
    ret

delay endp

lefty proc
dec col
cmp col, 0
jle sn

leftyie:
mov dl , col
mov dh , row
xor bh, bh
mov ah, 02h
int 10h
ret 

sn:
mov col, 79
jmp leftyie
lefty endp



righty proc
inc col
cmp col,79
jg zero

rightyie:
mov dl,col
mov dh,row
xor bh, bh
mov ah, 02h
int 10h
ret 

zero: 
mov col,0
jmp rightyie
righty endp



upy proc
dec row
cmp row, 0
jl upzero

uptie:
mov dl,col
mov dh,row
xor bh, bh
mov ah, 02h
ret

upzero:
mov row,24
jmp uptie
 
upy endp


downy proc
inc row
cmp row, 24
jg gozero

downty: 
mov dl,col
mov dh,row
xor bh, bh
 mov ah, 02h
int 10h
ret 

gozero:
mov row,0
jmp downty
downy endp

video proc
mov al, 03h ;set video mode
  mov ah, 00h
  int 10h
  ret
 video endp

start proc
     ;starting coordinates
   mov dh, 12 ;row
   mov dl, 40 ;column
   xor bh, bh
   mov ah, 02h
   int 10h 
   ret
start endp

dashclear proc
mov ax, 0600h
mov bh, 07h
xor cx, cx
mov dx, 184fh
int 10h
ret
dashclear endp

getchar proc
mov ah, 00h
int 16h
ret
getchar endp

    
main  proc
mov ax, @data
mov ds, ax

  
 call video
 call start
   mov dx, offset var
   mov ah, 09h
       int 21h


 mov cx, 3200h  ;stop cursor blinking
 mov ah, 01h
 int 10h

call start
getinput:

call getchar ;get character


direct_change:
cmp ah, 72
je w 
cmp ah, 80
je s 
cmp ah, 75
je a 
cmp ah, 77
je d

cmp al, 119
je w 
cmp al, 115
je s 
cmp al, 97
je a 
cmp al, 100
je d

cmp al, 119
jne rak 
cmp al, 115
jne rak
cmp al, 97
jne rak 
cmp al, 100
jne rak


a:
call delay
call dashclear
call lefty
mov dx, offset var
mov ah, 09h
int 21h


jmp a


s:
call delay
call dashclear
call downy
mov dx, offset var
mov ah, 09h
int 21h

jmp s


d:
call delay
call dashclear

call righty
mov dx, offset var
mov ah, 09h
int 21h

jmp d


w:
call delay
call dashclear

call upy
int 10h
mov dx, offset var
mov ah, 09h
int 21h

jmp w

rak:
jmp getinput

main endp
end main







当我按下字符w,a,s,d进入特定方向

然后它去了在蛇游戏中一直到那个方向



所以当我的角色移动时我该如何改变方向?我认为这是在我的延迟proc

我的想法是

当我不在时间限制内按下wasd键然后它应该继续否则它应该改变方向



关于如何做到这一点的任何想法?




when i pressed character w , a, s, d in go to a specific direction
and it goes to that direction all the way like in the snake game

so how do i change direction while my character is moving? i think it is in my delay proc
my idea is
when i dont press w a s d key within the time limit then it should continue otherwise it should change direction

any idea on how to do this?

推荐答案

'

delaytime db 10
总db 0
col db 40
row db 12
.stack 100h
.code
delay proc
mov ah,00
int 1Ah
mov bx,dx

jmp_delay:
int 1Ah
sub dx,bx
cmp dl,delaytime
jl jmp_delay
ret

delay endp

lefty proc
dec col
cmp col,0
jle sn

leftyie:
mov dl,col
mov dh,row
x or bh,bh
mov ah,02h
int 10h
ret

sn:
mov col,79
jmp leftyie
lefty endp



righty proc
inc col
cmp col,79
jg zero

rightyie:
mov dl,col
mov dh,row
xor bh,bh
mov啊, 02h
int 10h
ret

零:
mov col,0
jmp rightyie
righty endp



upy proc
dec row
cmp row,0
jl upzero

uptie:
mov dl,col
mov dh,row
xor bh,bh
mov ah,02h
ret

upzero:
mov row,24
jmp uptie

upy endp


downy proc
inc row
cmp row,24
jg gozero

downty:
mov dl,col
mov dh,row
xor bh,bh
mov ah,02h
int 10h
ret

gozero:
mov row,0
jmp downty
downy endp

video proc
mov al,03h;设置视频模式
mov啊,00h
int 10h
ret
video endp

start proc
;起始坐标
mov dh,12 ;行
mov dl,40;列
xor bh,bh
mov啊,02h
int 10h
ret
start endp

dashclear proc
mov ax,0600h
mov bh,07h
xor cx,cx
mov dx,184fh
int 10h
ret
dashclear endp

getchar proc
mov ah,00h
int 16h
ret
getchar endp


主要proc
mov ax,@ dat
mov ds,ax


通话视频
通话开始
mov dx,偏移var
mov啊,09h
int 21h


mov cx,3200h;停止光标闪烁
mov ah,01h
int 10h

呼叫开始
getinput:

呼叫getchar;获得字符


direct_change:
cmp啊,72
je w
cmp啊,80
je s
cmp啊,75
je a
cmp啊,77
je d

cmp al,119
je w
cmp al,115
je s
cmp al,97
je a
cmp al,100
je d

cmp al,119
jne rak
cmp al,115
jne rak
cmp al, 97
jne rak
cmp al,100
jne rak


a:
呼叫延迟
呼叫dashclear
叫lefty
mov dx,offset var
mov ah,09h
int 21h


jmp a


s:
呼叫延迟
呼叫dashclear
呼叫downy
mov dx,offset var
mov ah,09h
int 21h

jmp s


d:
呼叫延迟
呼叫dashclear

呼叫权限
mov dx,offset var
mov啊,09h
int 21h

jmp d


w:
呼叫延迟
呼叫dashclear

调用upy
int 10h
mov dx,offset var
mov ah,09h
int 21h

jmp w

rak:
jmp getinput

main endp
end main
' delaytime db 10 total db 0 col db 40 row db 12 .stack 100h .code delay proc mov ah, 00 int 1Ah mov bx, dx jmp_delay: int 1Ah sub dx, bx cmp dl, delaytime jl jmp_delay ret delay endp lefty proc dec col cmp col, 0 jle sn leftyie: mov dl , col mov dh , row xor bh, bh mov ah, 02h int 10h ret sn: mov col, 79 jmp leftyie lefty endp righty proc inc col cmp col,79 jg zero rightyie: mov dl,col mov dh,row xor bh, bh mov ah, 02h int 10h ret zero: mov col,0 jmp rightyie righty endp upy proc dec row cmp row, 0 jl upzero uptie: mov dl,col mov dh,row xor bh, bh mov ah, 02h ret upzero: mov row,24 jmp uptie upy endp downy proc inc row cmp row, 24 jg gozero downty: mov dl,col mov dh,row xor bh, bh mov ah, 02h int 10h ret gozero: mov row,0 jmp downty downy endp video proc mov al, 03h ;set video mode mov ah, 00h int 10h ret video endp start proc ;starting coordinates mov dh, 12 ;row mov dl, 40 ;column xor bh, bh mov ah, 02h int 10h ret start endp dashclear proc mov ax, 0600h mov bh, 07h xor cx, cx mov dx, 184fh int 10h ret dashclear endp getchar proc mov ah, 00h int 16h ret getchar endp main proc mov ax, @data mov ds, ax call video call start mov dx, offset var mov ah, 09h int 21h mov cx, 3200h ;stop cursor blinking mov ah, 01h int 10h call start getinput: call getchar ;get character direct_change: cmp ah, 72 je w cmp ah, 80 je s cmp ah, 75 je a cmp ah, 77 je d cmp al, 119 je w cmp al, 115 je s cmp al, 97 je a cmp al, 100 je d cmp al, 119 jne rak cmp al, 115 jne rak cmp al, 97 jne rak cmp al, 100 jne rak a: call delay call dashclear call lefty mov dx, offset var mov ah, 09h int 21h jmp a s: call delay call dashclear call downy mov dx, offset var mov ah, 09h int 21h jmp s d: call delay call dashclear call righty mov dx, offset var mov ah, 09h int 21h jmp d w: call delay call dashclear call upy int 10h mov dx, offset var mov ah, 09h int 21h jmp w rak: jmp getinput main endp end main







当我按下角色w,a,s,d进入特定的方向时

它会一直朝着那个方向前进,就像在蛇游戏中一样>


所以当我的角色移动时我如何改变方向?我认为这是在我的延迟proc

我的想法是

当我不在时间限制内按下wasd键然后它应该继续否则它应该改变方向



关于如何做到这一点的任何想法?




when i pressed character w , a, s, d in go to a specific direction
and it goes to that direction all the way like in the snake game

so how do i change direction while my character is moving? i think it is in my delay proc
my idea is
when i dont press w a s d key within the time limit then it should continue otherwise it should change direction

any idea on how to do this?


这篇关于当角色在装配中移动时如何改变方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆