Scenery, Effects & Excruciating Bugs (To Spring: Dev Blog #4)

Old Franjo posting 2 days in a row?! Is the sky about to fall in on our heads?? Are the compasses all about to give up on magnetic directions and point down instead? Nope. Just call me hot, crispy bacon drenched in brown sauce and no butter, because I’m on a roll. Eaten by someone else of course, cause I’m a pesky pescatarian these days. I miss bacon. I’ve already veered wildly off topic.

I just can’t stop tweaking this bloody game this weekend. Yesterday I did a lot of character sprite work and today I’ve done quite a lot of scenery sprite work and functionality. I added some parallax backgrounds in the forms of different sized rocks and mounds of snow, implemented cloud and plant spawners so that the clouds and plants could be randomly scattered across the map and 3 extremely time-consuming little touches, that I’m going to get good and steamed up about if that’s alright.

The Mother Fucking Sun/Moon cycle

“How hard can it be to put in a sun and moon that rise and set with the already established day/night cycle?” I thought stupidly. Cut to 3 hours later and I’ve rigged up a circular path for them to follow and I’m smashing my head against my desk trying to work out a way of finding the length of an arc of a circle when all you know is it’s radius. For the record, it’s fucking impossible, but that didn’t stop me from trying until my brain begged me to stop. The reason I needed to find the length of an arc is that I needed to time the sun and moon’s rising and falling with the day/night cycle and for that I needed to know how far they were travelling over the course of the day or night. If they’d been on a straight line, this would be a piece of piss, but as they weren’t, it almost ruined me. The worst part is that this was the 2nd most difficult problem that I’ve had today.

In the end, I decided to scrap the fancy-shmancy arc for a more basic system, where the sun rises to the top of the screen at sunrise, travels in a straight line across the top of the screen and then lowers back down at sunset. Vice versa for the moon. This still took the horrendous maths below that took me a little while longer. I’ve managed to fudge it so that the X coordinate of the sun and Moon will start at the right hand side of my camera (I did this in the camera object so that they’d stay on screen instead of disappearing when I walked away) and then shift across to the left by the percentage of the day that’s passed. I hated this. I’m alright at maths but percentages are my kryptonite.

The lovely Straightforward Particle Effects

To be honest, this part was still time consuming and was lovely and straightforward only because I nicked most of it. There’s a Gamemaker Studio 2 youtuber that I will never stop banging on about to anyone wanting to get into game design named Shaun Spalding and during a platformer tutorial I followed along with once, he brought out a versatile particle effect that he had actually nicked himself from someone else. It’s amazing once you start coding how much of your time goes into finding stuff to nick, really.

It’s a sprite containing progressively smaller sub-images that you can summon en-masse whenever you want a cloud of dust, or in my case, snow particles. I’ve tailored this in a couple of different ways; Firstly so that the fox now kicks out bits of snow behind her as she walks or runs and secondly so that snow flies up once she dives into it. It’s ridiculous how much nicer little touches like this can make your game look and I’m really happy with it.

The Footprints That Brought Me To My Fucking Knees

I hated this. I hated hated hated this. Ever since I started this game I thought that leaving footprints in the snow that disappear after a couple of seconds would be a beautiful little touch but one that’d be really overly complicated. As it turns out, it was actually really straightforward. Seriously, it was. Let me explain why it ruined my weekend. I apologise, but I’m about to get technical. I’ll try not to get too far into the weeds, but honestly this is just going to be a rant for my own benefit. Please feel free to skip to the next section.

The theory of putting these footprints in was simple: Go through my walking/running sprites and any time the fox lifts a foot off the ground, create a separate sprite with a footprint where her foot had just been. For me, in both my walking and running animations, the fox lifts her foot on frames 1, 2, 6 and 7. So I made a sprite containing 4 sub-images of the footprints for each foot and when my fox’s animation gets to frame 1, 2, 6 or 7, it’d add in a new object that puts in the corresponding footprint frame. Does that make sense? I’m horrible at explaining things like this I think, it’s why I try not to get too technical on things like this. But anyway, the object was set up so that it’s transparency would reduce over a couple of seconds, making the footprint disappear and it all worked perfectly… For about 5 seconds.

I could not for the life of me work out why but my fox would leave pristine footprints for about 5 seconds and then it wouldn’t work for another 10, at which point it would magically work once again. I had a cooldown set up so that the fox wasn’t churning out 60 footprints per second and I disabled that, but it still didn’t work. I had the command nested inside quite a lot of conditional statements (Amateur, I know), so I tried removing it from those and having it as it’s own separate block of code, but it still didn’t work. I checked all of my sprites, all of my logic, I rewrote a lot of code that I thought could be blocking it and the fucking thing kept stopping creating footprints after 5 seconds for no bloody reason!

I eventually found the problem. It was about 3 hours in and I was a broken man. In desperation, I added the values for my sprite_index, image_index and image_speed to my debug window in the game, genuinely thinking “If I don’t fix this in the next 10 minutes, the footprints are coming out.” I was done. I noticed from here that my image_index (This is the value that corresponds to the sub-image of your sprite. The first sub-image is image_index 0, the second is image_index 1, etc) had 2 decimal places. It wasn’t supposed to have 2 decimal places. Amateur that I am, I didn’t even know the sodding thing could have decimal places! I was using a switch statement to check if my image_index was precisely 1, 2, 6 or 7 so as the image_index went out of sync and into the decimals, it stopped passing the check. Then presumably it would sync back up and start making footprints for a bit again, then start failing again. I changed the switch statement to an if statement that checked if the image_index was between 1 and 2, 2 and 3 etc and my gruelling day was finally over.

There. All better.

Phew, sorry about that. That was the first really paralysingly frustrating bug that I’ve had during the creation of this game and I needed to vent. I’ve had plenty of them before, on Flight of the Bluebird especially. Usually with bugs you have some idea what the root cause is but when you have absolutely no clue it’s a draining, helpless feeling. But yeah, my fox now has fucking footprints and you’d better appreciate them. I think they look nice.

Final Thoughts For The Weekend

I’ve got conflicting feelings at the moment. I’m really really proud of what I’ve made so far. I think it looks nice, plays nice and is just a really pleasant experience. Not Animal Crossing levels of pleasant, but pleasant nonetheless. However, it strikes me as an “Experience” (Gag) more than a game at this point. All you can really do is run around jumping at targets to make the score go up. I need to liven up the gameplay and I think that should be the next thing I tackle. I originally thought of Polar Bears as a roaming threat that you’d need to run from, but I’m not sure that’s the way to go. Any ideas, send them my way. Thoughts and advice are always appreciated. I’ll leave you with an updated demo video. See if you can spot the new bug I’ve found. I’m done for the day though, I’ll get it another time.

Oh yeah, and don’t forget to scrub your sticky palms with soap and water, you dingus.

Cheers,

Dave

Advertisement

Fox Game (To Spring: Dev Blog #1)

Hello again! It’s been a while since I’ve done anything on this site as the amount of free time I’ve had has been really quite restricted lately. Nevertheless, I’ve had an idea and I want to document my progress in bringing it to life. I’ve already outlined the tools I use for game design in my previous post here, so I’m just going to launch straight into this with no faffing about. Here’s my idea:

Concept

You are an arctic fox. Most of you will have seen the clips on nature documentaries or Youtube or your social media of choice. I was watching some such clips the other day and I realised that the thing that really intrigues me about arctic foxes are the way that they find food: They stand there on top of who knows how many feet of snow and listen. They listen and listen and listen… And BAM! They leap up, dive down headfirst and submerge half of their body in the snow, reaching down to the source of the telltale sounds of scurryings and scratchings of delicious lemmings.

I’m imagining a 2D side-scrolling game where you are a fox wandering the arctic in search of food. The primary loop of the game, or your goal from second to second, is to listen for, locate and dive for food while evading predators. You’ll accomplish this with the help of your extraordinary sense of hearing – In gameplay terms, the slower you’re moving, the more obscured the visuals of the game will become but the more you’ll be able to block out the background noise of the tundra and hone in on the sounds of your prey, which will be highlighted visually under the snow, perhaps with the help of a highlighted circle that lets you know generally where the sound is coming from. This circle will be quite large at first, meaning you may come up empty…mouthed, but it will decrease in size as you catch more and more food and hone your skills. You’ll need to search carefully however, as polar bears may wander along to ruin your day, in which case you’ll receive a visual and audible alert telling you that you’ll need to run.

The secondary loop, or your goal from minute to minute, is to find enough food to keep yourself and your pups alive. The game will end once you’ve found enough food to keep everyone well fed, whereupon you’ll find yourself back at your den feeding the pups. The feel-good story of the year.

It won’t be a long game, or a complicated game, but as I’ve said before, my goal is still to keep things simple. I’ve made a single game so far, an arcadey sort of chaotic football simulator named Player Power which took me 2 weeks to make and so far 6 sodding months to publish to Steam. But “Fox Game” (Hit me up with a better title because I just can’t think of one at the minute) will be a significant step up on that game already in terms of difficulty to program, once you factor in all of the moving pieces.

The Plan

So far I’ve done a hell of a lot of thinking. Thinking over the structure, the features I’d want etc and I feel like the above paragraphs completely sum the game up, which is a testament to just how much I’ve restricted myself. It’ll just be the fox protagonist, a bear that can appear, some food that will appear, some kids to give it to and a shit load of snow.

Programming-wise, I don’t think there’s anything there that I haven’t already done at some point. I’ve done platforming tutorials that involved the intricacies of moving sideways and jumping and got about half way through “Flight of the Bluebird” which involved several much more complicated enemy spawners that had to create enemies on the beat of whatever song happened to be playing. Ridiculous idea for a rookie to take on in hindsight. Spawning food at random locations under the snow shouldn’t be too much trouble either, although the dive mechanic will take a bit of working out I’m sure. What I’m trying to get around to is the fact that the programming should be fine given some free time and some elbow grease. The real challenge is going to be in the art. Ridiculous hypocrite that I am, I’m planning on ignoring my own advice to keep things simple and instead trying to make this game look as pretty as possible. It just seems like the right thing to do, focusing on designing an excellent protagonist who’s animated well, to liven up the bleak, plain landscape that is the frozen tundra. If I try and get away with a shit 16 x 16 pixel sprite that vaguely resembles a dog, this isn’t going to be a nice game to look at at all.

So yes, that’s the plan. I’ll create the project in GMS2 first and work out what kind of resolution I want to work with, then I’ll start trying to get my art skills up to scratch. I’ve sort of started already actually, as you can see below. That is a 256 x 256 sprite I’ve made that could someday become the titular fox. I’m not sure if I want to commit myself to drawings that detailed and might scale back down to 128 x 128 but I’ll work all that out later.

As always, thoughts and advice are welcome, because I am shit at this (But getting better 🙂 )

Cheers,

Franjo