Reverse ball rotation after bouncing.

This commit is contained in:
~d6 2023-05-04 18:16:13 -04:00 committed by Devine Lu Linvega
parent 9416a0e813
commit 11a893d10d
1 changed files with 14 additions and 5 deletions

View File

@ -8,12 +8,14 @@
@ball &x $2 &y $2 &vx $2 &vy $2 @ball &x $2 &y $2 &vx $2 &vy $2
@timer $1 @timer $1
@frame $1 @frame $1
@direction $1
( (
@|vectors ) @|vectors )
|0100 |0100
( variables )
#01 .direction STZ
( vectors ) ( vectors )
;on-frame .Screen/vector DEO2 ;on-frame .Screen/vector DEO2
( theme ) ( theme )
@ -42,7 +44,7 @@ BRK
( reset timer ) ( reset timer )
[ LIT2 00 -timer ] STZ [ LIT2 00 -timer ] STZ
( 12 frames animation ) ( 12 frames animation )
.frame LDZ INC DUP #0c NEQ MUL .frame STZ .frame LDZk .direction LDZ ADD #0c DIVk MUL SUB SWP STZ
move-ball move-ball
BRK BRK
@ -50,11 +52,18 @@ BRK
( (
@|core ) @|core )
@flip-direction ( zp^ -- )
LDZ2k #ffff EOR2 ( INC2 ) ROT STZ2
.direction LDZk #0a EOR SWP STZ
JMP2r
@check-flip-vx ( x -- x ) @check-flip-vx ( x -- x )
( left ) DUP2 #0010 LTH2 ?&flip ( left ) DUP2 #0010 LTH2 ?&flip
( right ) DUP2 .Screen/width DEI2 #0050 SUB2 GTH2 ?&flip !&else ( right ) DUP2 .Screen/width DEI2 #0050 SUB2 GTH2 ?&flip !&else
&flip .ball/vx LDZ2k #ffff EOR2 ( INC2 ) ROT STZ2 &flip .ball/vx !flip-direction
&else &else
JMP2r JMP2r
@ -62,7 +71,7 @@ JMP2r
@check-flip-vy ( y -- y ) @check-flip-vy ( y -- y )
( bottom ) DUP2 .Screen/height DEI2 #0050 SUB2 GTH2 ?&flip !&else ( bottom ) DUP2 .Screen/height DEI2 #0050 SUB2 GTH2 ?&flip !&else
&flip .ball/vy LDZ2k #ffff EOR2 ( INC2 ) ROT STZ2 &flip .ball/vy !flip-direction
&else &else
JMP2r JMP2r