DEV Community ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป

DEV Community ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป is a community of 963,864 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
Cover image for Hacktoberfest 2021, PR #1
Tรณth Bรฉla
Tรณth Bรฉla

Posted on

Hacktoberfest 2021, PR #1

This article was taken from my Ko-Fi page, where you check more of my stuff, and support me if you wish to!
ko-fi

Now, onto the article!

Clock Mage was a game jam entry of mine for the first My little Roguelike jam back in 2020. I really liked the jam the people were amazing, the submissions awesome, and overall i really got into the mood of programming, even had a few livestreams, and a lot of progress tweets, so i was pretty happy with it.

Alt Text

So happy, that it i wanted to remake the whole thing in the Godot Game Engine, to expand on it, as i hit a major roadblock in the PICO-8 project, namely tokens. The "engine" has several hard limits on your code (to invoke oldschool programming challanges and feels) and one of them is the infamous 8192 tokens. I struck it several times during the development, cut it back a few times, but decided that a small scope may just be better for the project, and left it after a few little updates, and turned to the Godot remake.

That is going pretty well, but i alway had a longing to finish and polish up the PICO-8 version, which i started working on, but soon hit the roadmark of the tokens again. Well, nothing left, to dust down my "skill" and learn a bit more about what and how to optimise, so in the end this Pull Request was born, freeing up almost a hundred tokens with one easy trick.

Local variables. In PICO-8, typing player.health counts as two tokens, so if you really depend on these kind of data during a function it's much better to just declare a local health = player.health, which cost 4 (health, =, player, health), so if i can replace 8 of these calls, it'll only use 12 tokens instead of 16, which might seem low, but it will accumulate quickly. This really helps if your UI's position depends on the players position.

There are a few quick fixes included in the PR, which i did not comment on sadly.

One of them is the director.maxCredit = flr(director.maxCredit/2) line, which honestly is a really big deal. My game depends on the so called Director, which spawns chest, enemies, sets costs, rewards etc... On each stage there is a teleport which you need to activate to progress, if you can survive a minute. During this time the Directors spawn credit is doubled to enable way more enemies to spawn, and i somehow forgot to reset it...

Alt Text

The other is pretty closely related, and just as "dumb". I'm calculating a very simple difficulty in the game (time spent and level count), and for a long time i did not notice that i do not apply any of this. "How can you not notice that?" you may ask, and my answer is the issue just describe above. As i did not reset the teleporter event credit spike, the game got harder on it's own, and with a much higher spike than i originally wanted. One issue masked the other, so now things should be okay on this front.

Future plans are to reduce tokens even more, my enemy AI part is full of these kind of these, and maybe optimise, and some day we may have some space to add a boss to the game as well.

If you also want to join the Hacktoberfest 2021 just click the link, and the page will introduce you to everything you need to know!

https://hacktoberfest.digitalocean.com/

Thanks for reading and have a nice day!

Other social sites:
๐Ÿฆ Twitter
๐Ÿ“ท Instagram
๐ŸŽฅ Twitch
๐ŸŽฌ YouTube

Games and devlogs i made:
โŒจ๏ธ GitHub repos
๐ŸŽฎ Itch.io
๐Ÿ•น๏ธ Newgrounds

All my links in one place:
Linktr.ee

Top comments (0)

Update Your DEV Experience Level:

Settings

Go to your customization settings to nudge your home feed to show content more relevant to your developer experience level. ๐Ÿ›