1k bouncing ball

Anything Sinclair ZX Basic related; history, development, tips - differences between BASIC on the ZX80 and ZX81
Post Reply
Shaun_B
Posts: 451
Joined: Wed Apr 22, 2009 10:22 am

1k bouncing ball

Post by Shaun_B » Sat Jan 05, 2019 11:59 am

Here's a 1k bouncing ball demo using some useful memory saving techniques.

Code: Select all

   2 SAVE "B"
   3 CLS
   4 PLOT X,Y
   5 LET X=X+A
   6 LET Y=Y+B
   7 IF Y>=CODE "F" OR NOT Y THEN LET B=-B
   8 IF X>=CODE "Z" OR NOT X THEN LET A=-A
   9 GOTO PI
In direct mode, enter

Code: Select all

LET X=NOT PI
LET Y=X
LET A=NOT X
LET B=NOT Y
GOTO 2
Regards,

Shaun.
Attachments
bouncev2.p
Slight amend to see if I could save more bytes
(267 Bytes) Downloaded 33 times
1kbounce.p
(261 Bytes) Downloaded 38 times
Last edited by Shaun_B on Sat Jan 05, 2019 1:56 pm, edited 1 time in total.

User avatar
Dim_75
Posts: 38
Joined: Fri Sep 01, 2017 11:04 pm
Location: Paris, FR

Re: 1k bouncing ball

Post by Dim_75 » Sat Jan 05, 2019 1:37 pm

Small, simple, cool ! ;) :P

dr beep
Posts: 1178
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: 1k bouncing ball

Post by dr beep » Sat Jan 05, 2019 11:26 pm


Crayon21
Posts: 66
Joined: Sun Nov 04, 2018 2:33 am

Re: 1k bouncing ball

Post by Crayon21 » Tue Feb 05, 2019 12:22 am

Very well done. what are the Not statements for though?
zx81: great yet flawed
Zx spectrum: masterpiece that keeps on giving

(wish it weren't so expensive) :o

dr beep
Posts: 1178
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: 1k bouncing ball

Post by dr beep » Wed Feb 06, 2019 3:05 pm

NOT A will test if A=0

NOT 0 will give 1 as result
When A<>0 then NOT A will return 0 (false)

NOT A is 2 bytes, the shortest (bytesaving) test.

thedevworks
Posts: 15
Joined: Mon Mar 04, 2019 5:33 pm

Re: 1k bouncing ball

Post by thedevworks » Fri Mar 22, 2019 12:40 pm

https://youtu.be/EJCFu95eAxI


Nice :) Fun.. Thanks!

Post Reply