Bouncing ball within a bouncing frame

Post Reply
MarkTheStrange
Posts: 23
Joined: Sat Nov 26, 2022 6:24 pm

Bouncing ball within a bouncing frame

Post 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
Screenshot 2025-02-19 at 17.14.51.png (69.17 KiB) Viewed 746 times
Try It Now!
Attachments
METABOUNCE.PRG
(254 Bytes) Downloaded 38 times
User avatar
ahenry3068
Posts: 1200
Joined: Tue Apr 04, 2023 9:57 pm

Re: Bouncing ball within a bouncing frame

Post 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 :D . I DID NOT even look at Mark's code.

Try It Now!
Attachments
BOUNCE.PRG
(4.76 KiB) Downloaded 19 times
BOUNCE.BAS
(5.61 KiB) Downloaded 5 times
MarkTheStrange
Posts: 23
Joined: Sat Nov 26, 2022 6:24 pm

Re: Bouncing ball within a bouncing frame

Post by MarkTheStrange »

ahenry3068 wrote: Fri Feb 21, 2025 2:53 pm Had to do my Own version :D .
Try It Now!
Well, that's much fancier. Change the frame to a gilded picture frame and it will fit right in. :)
User avatar
ahenry3068
Posts: 1200
Joined: Tue Apr 04, 2023 9:57 pm

Re: Bouncing ball within a bouncing frame

Post by ahenry3068 »

MarkTheStrange wrote: Fri Feb 21, 2025 3:39 pm
ahenry3068 wrote: Fri Feb 21, 2025 2:53 pm Had to do my Own version :D .
Try It Now!
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.
kelli217
Posts: 544
Joined: Sun Jul 05, 2020 11:27 pm

Re: Bouncing ball within a bouncing frame

Post by kelli217 »

Looks like Robin saw the challenge too. [yt]https://www.youtube.com/watch?v=zwTA7xi0QD0[/yt]
User avatar
ahenry3068
Posts: 1200
Joined: Tue Apr 04, 2023 9:57 pm

Bouncing ball With some Physics

Post by ahenry3068 »

Added some interaction between the ball & the box.

Try It Now!
Attachments
BOUNCE.PRG
(4.8 KiB) Downloaded 14 times
BOUNCE.BAS
(5.72 KiB) Downloaded 3 times
User avatar
desertfish
Posts: 1125
Joined: Tue Aug 25, 2020 8:27 pm
Location: Netherlands

Re: Bouncing ball within a bouncing frame

Post 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.
Post Reply