offset NPC045
#define
max_move_speed = 800
moving_vel = 30
maxYvel = 200
maxXvel = 50
maxmovespeed = 190
#enddefine
push ebp ;This starts the code
mov ebp, esp
sub esp, 10
mov dword [EBP-10],0
mov dword [EBP-C],0
mov dword [EBP-8],0
mov dword [EBP-4],0
setpointer
cmp npc.scriptstate, 1
je :X_mov_handeler
;-------------------------------------
:Statesetup
mov eax PlayerYpos
mov npc.Y, eax
mov edx PlayerXpos
mov npc.X, edx
mov npc.scriptstate, 1
jmp :render
;-------------------------------------
:X_mov_handeler
mov edx, npc.collision
and edx, 1
jne :hit_wall
mov edx, npc.collision
and edx, 4
je :no_hit_wall
:hit_wall
mov npc.moveX, 0
;-------------------
:no_hit_wall
mov eax, keyHeld
and eax, 1
jne :move_left
mov eax, keyHeld
and eax, 2
je :Y_mov_handeler
;-------------------
;move right
add npc.moveX, 10
jmp :Y_mov_handeler
;-------------------
:move_left
add npc.moveX, -10
;-------------------
:Y_mov_handeler
mov edx, npc.collision
and edx, 2
jne :hit_wallY
mov edx, npc.collision
and edx, 3
je :no_hit_wallY
:hit_wallY
mov npc.moveY, 0
;-------------------
:no_hit_wallY
mov eax, keyHeld
and eax, 4
jne :move_up
mov eax, keyHeld
and eax, 3
je :add_vels
;move down
add npc.moveY, 10
jmp :add_vels
:move_up
add npc.moveY, -10
;-------------------------------------
:add_vels
mov eax, npc.moveX
mov edx, npc.moveY
add npc.X eax
add npc.Y edx
mov eax npc.Y
mov playerYpos, eax
mov edx npc.X
mov playerXpos, edx
;-------------------------------------
:Render
xor eax, eax
mov npc.DisplayL,eax
mov npc.displayR,eax
mov npc.displayU,eax
mov npc.displayD,eax
:end_of_code
mov esp, ebp
pop ebp
retn