How to write a lot of games!

Last month I shared with you why I write so many games a year. In this post I’m going to talk about the process and how you can apply it to your game workflow.

You might not need to write 20 games a year as I do, but I think that these tips may save you some time and stress.

Write code that is easy to change

In addition to the games, I write for myself, there has always been an employer or client that I’m making a game for.

Non-coders like the creative process of making a game. Most will ask you to design a game with a certain plan. Then all of a sudden they will get a brilliant idea just before the deadline.

While it is important to set limits with clients and managers, there are time you’ll just have to give in and change the code anyway. This is why it is important to make it easy on yourself.

Here are some ideas on how you can make the code easier to change.

Use Abstract Variables

Instead of using variables like “spaceship”,”bunny” or “troll”, use variables that will still make sense even if the overall theme changes. Use names like “player” or “enemy”.

This will also help if you make a copy of the game and re-skin it.

Keep organized

I know some of you will groan at this. I have when I’ve seen others talk about it, but it has saved a lot of stress over the years.

You need to organize in a way that make sense to you. If you are part of a team you have to agree on a way that everyone can live with.

I get a lot of requests for code help and very often I am sent a single file with a lot of global functions. This is fine to get started but it is a recipe for a disaster if you want to make a living off of your code.

I talk about this more in the reusable code section below.

Make notes

I’ll be honest, I don’t always have time to comment the code in the way that I want. However leaving your future self notes in the code can be very helpful.

For myself outlining the game either before or after can help in the thinking process. Here is an example:

//set up player

..code..

//set up bad guy

..code..

//check for collisions

..code..

//check for game over

..code..

Make code that is reusable!

If done right, this will be your biggest time saver and allow you to focus more on the fun and creative side of your games.

Use Classes

If you are not using Javascript classes in your HTML5 games you absolutely should. I resisted using classes a long time ago, (2007?) just writing functions and variables and copying and pasting the code when I needed to reuse it.

The trouble with that method is that you have to update in every location when you make a change. It is a nightmare for finding bugs.

If you’ve never used classes in JavaScript here is a quick video that will explain it.

Folders

Keep your code classes separated by types and in different folders. This will help you build games quicker because you can just copy and paste that folder to a new game.

Write parts more than games

Only about 10% of my time is used writing code that is unique to one game. 80% is used to make game parts, that can be reused. The other 10% is putting those parts together.

As you might see by that formula that math won’t hold up forever. Because after you have a decent game parts library, for a new game you only have to write the 20% that isn’t parts.

Stop repeating yourself

If I find myself writing the same code over and again and it is more that 2 or 3 lines of code I make it into a class.

It is not a hard and fast rule, but if I don’t do it, I’m doomed to keep typing the same stuff for the rest of the game. Too much repetition is boring and I get bored easy.

Preparation

Keep a list of ideas

I keep a list of games I think that I can write in about 1-3 hours. When I need to write a new game I refer to this list.

Of course, even with these tips and tricks a 3 hour game is not going to be an epic quest. These are usually casual, quick physics or puzzle games.

A lot of games I write never get released because I get bored with them. By reducing the time spent on them I’m more likely to complete and ship them.

Make a library of assets

If you are making games to publish on your own, you’ll need to find or make your own assets.

I’m not an artist by any means, so when I’m making games on my own I have to find artwork and sound effects online.

Often times, I would look for the assets when only when it was time to add them to the game. This was not an efficient use of time, because it brought me out of the code-zone and into browsing the web.

What you can do instead is look for images and sound effects online for games that you think you will make in the near future.

Sometimes I find things that are not suitable for the game I have in mind, but it is still something nice to have and will store it away for future.

Keep folders of general game assets, and then make folders with the name of the future game. (I call these game kits). Copy the files into these game kit folders. That way you have all the images and sound effects ready.

Pitfalls and Dangers

Here are some of the things you should look out for.

Be careful using templates

I write a lot of templates, including my Ultimate Game Parts Template. These can save a lot of work and can be beneficial for learning.

But if you use any template for professional game development, take the time to look through the classes.

When I was starting out, the few times I used other people’s code it came back to haunt me. Clients would request a simple thing like changing some text color. Without knowledge of how to make updates it led to some embarrassing situation.

Don’t get too comfortable

We reach a certain point where we are comfortable with the way we write code and games. This is important for good development.

Every now and then we need to get out of our comfort zone. If we don’t, we won’t grow. Don’t be afraid to learn new things. Don’t be afraid to be wrong.

If I had decided to just stay comfortable I’d still be writing flash games.

These are just some the main points and hard lessons I’ve picked up over the last 20 years of game development. I hope you find them useful, whether you are making 1 or 100 games and I wish you every success!

Leave a Comment

Your email address will not be published. Required fields are marked *