uxn/projects/examples/demos/move.tal

79 lines
1.7 KiB
Tal

( devices )
|0000 @System &vector $2 &pad $6 &r $2 &g $2 &b $2
|0020 @Screen &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
|0080 @Controller &vector $2 &button $1 &key $1
( variables )
|0000
@slime $1
( init )
|0100 ( -> ) @program
( theme )
#0daf .System/r DEO2
#02ff .System/g DEO2
#035f .System/b DEO2
( vectors )
;on-frame .Screen/vector DEO2
( set origin )
.Screen/width DEI2 #01 SFT2 .Screen/x DEO2
.Screen/height DEI2 #01 SFT2 .Screen/y DEO2
( defaults )
;default-icn .Screen/addr DEO2
#41 .Screen/sprite DEO
#0a .slime STZ
BRK
@on-frame ( -> )
#0a .slime STZ
;default-icn .Screen/addr DEO2
( hold ctrl key to change slime color )
.Controller/button DEI #0f AND
DUP #01 NEQ ,&no-ctrl JCN #05 .slime STZ &no-ctrl
DUP #02 NEQ ,&no-alt JCN #0f .slime STZ &no-alt
POP
( clear )
#40 .Screen/sprite DEO
( detect movement )
.Controller/button DEI
DUP #10 AND #00 EQU ,&no-up JCN
.Screen/y DEI2 #0001 SUB2 .Screen/y DEO2
;up-icn .Screen/addr DEO2 &no-up
DUP #20 AND #00 EQU ,&no-down JCN
.Screen/y DEI2 INC2 .Screen/y DEO2
;down-icn .Screen/addr DEO2 &no-down
DUP #40 AND #00 EQU ,&no-left JCN
.Screen/x DEI2 #0001 SUB2 .Screen/x DEO2
;left-icn .Screen/addr DEO2 &no-left
DUP #80 AND #00 EQU ,&no-right JCN
.Screen/x DEI2 INC2 .Screen/x DEO2
;right-icn .Screen/addr DEO2 &no-right
POP
( draw face )
#41 .Screen/sprite DEO
( draw slime )
;slime-icn .Screen/addr DEO2
.slime LDZ .Screen/sprite DEO
BRK
@default-icn
3c7e ffdb ffe7 7e3c
@up-icn
2466 e7db ffff 7e3c
@down-icn
3c7e ffff dbe7 6624
@left-icn
3c7e ef1f 1fef 7e3c
@right-icn
3c7e f7f8 f8f7 7e3c
@slime-icn
0000 183c 3c18 0000