Page 1 of 1
Bouncing ball within a bouncing frame
Posted: Wed Feb 19, 2025 10:22 pm
by MarkTheStrange
This was a challenge on the Facebook C64/C128 programmers group:
Create a sprite with a frame. Bounce a pixel within the sprite's frame. Bounce the sprite on the screen.
I thought an X16 version would be a fun task. The challenge was specifically to do it entirely in BASIC on the C64 using an expanded sprite (double-width, double-height) in a program with the smallest memory footprint (my X16 version takes up 244 bytes, but you get to stare at a screen doing nothing for many seconds while it initializes the sprite bitmap dynamically).
Since a square sprite makes for a boring bounce along a line between opposite corners, I made the ball bounce within a 48x42 rectangle inside the 64x64 sprite (to match an expanded sprite on the C64).

- Screenshot 2025-02-19 at 17.14.51.png (69.17 KiB) Viewed 935 times
Try It Now!
Re: Bouncing ball within a bouncing frame
Posted: Fri Feb 21, 2025 2:53 pm
by ahenry3068
MarkTheStrange wrote: ↑Wed Feb 19, 2025 10:22 pm
This was a challenge on the Facebook C64/C128 programmers group:
Create a sprite with a frame. Bounce a pixel within the sprite's frame. Bounce the sprite on the screen.
I thought an X16 version would be a fun task. The challenge was specifically to do it entirely in BASIC on the C64 using an expanded sprite (double-width, double-height) in a program with the smallest memory footprint (my X16 version takes up 244 bytes, but you get to stare at a screen doing nothing for many seconds while it initializes the sprite bitmap dynamically).
Since a square sprite makes for a boring bounce along a line between opposite corners, I made the ball bounce within a 48x42 rectangle inside the 64x64 sprite (to match an expanded sprite on the C64). Screenshot 2025-02-19 at 17.14.51.png
Try It Now!
Had to do my Own version

. I
DID NOT even look at Mark's code.
Try It Now!
Re: Bouncing ball within a bouncing frame
Posted: Fri Feb 21, 2025 3:39 pm
by MarkTheStrange
Well, that's much fancier. Change the frame to a gilded picture frame and it will fit right in.

Re: Bouncing ball within a bouncing frame
Posted: Fri Feb 21, 2025 5:12 pm
by ahenry3068
MarkTheStrange wrote: ↑Fri Feb 21, 2025 3:39 pm
Well, that's much fancier. Change the frame to a gilded picture frame and it will fit right in.
That's doable... I will see.
Re: Bouncing ball within a bouncing frame
Posted: Fri Feb 21, 2025 6:09 pm
by kelli217
Looks like Robin saw the challenge too. [yt]
https://www.youtube.com/watch?v=zwTA7xi0QD0[/yt]
Bouncing ball With some Physics
Posted: Fri Feb 21, 2025 7:41 pm
by ahenry3068
Added some interaction between the ball & the box.
Try It Now!
Re: Bouncing ball within a bouncing frame
Posted: Fri Feb 21, 2025 9:50 pm
by desertfish
There's some weird physics going on with the ball though. It changes course sometimes even when it is not actually touching the sides of the box.
New Physics.
Posted: Sat Feb 22, 2025 9:47 am
by ahenry3068
desertfish wrote: ↑Fri Feb 21, 2025 9:50 pm
There's some weird physics going on with the ball though. It changes course sometimes even when it is not actually touching the sides of the box.
Well this is
Not real physics
But
REAL PHYSICS would eventually stop the animation with
friction !!!!
I thinks this looks a bit more
Realistic to the Eye.
Try It Now!