To Spring (To Spring: Dev Blog #2)

Ello ello ello. How are you all enjoying the apocalypse? Bit of a pisser, isn’t it? Obviously Covid-19 is having a massive effect all over the world but I’m sure you’re as exhausted as I am of hearing about the shitty things it’s doing to people’s lives, so let’s not dwell on it.. Basically what I’m trying to say is that I, like most people at the moment, have free time to burn. Some of this free time I’ve been putting towards Fox Game, or as I’ll be calling it from now on, To Spring.

I’m so fucking pleased with myself for this title. Cocky almost. Get this, right: Winter is the time when food is the most scarce for the arctic fox, which is our game’s protagonist. And as this is a food collection, 2D scroller sort of deal, it only makes sense that our game takes place over the winter, where the challenge is in finding and sniffing out food from beneath the snow. Our end goal therefore is to make it all the way through To Spring. With me? But how do we get this food? We leap into the air and dive beneath the snow to find it. Our primary gameplay loop revolves around our ability… TO SPRING!!! Right??? … Well I was impressed with myself.

The Game So Far

Since my concept post I’ve worked on a lot of basics and I’ve had a lot of fun to be honest! I’ve got a blank, minimalist looking fox protagonist who can walk and… run… ish… Fox walk and run animations are hard, OK? It’s a work in progress. As is the design of the thing. The minimalist look sort of works but I want to try and give the protagonist a bit of identity if I can, so that’s on the to-do list. I’ve implemented a blank (For now) map, a camera that tracks the player, some snow that falls and flies past you faster the quicker you’re moving and I even put in a day/night cycle that changes the lighting the longer you play. It’s a cool little touch and looks nice if I say so myself, as is the debug mode I snuck in which allows me to see different values I need for testing purposes. Also I implemented an incredibly basic tutorial system which is just text that comes up on the screen to prompt you to move, jump and dive to find food etc.

Speaking of which, let’s dive into the subject that I’ve spent the most time on, has given me the most headaches and that I am still probably the unhappiest about: Diving for food.

AAAAAAAAAARRRRRRRRRRRRRRRGGGGGGGHHH

The title about sums it up. Diving for food is the bread and butter of my game but I just can’t get it the way I like it. This mechanic has been through several iterations.

Take 1: Basic Diving

I started out by making the player able to just jump like they would in a platforming game, using the Spacebar if you’re playing with a keyboard using WASD controls, which for now is the only way to play it, although I do plan to add gamepad compatibility. Then at the height of your jump, you could press and hold S to indicate that you want to dive down to try and get food, as oppose to just landing on the ground. Once you landed, the game would look for the food, compare where you are on the map to where the food is and if you were close enough, you’d get the food. Food could spawn anywhere under the snow and it’s depth was irrelevant. It was very uncomplicated and very unsatisfying. Annoyed, I tried again.

Take 2: Charged Diving

Ok, so how about this; instead of Spacebar just making you jump the predetermined distance upwards, you could press and hold Spacebar to charge up a jump (Ticking up to a maximum of 15 jumping power, keep this in mind) and then charge your dive on the way back down by holding S (Again, to a max power of 15). This way, if food was deeper under the snow, you had to jump higher and dive down deeper as your depth was now also taken into consideration when calculating whether you’d hit the food or not. Made sense! The problem was, it felt incredibly imprecise to control and quite clunky to boot. I needed this level of complexity, but in a more simple, streamlined and precise way. So I tried again.

Take 3: Sexy Grid-Based Diving

“Alright, then how about this??” I asked my empty room, my unkempt beard and bloodshot eyes giving away my dwindling conviction in my own decisions, “A GRID-BASED SYSTEM!”

I split up the area under the ground vertically into 3 layers of depth: A surface layer, medium layer and deep layer. I also split up the entire map horizontally into 32 pixel chunks, thus creating a grid. The food would now spawn into one of these grid cells as oppose to anywhere it liked, giving me greater control. For example, I could now make sure that the first food the player had to find didn’t spawn in a 30 minute drive away, which was very handy. I suppose I could’ve done that anyway but the grid made it much simpler.

The idea was that now, when you charged your jump and then your dive (Which remember both had a max charge of 15), any dive with a lower charge value than 5 didn’t make you dive at all and just had you land normally. Between 5 and 10 meant you dived into the surface layer, between 10 and 15 meant you dived into the medium layer and a maximum strength 15 dive power meant you dived into the deep layer, hence solving the problem with precision that my freeform approach had formerly had. Once you dive to the ground, your horizontal location is rounded up or down to the nearest grid marker, depending on which you’re closest to. As a result of all this, when you dive, as long as you charged up a fair amount, you would hit a corresponding grid cell and get any food that it contained. Although this solved a lot of my problems, it also added a lot. This wasn’t simple or streamlined at all. This had gone the complete opposite way and become convoluted.

Take 4: Sexy, Charged, Grid-Based Fuck It, Use The Cursor

So what did I do with this behemoth of code that I’d built up over days, maybe weeks of tinkering? I binned it. Well, most of it. This is something that I’d highly recommend doing if you find yourself in a similar spot. Obviously save it first in case you ever need to refer back to it, but then bin it. Start completely fresh if you need to.

I kept a couple of things: Firstly, I wanted food to still spawn in a grid as it just made sense. Secondly, I kept the jump-charging meter, only this time there would be no dive button. You’d charge up your jump the same as before and once you released Spacebar, you’d fly off in the opposite direction of your mouse cursor. This way, you were sort of catapulting your fox by moving the cursor in different directions, which feels pretty cool. Then your dive depth is calculated off of your jump power as oppose to your dive power. And uh… This is how the jump/dive mechanic still works at the minute. I think it’s alright. It’s definitely sleeker and more intuitive, but it needs refining. It’s currently fairly buggy and VERY imprecise but it’s the best it’s been so far!

That’s about it. I should probably quickly mention sound before I go though. The blue circles you see in the above video are the food’s sound radii. Once you step into one, you’ll hear the chirping of rascally little lemmings get louder and louder as you approach the food, and then quieter as you walk past it. I’ve also layered a LOT of wind sound effects from Freesound, which is always an incredibly helpful tool for projects like this, on top of each other until I got the effect I wanted. The wind gets louder the faster you’re moving while the game’s opening music gets quieter as it gets drowned out by the wind. Speaking of the music, it’s a song called Heartbreaking from Incompetech, which is an equally if not even more useful website where you can find thousands of pieces of Royalty Free Music in a massive variety of genres, all written by the incomprehensibly generous Kevin MacLeod. All are usable in any project as long as you give him a credit and I’d highly recommend having a look, although you’re a braver man than I if you listen to any of the 38 tracks labelled “Erotic”.

Next up I’ll probably be looking to finish the running animation, creating a dive animation, refining the jumping mechanic some more and other bits and bobs I come across. I’ll be back when I have more progress to report and when I get around to continuing F:AJS.

Cheers,

Dave

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s