blitting sprites in EndBasic

10 views
Skip to first unread message

Aaron Dixon

unread,
Jun 8, 2023, 10:12:09 PM6/8/23
to endbasic
I came across EndBasic on HN last year, but just now looking into it as my son is just of age (7) to start playing with programming.

I'm starting out by showing him how to design sprites on graph paper and then blit them on screen using EndBasic's graphics APIs.

I've used a couple strategies for representing the sprite pixel coordinates, but neither seems satistfactory.

The first is to list each (x,y) coordinate using DATA. But this is tricky because I have to use RESTORE and then jump (by READing) to the offset that has the sprite that I'm currently rendering. 

What would be ideal would be able to store each sprite in a two-dimensional array. But this is cumbersome without a array literal syntax.

Something like

DIM arr(2,10) = [[1,2],[3,4],...]

Wondering if I'm missing a good way to do this in EndBasic in a clean way. 

Julio Merino

unread,
Jun 8, 2023, 10:20:34 PM6/8/23
to Aaron Dixon, endbasic
Hey Aaron,

Thanks for trying this out!

One way I’ve seen this done is by putting all sprites' data into DATA and then using a few loops at the beginning of the program to construct matrixes out of them via READ. The DATA is thus used as a read-once construct.

I know it's not the greatest answer but... do any BASIC dialects have array literals as inspiration? If not, I'd be reluctant to add them.

I've also been wondering if we need a primitive to blit the sprite matrix onto the screen. Probably yes for performance reasons...

Hope this helps!

From: endb...@googlegroups.com <endb...@googlegroups.com> on behalf of Aaron Dixon <atd...@gmail.com>
Sent: Thursday, June 8, 2023 7:12:09 PM
To: endbasic <endb...@googlegroups.com>
Subject: blitting sprites in EndBasic
 
--
You received this message because you are subscribed to the Google Groups "endbasic" group.
To unsubscribe from this group and stop receiving emails from it, send an email to endbasic+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/endbasic/2c37310d-1ec5-4ecb-b966-d0adb48d7634n%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Aaron Dixon

unread,
Jun 9, 2023, 12:09:57 AM6/9/23
to endbasic
That's great, I love the DATA-to-array strategy so I'll try that. I love the simplicity of the language and adherence to BASIC, so makes sense not to bring in array literals. Thanks for the quick response!
Reply all
Reply to author
Forward
0 new messages