| ... | ... |
@@ -8,12 +8,14 @@ |
| 8 | 8 |
@ball &x $2 &y $2 &vx $2 &vy $2 |
| 9 | 9 |
@timer $1 |
| 10 | 10 |
@frame $1 |
| 11 |
+ @direction $1 |
|
| 11 | 12 |
|
| 12 | 13 |
( |
| 13 | 14 |
@|vectors ) |
| 14 | 15 |
|
| 15 | 16 |
|0100 |
| 16 |
- |
|
| 17 |
+ ( variables ) |
|
| 18 |
+ #01 .direction STZ |
|
| 17 | 19 |
( vectors ) |
| 18 | 20 |
;on-frame .Screen/vector DEO2 |
| 19 | 21 |
( theme ) |
| ... | ... |
@@ -42,7 +44,7 @@ BRK |
| 42 | 44 |
( reset timer ) |
| 43 | 45 |
[ LIT2 00 -timer ] STZ |
| 44 | 46 |
( 12 frames animation ) |
| 45 |
- .frame LDZ INC DUP #0c NEQ MUL .frame STZ |
|
| 47 |
+ .frame LDZk .direction LDZ ADD #0c DIVk MUL SUB SWP STZ |
|
| 46 | 48 |
move-ball |
| 47 | 49 |
|
| 48 | 50 |
BRK |
| ... | ... |
@@ -50,11 +52,18 @@ BRK |
| 50 | 52 |
( |
| 51 | 53 |
@|core ) |
| 52 | 54 |
|
| 55 |
+@flip-direction ( zp^ -- ) |
|
| 56 |
+ |
|
| 57 |
+ LDZ2k #ffff EOR2 ( INC2 ) ROT STZ2 |
|
| 58 |
+ .direction LDZk #0a EOR SWP STZ |
|
| 59 |
+ |
|
| 60 |
+JMP2r |
|
| 61 |
+ |
|
| 53 | 62 |
@check-flip-vx ( x -- x ) |
| 54 | 63 |
|
| 55 |
- ( left ) DUP2 #0010 LTH2 ?&flip |
|
| 64 |
+ ( left ) DUP2 #0010 LTH2 ?&flip |
|
| 56 | 65 |
( right ) DUP2 .Screen/width DEI2 #0050 SUB2 GTH2 ?&flip !&else |
| 57 |
- &flip .ball/vx LDZ2k #ffff EOR2 ( INC2 ) ROT STZ2 |
|
| 66 |
+ &flip .ball/vx !flip-direction |
|
| 58 | 67 |
&else |
| 59 | 68 |
|
| 60 | 69 |
JMP2r |
| ... | ... |
@@ -62,7 +71,7 @@ JMP2r |
| 62 | 71 |
@check-flip-vy ( y -- y ) |
| 63 | 72 |
|
| 64 | 73 |
( bottom ) DUP2 .Screen/height DEI2 #0050 SUB2 GTH2 ?&flip !&else |
| 65 |
- &flip .ball/vy LDZ2k #ffff EOR2 ( INC2 ) ROT STZ2 |
|
| 74 |
+ &flip .ball/vy !flip-direction |
|
| 66 | 75 |
&else |
| 67 | 76 |
|
| 68 | 77 |
JMP2r |