galaxy brain

I HAVE NEVER FELT AS SMART AS I DID JUST NOW IMPLEMENTING THIS FEATURE HAHAHAHAHAHAAHA WOW THIS IS GREAT

Trying to celebrate while I feel good about myself because I know something stupid is going to brutally humble me before too long. Now that that’s out of my system, today’s progress was an extremely productive hour of implementing sprite swap control, and a method of determining which treasures have been found. And now, this is basically a playable prototype! Like, the current state is basically a mock up of the game that you can control! Before I sit down with Robert (the game’s designer) and talk about where to go next, I’d like to implement game over/victory states and a couple other UI tweaks (treasures found, revealing treasures at a game over, etc.), but for now, this feels pretty good!

Sprite Control:

In yesterday’s blog, we wrote a script which is attached to every room which determines if a spelunker is on top of it. We use this, plus the randomly generated treasure values, and the current phase to create a set of conditions under which the sprites will change. If there’s a spelunker on an arrow, and it is the excavate phase, and there is a treasure assigned to that tile, it’ll swap to a treasure! Otherwise, it’ll swap to a red arrow.

*Note: A third condition must be added which triggers a game over if the spelunker is on a red arrow when entering into the excavate phase.

I think this script pulls in variables from other places more than any script I’ve written so far.

This was based on a tutorial I saw online (1, 2) and then modified to fit my needs. The way treasure rooms are selected is by generating four random numbers 1-24 (corresponding to each arrow room). We pull those four random numbers into this script and check if any of them are equal to the name of the GameObject (after converting it to a string). It worked on the first try! I also created a boolean which can flip to True after the treasure is found. (we’ll use that in a moment).

Code snippet for sprite swapping control.

The four numbers which appear in the console are the locations of the four randomly spawned treasures.

Marking treasures as found:

As mentioned above, each room has a boolean which can switch to True if a treasure room is uncovered. Because these are randomly assigned each time, we’re not sure which game object to pull from to get that value each time. However, the name of the game object is just the number generated (but as a string) so we can use GameObject.Find and convert the randomly generated treasure spawns ToString() to check the right rooms every time for treasure. Now when those specific rooms indicate their treasure has been found, this script marks the corresponding treasure as found (Either 1,2,3, or 4). The previous one did not discriminate - it just knew that a treasure had been found. It didn’t know which one.

New variables(? not sure what the right word is lol) created for this section.

Code snippet which checks the game objects which have treasure to see if it’s been found.

While at the moment you still have to keep track of your moves, and the game doesn’t yet tell you when you’ve won/lost, I’d say this looks pretty darn good!! I’m excited to keep moving forward and am glad this worked out so well.

I have a feeling the next bit won’t be so easy, lol. Gotta take those W’s where we can get them I suppose.

Thanks for reading!

Previous
Previous

back at it again

Next
Next

Pesky Spelunkers