uxn/projects/examples/dev.controller.buttons.usm

99 lines
1.8 KiB
Plaintext

( Dev/Controller )
%++ { #0001 ADD2 }
%-- { #0001 SUB2 }
%2/ { #0002 DIV2 }
( variables )
@slime [
&color 00
&end
]
( devices )
|0100 @System [
&vector 0000
&pad 0000
0000
0000
&r 0000
&g 0000
&b 0000
&end
]
|0120 @Screen [
&vector 0000
&width 0000
&height 0000
&pad 0000
&x 0000
&y 0000
&addr 0000
&color 00
&end
]
|0140 @Controller [
&vector 0000
&button 00
&key 00
&end
]
|0200
( theme ) #0daf =System/r #02ff =System/g #035f =System/b
( vectors ) ,on-frame =Screen/vector
( set origin )
~Screen/width 2/ =Screen/x
~Screen/height 2/ =Screen/y
,default_icn =Screen/addr
#31 =Screen/color
#2a =slime/color
BRK
@on-frame
#2a =slime/color
,default_icn =Screen/addr
( hold ctrl key to change slime color )
~Controller/button #0f AND
DUP #01 NEQ ^$no-ctrl JNZ #25 =slime/color $no-ctrl
DUP #02 NEQ ^$no-alt JNZ #2f =slime/color $no-alt
POP
( clear ) #30 =Screen/color
( detect movement )
~Controller/button #f0 AND
DUP #04 SFT #01 AND #01 NEQ ^$no-up JNZ
( move ) ~Screen/y -- =Screen/y ,up_icn =Screen/addr $no-up
DUP #05 SFT #01 AND #01 NEQ ^$no-down JNZ
( move ) ~Screen/y ++ =Screen/y ,down_icn =Screen/addr $no-down
DUP #06 SFT #01 AND #01 NEQ ^$no-left JNZ
( move ) ~Screen/x -- =Screen/x ,left_icn =Screen/addr $no-left
DUP #07 SFT #01 AND #01 NEQ ^$no-right JNZ
( move ) ~Screen/x ++ =Screen/x ,right_icn =Screen/addr $no-right
POP
( draw face )
#31 =Screen/color
( draw slime )
,slime_icn =Screen/addr
~slime/color =Screen/color
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 ]