Friday, 11 January 2019

Phony Game

Up until now I've been mostly focusing on the game technology and neglecting the gameplay. I'm going to address that a little bit by adding scoring to the game. I want to add some risk/reward to the gamplay - score higher by taking more risks. From now on I'm going to try to make sure that I remember to add gameplay features as well as tech features.

So how do you score in a shoot-em-up where you can't actually shoot? There are a few possible ways that come to mind:
  1. Score bullets: Fired from spawners like normal bullets, but instead of hurting you when you collide with them they give you score
  2. Bullet grazing: Score points by flying very close to bullets but not close enough to be killed
  3. Score zones: Marked areas of the screen that award you points when you fly over them
I like all three of these scoring methods and I'll probably implement them all over time. If you have any more good scoring ideas that you'd like to see in the game, please let me know in the comments.


To start with, I'm going to implement..

Wednesday, 2 January 2019

Constant Craving

In this post I'm going to do some housekeeping on the game and add four small things that each make the development process a little bit nicer:
  1. A constants file to keep all the configuration magic numbers in one place
  2. A script to serve the game files up to your browser from your machine, so you can build and test the game locally and very quickly
  3. A better way to see the debug console output without having to open up the browser debug console
  4. A favicon to stop the browser complaining that it can't find one

Friday, 28 December 2018

State Of The Nation

In the last post I wrote a simple state machine to delay some initialisation code until the required resources had loaded. It was quite an ugly hack, so this time I'm going to refactor that and make it a lot nicer. I will be adding a state manager system and three different states: Loading, Title Screen and Game.


Thursday, 27 December 2018

Fixing A Hole

In the last post I added fonts to the game. This worked.. but there was a small bug which meant that printed text sometimes didn't appear. Now I need to fix that. Welcome to gamedev!

To fix the defect I first need to be able to reliably reproduce it - how else will I know if I've fixed it? I'll be using the debugger in Google Chrome for my testing, and I've got the game code saved on my webserver. I've noticed that the first time I load this page the font is missing, but if I hit F5 to refresh the page then the font appears. My hypothesis is that this is related to caching of resources, so let's start investigating that. If I open Chrome's debug console (hit F12) and then right click on the reload button there's an option to "Empty Cache and Hard Reload". If I select that then the cache is emptied, the page reloads and.. the font is missing. Bingo! The bug is reproducible, and now I can start looking at what the problem is.


Now I'll go back to the debugger and start poking around..

Tuesday, 25 December 2018

Word Up

Dodging bullets is fun, but we need to start communicating information to the player. One of the most basic ways to do this is with text. In this post I'll add old school mono-spaced pixel font support to the game, and use that to show some simple placeholder info.



It all starts with a font sheet:

Wednesday, 19 December 2018

Hold It Now, Hit It

Last time, I added coarse "box" collision to the game. Box collision is fast, but it's not accurate enough for a shoot-em-up. What I need is pixel perfect collision. This works using "collision maps" for the two objects. A collision map is basically the same as a sprite image (which is sometimes called a pixel map), but instead of storing a colour value for each pixel, I store a true or false value - true if the pixel is set, false if not. When it comes to checking for collision, I walk across the two collision maps and check for any pixel where both maps are set to true. If that happens then the two objects are colliding.


In the following image, you can see the difference between the two types of collision:

Thursday, 13 December 2018

Feel The Pain

This time I'm going to add collision to the game. Perfect collision detection is super important in bullet hell games, so I'll be making sure I get it right. I'll split this into two steps - first I'll add the code to support collisions and put in some coarse "box" collision. That's not going to be good enough, but it works well as a first pass. Once the box collision has decided that two objects are potentially colliding, then we'll switch to pixel perfect collision, which I'll add next time.


First, let's talk about that simple box collision..