(snake) Fixed death bug
This commit is contained in:
parent
5cf69a2659
commit
3e2082dddf
|
@ -64,8 +64,7 @@
|
||||||
|
|
||||||
@<move> ( -- )
|
@<move> ( -- )
|
||||||
( | copy tail )
|
( | copy tail )
|
||||||
[ LITr -snake/pos ] LDZ2r
|
[ LITr -snake/pos ] LDZ2r .snake/length LDZ #00
|
||||||
.snake/length LDZ #00
|
|
||||||
&>loop ( -- )
|
&>loop ( -- )
|
||||||
DUPk ADD .snake/tail ADD LDZ2k STH2
|
DUPk ADD .snake/tail ADD LDZ2k STH2
|
||||||
SWP2r STH2r ROT STZ2
|
SWP2r STH2r ROT STZ2
|
||||||
|
@ -74,13 +73,13 @@
|
||||||
( ) .snake/dead LDZ ?&end
|
( ) .snake/dead LDZ ?&end
|
||||||
.snake/direction LDZ
|
.snake/direction LDZ
|
||||||
( ) DUP #01 NEQ ?{
|
( ) DUP #01 NEQ ?{
|
||||||
.snake/y LDZ #01 SUB .arena/h LDZ [ LTHk JMP SWP POP ] .snake/y STZ }
|
.snake/y LDZk #01 SUB .arena/h set-pos }
|
||||||
DUP #02 NEQ ?{
|
DUP #02 NEQ ?{
|
||||||
.snake/y LDZ INC .arena/h LDZ DIVk MUL SUB .snake/y STZ }
|
.snake/y LDZk INC .arena/h set-pos }
|
||||||
DUP #04 NEQ ?{
|
DUP #04 NEQ ?{
|
||||||
.snake/x LDZ #01 SUB .arena/w LDZ [ LTHk JMP SWP POP ] .snake/x STZ }
|
.snake/x LDZk #01 SUB .arena/w set-pos }
|
||||||
DUP #08 NEQ ?{
|
DUP #08 NEQ ?{
|
||||||
.snake/x LDZ INC .arena/w LDZ DIVk MUL SUB .snake/x STZ }
|
.snake/x LDZk INC .arena/w set-pos }
|
||||||
POP
|
POP
|
||||||
( | detect collision with apple )
|
( | detect collision with apple )
|
||||||
.snake/pos LDZ2 .apple/pos LDZ2 NEQ2 ?{
|
.snake/pos LDZ2 .apple/pos LDZ2 NEQ2 ?{
|
||||||
|
@ -97,6 +96,12 @@
|
||||||
INC GTHk ?&>loop-body
|
INC GTHk ?&>loop-body
|
||||||
POP2 &end JMP2r
|
POP2 &end JMP2r
|
||||||
|
|
||||||
|
@set-pos ( z mod -- )
|
||||||
|
LDZ OVR INC ?{ ROT STZ
|
||||||
|
POP JMP2r }
|
||||||
|
DIVk MUL SUB SWP STZ
|
||||||
|
JMP2r
|
||||||
|
|
||||||
@<add-apple> ( -- )
|
@<add-apple> ( -- )
|
||||||
.DateTime/hour DEI2 .DateTime/minute DEI2 MUL2
|
.DateTime/hour DEI2 .DateTime/minute DEI2 MUL2
|
||||||
( ) DUP2 #1234 MUL2 ADD .arena/w LDZ DIVk MUL SUB .apple/x STZ
|
( ) DUP2 #1234 MUL2 ADD .arena/w LDZ DIVk MUL SUB .apple/x STZ
|
||||||
|
|
Loading…
Reference in New Issue