Tune snake speed and fix a bug with turning code
This commit is contained in:
parent
4a63bf5467
commit
2368fa7b7f
12
mato8.asm
12
mato8.asm
|
@ -4,7 +4,7 @@
|
||||||
; Under Creative Commons Zero 1.0
|
; Under Creative Commons Zero 1.0
|
||||||
; Assemble with c8asm (https://github.com/wernsey/chip8)
|
; Assemble with c8asm (https://github.com/wernsey/chip8)
|
||||||
|
|
||||||
define frames_wait 4
|
define frames_wait 5
|
||||||
|
|
||||||
define up_key 2
|
define up_key 2
|
||||||
define down_key 8
|
define down_key 8
|
||||||
|
@ -46,6 +46,8 @@ mainloop:
|
||||||
ld v0, frames_wait
|
ld v0, frames_wait
|
||||||
ld dt, v0
|
ld dt, v0
|
||||||
|
|
||||||
|
ld v1, head_direction_reg
|
||||||
|
|
||||||
ld v0, up_key
|
ld v0, up_key
|
||||||
sknp v0
|
sknp v0
|
||||||
call turn_up
|
call turn_up
|
||||||
|
@ -116,22 +118,22 @@ spawn_fruit:
|
||||||
|
|
||||||
turn_up:
|
turn_up:
|
||||||
; Don't allow 180° turns (which would kill the snake instantly)
|
; Don't allow 180° turns (which would kill the snake instantly)
|
||||||
se head_direction_reg, direction_down
|
se v1, direction_down
|
||||||
ld head_direction_reg, direction_up
|
ld head_direction_reg, direction_up
|
||||||
ret
|
ret
|
||||||
|
|
||||||
turn_down:
|
turn_down:
|
||||||
se head_direction_reg, direction_up
|
se v1, direction_up
|
||||||
ld head_direction_reg, direction_down
|
ld head_direction_reg, direction_down
|
||||||
ret
|
ret
|
||||||
|
|
||||||
turn_left:
|
turn_left:
|
||||||
se head_direction_reg, direction_right
|
se v1, direction_right
|
||||||
ld head_direction_reg, direction_left
|
ld head_direction_reg, direction_left
|
||||||
ret
|
ret
|
||||||
|
|
||||||
turn_right:
|
turn_right:
|
||||||
se head_direction_reg, direction_left
|
se v1, direction_left
|
||||||
ld head_direction_reg, direction_right
|
ld head_direction_reg, direction_right
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue