@neauoire i would have sent it as a file but it appears my client doesn't allow that.
( the ball's coordinates have 4 digits after the dot )
|00 @system &vector $2 &expansion $2 &wst $1 &rst $1 &metadata $2 &r $2 &g $2 &b $2 &debug $1 &state $1
|10 @Console &vector $2 &read $1 &pad $4 &type $1 &write $1 &error $1
|20 @screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
|80 @Controller &vector $2 &button $1 &key $1
|90 @Mouse &vector $2 &x $2 &y $2 &state $1 &chord $1 &pad $4 &scrolly &scrolly-hb $1 &scrolly-lb $1
|c0 @DateTime &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1
|0008
@shroom/h
|0006
@ball/r
|0000
@shroom &x $2 &y $2 &w $2 &speed $2
@ball &x $2 &y $2 &vx $2 &vy $2
|0100
@on-start ( -> )
#11af .System/r DEO2
#61de .System/g DEO2
#904e .System/b DEO2
#0100 .Screen/width DEO2
#00c0 .Screen/height DEO2
;on-frame .Screen/vector DEO2
;on-controller .Controller/vector DEO2
init-level BRK
@on-frame ( -> )
control step draw BRK
@on-controller ( -> )
BRK
@control ( -- )
.Controller/button DEI
( left ) DUP #40 NEQ ?{
.shroom/x LDZ2k .shroom/speed LDZ2 SUB2 ROT STZ2 }
( right ) #80 NEQ ?{
.shroom/x LDZ2k .shroom/speed LDZ2 ADD2 ROT STZ2 }
JMP2r
@init-level ( -- )
#0018 .shroom/w STZ2
.Screen/width DEI2 .shroom/w LDZ2 SUB2 #01 SFT2 .shroom/x STZ2
.Screen/height DEI2 ;shroom/h SUB2 #0010 SUB2 .shroom/y STZ2
#0001 .shroom/speed STZ2
#0500 .ball/x STZ2
#0500 .ball/y STZ2
#0010 .ball/vx STZ2
#0010 .ball/vy STZ2
JMP2r
@step ( ball )
.ball/x LDZ2k .ball/vx LDZ2 ADD2 ROT STZ2
.ball/y LDZ2k .ball/vy LDZ2 ADD2 ROT STZ2
bounce-shroom bounce
( lose ) .ball/y LDZ2 #04 SFT2 .Screen/height DEI2 LTH2 ?{ lose }
JMP2r
@lose ( -- )
[ LIT2 01 -System/state ] DEO
JMP2r
@bounce ( redo this! )
.ball/x LDZ2 #04 SFT2 .Screen/width DEI2 LTH2 ?{
#0000 .ball/vx LDZ2 SUB2 STH2k .ball/vx STZ2
.ball/x LDZ2k STH2r ADD2 ROT STZ2 }
JMP2r
@bounce-shroom ( -- )
( .ball/vy LDZ2 is-negative [ JMP JMP2r ] )
( top ) .ball/y LDZ2 #04 SFT2 ;ball/r ADD2 .shroom/y LDZ2 GTH2 [ JMP JMP2r ]
( ) .ball/x LDZ2 #04 SFT2 .shroom/x LDZ2
( right ) OVR2 OVR2 .shroom/w LDZ2 ADD2 LTH2 ?{ POP2 JMP2r }
( left ) SWP2 ;ball/r ADD2 LTH2 [ JMP JMP2r ]
( bounce ) #0000 .ball/vy LDZ2 SUB2 .ball/vy STZ2
( | why ORA2 doesn't work?? )
JMP2r
@draw ( foreground )
#0000 DUP2 .Screen/x DEO2
.Screen/y DEO2
#c0 .Screen/pixel DEO
draw-ball draw-shroom JMP2r
@draw-ball ( -- )
#00 .Screen/auto DEO
.ball/x LDZ2 #04 SFT2 .Screen/x DEO2
.ball/y LDZ2 #04 SFT2 .Screen/y DEO2
;ball-chr .Screen/addr DEO2
#c1 .Screen/sprite DEO
JMP2r
@draw-shroom ( -- )
#26 .Screen/auto DEO
.shroom/x LDZ2 .Screen/x DEO2
.shroom/y LDZ2 .Screen/y DEO2
;shroom-chr .Screen/addr DEO2
#c1 .Screen/sprite DEOk DEO
JMP2r
@is-negative ( n* -- f )
#8000 AND2
( | POP #00 )
NEQ JMP2r
@ball-chr [
3078 fcfc 7830 0000 3078 fcfc 7830 0000 ]
@shroom-chr [
0006 0000 0000 0000 3f7f ffff ffff ff7f
00df 0000 0000 0000 ffff ffff ffff ffff
00fc 0c00 0000 0000 fcfe ffff ffff fffe
0000 0001 0301 0000 0000 0001 0301 0000
ff00 ff00 91ff eeff 00ff ffff ffff 738c
0000 0080 c080 0000 0000 0080 c080 0000 ]