This section is all about using the code you have just learned about and using it to make games. You may not be that interested in games per se but it is a great way to develop your coding skills. What you learn here can be applied to any aspect of coding. It is genuinely fun (at least I think so). So work through the examples, they are simple enough games but coding them is far from simple.

Depending on when you visit this website will depend which ones are available. So the plan is the following:

  • Part 0: game snippets (bits of code that you might find useful later especially if you start here)
  • Part 1: lerp game
  • Part 2: pong
  • Part 3: flappy bird
  • Part 4: space invaders
  • Part 5: asteroids
  • Part 6: maze
  • Part 7: noughts and crosses (with AI)
  • Part 8: matter.js (a game engine)
  • Part 9: angry birds (made with matter.js)

Games Introduction Coding Snippets

This is useful if you already know how to code but in a different language and it is also useful if you just want to learn how to make some games and can’t be bothered working through the first 4 basic parts prior to this. Think this as almost a cheat sheet if you were.

Games Part 1 Lerp

This s a fun introduction to making games. It uses a function called lerp() which measures the distance between two points moves incrementally towards it. So you have you which is being chased by an enemy who will track you wherever you go. You move around the canvas using the arrow keys to reach all the targets before the enemy gates you. Simple but effective and a good introduction to coding a game.

Games Part 2 Pong

This is such a classic and was probably for many the first computer game they played back in the day. This is another great first game to make that was actually a real game. The concept is simple and what you will be making is a two player game, but you could make it you versus the machine using lerp if you were feeling adventurous. I have adapted it and it wasn’t very difficult.

Games Part 3 Flappy Bird

If you have never played this game you have missed out on a craze. It is the simplest game in the world but surprisingly addictive. You simply tap the space bar to keep the bird in the while navigating between pipes that you are flying through. The aim is not to hit the pipes.

Games Part 4 Space Invaders

This is an attempt to replicate the classic space invader game. Possible the most well known of the early video games. This is not the complete, finished and polished game but provides a platform to improve and add features at a later date as you learn more about coding.

Games Part 5 Asteroids

This is a game called Asteroids where you can navigate space in your spaceship and blow up asteroids without being hit. The asteroids float around randomly and you can turn and move and fire lasers. The asteroids then break up and create a greater hazard. Enjoy.

Games Part 6 Maze

You create a maze which is randomly generated, each time it is a new maze. You can make it any size you want (complexity) and then manoeuvre around it using the arrow keys or print off a blank version to print off later. This is a great template to develop into a PacMan type game without having to hard code a maze yourself.

Games Part 7 Noughts and Crosses (with AI)

If you are American then you would call it Tic-Tac-Toe for some reason. This is a simple playable game where the computer will play itself and then you can play the computer but at that stage it isn’t very intelligent. So using a minimax algorithm you can play a smarter version.

Games Part 8 matter.js

This isn’t a game but a game or physics engine from which you can build more games using an engine. This works seamlessly with p5.js and is a precursor to creating the angry birds game which is next. As a physics engine you can also use in the section on physics simulation (CartPole)

Games Part 9 Angry Birds using matter.js

This is a rudimentary game example applying what you learned in part 8 where you make a simple playable game called Angry Birds. It uses the physics/game engine matter.js. This provides one example that could be used for a variety of other games, you could use the engine to recreate all the games in parts 1-7 or better still create your own game and publish it.