CC-004 - Happy Moon Fish

A place to house devlogs of member’s projects.
Post Reply
User avatar
Sirocco
Site Admin
Posts: 734
Joined: Fri Feb 12, 2021 10:25 pm
Location: Outer Demoscenia
Contact:

CC-004 - Happy Moon Fish

Post by Sirocco »

Image

https://noop.rocks/sirocco/cc/cc-004-compo.zip (Windows binary + source)

😒 🐡 🗿 🌛

This was not my initial roll. It was actually my second. The first seemed promising, but after half an hour staring at the emoji I just couldn't pull an idea out of it, which is basically a failing on my part. However, there was also a time element at play -- I didn't have much time to get this done; maybe 10 hours max, and that was cutting into my weekend chores. Living alone is equal parts pleasure and pain :D

When my second roll came up with a moai, I couldn't resist. That's two of the last four, so I probably need to blacklist that emoji from here out... heh. I pulled out an idea in a matter of seconds, and started working on it. The premise was a group of fish living on the moon that are fed by happy emotions, which fall to the moon from space. The moon god (in the form of a moai) can rotate the moon to line up the fish with their food. You would also need to avoid unhappy emoji, which would kill off fish immediately.

I spent an hour on Friday night getting some public domain images converted to good textures/sprites, and then about 7 more hours on Saturday working things out. A game, of any sort, in ~8 hours is a record for me by a long shot, so this is a pretty good affirmation of Raylib's general utility, and my comfort level with it. I'm still using version 3.50, so there are a few major updates I'm behind on. I'll look into that later this year, as time allows.

I got the moon texture centered on the screen, and made sure it was perfectly round. This allowed me to use polar coordinates to position sprites. Whereas a normal coordinate system would use X,Y and possibly Z coordinates (or whatever combination makes you happy), polar coordinates can typically be reduced to an angle and a distance. If the point of origin is fixed, as we have here, that makes things even simpler. The origin would be the exact center of the moon texture. I got the coord system up and running in a matter of minutes, then had to fiddle with the sprite rotation to get it matching. This is a bit embarrassing as it features some magic numbers, but I was moving fast and didn't have time to get the math just right, so that everything would fall into place with minimal fuckery. Mea culpa, and such things.

The "food" emoji randomly spawn within a range of the moon, and each 'tick' of the game they slowly accelerate toward the moon, which gives the game an extra sense of urgency. You have time to move the moon around, given that you commit to a course of action promptly. The slow rotation speed means you can only go so far as food drops, and if you waffle, you won't get much accomplished. I like it that way. It also means that you have less opportunity to get "angry" food out of the way.

Score is calculated based off the number of fish you have, and a somewhat exponential value given their condition. Well-fed fish will bring your score up in a hurry. Conversely, losing a fish puts a big, and permanent, damper on your scoring capacity, given that the game has a time limit. You start out with 14 fish, and will probably lose 3-4 of them in the first 30 seconds, either due to starvation, or bad luck as the first wave of angry emoji rolls in and you're overwhelmed by the inrush. Missile Command is one of my favorite games from my early youth, and this shares some similarities in design. Specifically, it's easier to protect less targets, so the game gets easier as you go on. However, your score suffers for it. To keep people from just leaving one fish alive and keeping the game going forever, I decided to put in the 3 minute timer.

I got a quick and dirty animation going for the moai by attaching the positive side of a sine wave to the actor's distance value (ignoring the negative side entirely). This results in a short "hop" rather than a wave. Once again, sine saves the day. It never ceases to be useful in unexpected and unconventional ways.

Moving left/right results in the moon's angle turning, and each fish also has its angle turned by an equal amount. Thanks to polar coordinates, no further nonsense is required. The last time I used them was back in the early Fenix Blade days (I used polar coords for the polygons in the game, to get cheap and easy scaling and rotation).
BadMrBox
Posts: 28
Joined: Tue Feb 16, 2021 3:45 pm

Re: CC-004 - Happy Moon Fish

Post by BadMrBox »

This was a fun little game :)
Post Reply