Weeks 118-119: SUGAR and Breakout (Patreon)
Content
These two weeks I worked on SUGAR's text-pattern feature and on a C++ programming pattern with which I started making a Breakout clone!
In Pico-8 and, in fact, many other game engines, it's not uncommon to display the same text several times, with very small offsets and different colors, to create outline and/or shadow effects. Taking Pico-8 as example, you can go from this:
print("hello world!", x, y, 7)
</code>
To this:
print("hello world!", x-1, y+1, 13)
print("hello world!", x+1, y+1, 13)
print("hello world!", x, y+2, 13)
print("hello world!", x-1, y, 7)
print("hello world!", x+1, y, 7)
print("hello world!", x, y-1, 7)
print("hello world!", x, y+1, 7)
print("hello world!", x, y, 0)
</code>
Besides looking way cooler, this can help a lot with distinting the text from whatever is in the background. It's a great technique, but you are effectively rendering a lot more text than you would without it. While this will rarely slog down a program, because text rendering is generally pretty fast, if you have a lot of text, it may just do that. And either way, on the code side, this isn't a very 'clean' way to do things, however simple.
So for SUGAR I had the idea for a feature which would register such a pattern and would reproduce it, in a more clever way than rendering the same text a thousand times.
These two weeks I figured out what that clever way would be and then proceeded to implement it. (along the way I reworked how the data for the glyphs was stored and that gave out this wonderful glitched text you can see in the gif above)
Here's how to use this feature in-engine!
<code>printp(0x0200,
0x2120,
0x4240,
0x0400);
printp_colors(0, 7, 13);
pprint("hello world!", x, y);
</code>
These lines, used with the Pico-8 palette and font, will give the exact same result as the second "hello world!" picture above.
As you can see, printp() takes 4 arguments, which are the 4 lines of the pattern being registered. The pattern has to be 4x4 with only 3 different colors (1, 2, 4 - not counting 0 for transparency). That seemed a good middle ground between this feature getting too expensive and it being too limited. Still in printp(), the keys for the colors are 1, 2 and 4. That is because those arguments are processed as bitmasks. If you used 7 (1+2+4) as a key, all three colors would be registered for that cell. (but only 1 would ever be drawn) When drawing, 1 has priority over 2, and 2 has priority over 4.
The engine always holds 2 colors, for drawing with fillp, but here 3 were needed. So those are held separately and can be set with printp_colors() or as 4th, 5th and 6th arguments of pprint().
pprint() makes the magic happen and draws your text, applying the pattern by way of bit magic.
As it stands currently, this feature is slightly flawed in two ways. The first is that it can be optimized a little further, which I will get onto sooner or later. The second is that each glyph/letter is drawn separately, and so with some patterns, glyphs may appear to be drawn 'above' their left neighbors. I will try to find a solution to this soon.
That said, it is working as intended and that's really what matter, right? (I'm quite happy with it)
Here's another idea I got on Sunday evening: a C++ programming pattern, using my existing object system, C++ maps and C unions, to allow a workflow where the whole of a game's logic could be contained in one file, much like with Pico-8, without this file becoming an utter mess. (relatively speaking)
And it turns out that the only element I was missing was C-style #defines to make a few little shortcuts! With that, the pattern was complete and I began to test it, by making a Breakout clone!
Now, one does not simply make a Breakout clone in 24 or 48 hours. Especially when you can't bring yourself to overlook any detail whatsoever. So while my C++ programming pattern worked even better than I expected, I still took my sweet time to make the game extra shiny. So much so that it's still not done. But it's close! I'd say it's about 80% done!
The problem, as I realized after writing on Patreon that I would try to finish the game during the week-end (I didn't - I implemented my text-pattern thing instead though), the problem is that SUGAR is not quite ready for a game release just yet. For one thing I noticed that scaling the game to bigger resolutions was much more expensive than I expected, which means I'm probably going to integrate OpenGL just for that. (it was planned anyway, for post-processing shaders) I also would like controller support to be available, but... we'll see about that.
So fingers crossed, the game will be out by the end of the coming week. However, an early version of the game will be available much sooner to my 5$+ Patreon supporters, with those little SUGAR misgivings.
On a similar note, I'm also planning to update the work-in-progress and abandoned projects troves which are available to 8$+ Patreon supporters! There will be Bombs On Venus (Pico-8 - work-in-progress), LOKPIK (Pico-8 - abandoned - with source code), the game from two weeks ago with the cute face (SUGAR, work-in-progress), and other projects from the last few months!
Finally, next week-end is Ludum Dare! I plan to participate in the compo category (unless I run out of time) and with Pico-8! I might not get all the time I want to work on whatever I'll make but hopefully I'll make something interesting!
As usual I want to thank my Patreon supporters for their continuous support! I wouldn't have near this much to write about if not for them! Here are the names of the 3$ supporters!
Alan Oliver, amy, Andreas Bretteville, Andrew Reist, Andrew Reitano, Anne Le Clech, Austin East, berkfrei, Bitzawolf, Brent Werness, Chris McCluskey, Christian Östman, Cole Smith, Collin Caldwell, Dan Lewis, Dan Rees-Jones, Dave Hoffman, Finn Ellis, Flo Devaux, Giles Graham, HERVAN, hushcoil, Jacel the Thing, Jakub Wasilewski, Jearl, Jefff, Jeremy Bouin, Jesse Bergerstock, Joel Jorgensen, Joseph White, Marcin Majewski, Marty Kovach, Max Cahill, Meru, Paul Nguyen, Pierre B., Qristy Overton, Reza Esmaili, rotatetranslate, Ryan Malm, Sasha Bilton, Sean S. LeBlanc, Thomas Wright, Tim and Alexandra Swast, vaporstack, Zachary Cook
These two weeks turned out pretty good in the end even though the first one was difficult!
This coming week I'll be mostly working on the Breakout clone and on SUGAR itself!
Have a great week!
Take care!
TRASEVOL_DOG