Bouncing ball within a bouncing frame
Posted: 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). Try It Now!
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). Try It Now!