Select Page

Arcade Side Quest: Space Fighter

Last weekend, I realized I was spending a lot of time focusing on the artwork and visual design of the game. It had been a while (months) since I’d coded anything and even longer since I’d coded a game in Godot. So in an effort to knock the dust off, I decided to enter a 72 hour game jam.

Anyone will tell you that’s virtually zero time to do any sort of game, and that’s true. You’d have to scrap all things fancy and focus on just the bare necessities. A simple character design, a simple enemy, maybe some projectiles, and that’s it. Anything beyond that in 72 hours is icing. Oh, and the other thing- this game jam had a limitation that would be announced at the beginning of the jam. It could be anything from “must be beatable in 10 seconds” to “cannot use gravity”.

I was already nervous about the jam itself, because the jam is already difficult, and I’m coming out of a long coding hiateus. So the closer the weekend got, the busier it got. I already had a dentist appointment scheduled, so I knew that would take a chunk out of my time, and then I ended up having a few video shoots land on that weekend as well. By the end of it, I really only spent about 5 or so hours on the game.

Hour 1

The jam began around midnight local time and the limitation revealed was “cannot take place on Earth”. So my mind immediately went to the classic arcade game “Space Invaders”. I went to work creating the player spaceship. I ended up spending 10-15 minutes on this design.

Next up, I went for the easiest one. I needed some sort of bullet for the player to shoot, so I went with a simple white rectangle. That took about 10 seconds. Next, our player needed some bad guys or aliens to shoot. I took about 20 minutes on the alien ship design, and actually ended up liking the enemy ship design more than the player ship… Maybe I should have switched their roles and used the enemy ship as the player ship. Maybe next time.

Next, I wanted to get these sprites into the game enginee and give them some basic movement. To do this, I imported the sprite into Godot and promptly burned 30 minutes looking for how to turn off the image filter. The filter is enabled by default, which makes small sprites come out blurry in the game engine. Definitely needed a refresher on this one! Once I found the hidden check box, I was ready to dive into the code. I just used the default direction keys that are predefined in Godot. I lifted a little script from the Godot docs to acheive basic left, right, up, down, and diagonal movement.

Once I had basic player controls up and running, I needed to get him shooting something. Next, I imported the bullet sprite, and attached a script to it that told it to travel up on the y axis at a fixed speed. Once that was done, I saved the bullet as a scene so it could be instantiated in the game as many times as I needed. The only problem that remained was getting rid of it. If I fired 20 million bullets over the course of my gameplay, the game would run great at first, but eventually, the engine and/or device would hit a limit and wouldn’t be able to process 20 million bullets continually moving through the game on every frame refresh (on screen or not). So to fix this, I gave the bullet a 3 second timer, connected it to the script, and when the timer expired, the bullet would execute queue_free() or remove itself from the game.

Hour 3

Now it was time to set up some basic rules in the game world. I wanted to fire a bullet when I hit spacebar, it flies up the screen, and if it overlaps with the collider that’s attached to an enemy spaceship, then delete both the enemy space ship and the bullet that hit the spaceship. That code was injected into the bullet object, so each bullet is looking for an overlap. So each time it overlaps with something, it checks if the name of that object is “Enemy”. If it is, then it will set itself to be invisible, stop moving upward, make an explosion animation visible, play an explosion sound effect, and play the explosion animation… then after 3 seconds the whole thing gets deleted regardless if it hit an enemy ship or not.

Hour 5

After lots of trials and errors, I finally ended up with a somewhat playable… something. It’s not really a game because there’s not way to keep score and no way to actually win or lose the game. If the enemy ships contact the player, nothing happens. If the player shoots an enemy ship, it blows up, but there’s no score or anything. So it’s pretty much an infinate shooter with no score.

Also, before I forget! When I was creating the script for the word, I didn’t want any enemies or bullets to already exist in the world. I wanted the enemies to just show up randomly (from the top of the screen, flying down toward the player) and bullets to appear when the player hit the space bar. So to do this, I saved the enemy ship as a seperate scene so I could instantiate it whenever I needed it. I attached a timer to the world scene to expire every 1 or 2 seconds ( I forgot how long, but it was defnintely expiring every 3 seconds or slightly more frequently). Every time the timer would expire, the world would instantiate a new enemy ship somehwere at random just above the screen, so they would start flying down into view.

TIME’S UP, PENCILS DOWN

Here’s what I ended up walking away with. And more importantly, along the way, I learned how to export a Godot project as a Linux executable for the first time. Previously, it had only been HTML exports. So yay! Speaking of which, here’s the HTML version:

CONTROLS:

Arrows keys move up, down, left, right, diagonal

Space bar to shoot.

Make sure you click the game before you play it, so it will know to recognize your inputs are for the game, not for typing 😀

Check out more articles

How to Generate a Ranger Config File

ranger --copy-config=all This will copy all the default config files from /usr/local/lib so you can make edits without messing anything up. Huge shout out to https://dquinton.github.io/debian-install/config/ranger.html for explaining this and so much more. Took me a...

First Open Source Contribution

Surprise! I genuinely did not plan on making my first ever open source contribution today. In fact, I didn't plan on a lot of things happening this week at all. I recently got an awesome opportunity to work on a site that is being hosted on a platform called Pantheon,...

How to Exclude Specific Posts and Pages from WP_QUERY

For the sake of having something to work with, let's suppose we've got the following query:In this query, inside the $args array, there's a special parameter that allows you to exclude specific posts and pages from the query. This parameter is called post__not_in and...

Configure SSH For Password-less Connections

Preamble I'm slightly embarrassed to admit this, but it was a long time before I figured out how amazing this little file is and how exactly to put it to good use. The file I'm talking about is the SSH config file. By default, when you first connect to a server via...

WordPress Site Stuck in Maintenance Mode

Plugin Error Code 500 During Update While I was updating a WordPress plugin locally, something happened on my local server to trigger a 500 error code as the plugin was updating. On the frontend, I refreshed the page and was greeted with "Briefly Unavailable for...

Creating a WordPress Plugin Downloader

How it Started I was recently tasked with the challenge of creating a WordPress theme generator. The idea being, instead of writing your style.css file from scratch, you'd be able to just answer a few simple questions about how you'd like your theme set up, and those...

Fix Audio on XFCE Chromebook

The Problem After moving from GalliumOS to Xubuntu, I noticed that playing YouTube videos on both Firefox and Chromium would result in decent playback for a few minutes, but suddenly the audio would turn into a solid beeping tone while the YouTube video displayed the...

Adjust Trackpad Sensitivity XFCE

xinput set-prop "Elan Touchpad" "Synaptics Finger" 1 1 1 What are the values 1 1 1? This sets the sensitivity as close to the original ChromeOS as possible. Larger numbers will decrease sensitivity of various aspects. I never looked into which individual value...

Fireworks (Short Film)

https://vimeo.com/395077249 About the film Year: 2020 Director/DP: Tim Searfoss Writers: Matt Jones, Tim Searfoss Sound Mix: Matt Jones

Hosting Multiple Sites Using LocalWP

I've done a write-up on hosting local WordPress sites before, but I definitely prefer this method over the previous one. If you've never tried hosting multiple sites using LocalWP, then I'd encourage you to check it out. I've had really bad issues with it in the past,...

Looking for a place to host your next project or design?

Use this link to get your first 4 months of WP Engine for free: WP Engine – Plans (With 4 months free)