I'm a software developer with very limited work capacity due to having the debilitating illness M.E. - please read my article Dying with M.E. as a Software Developer and The Future of my Blog: I'm Still Alive to find out more.

2D Platform Games Part 12: A Framework for Interactive Game Objects

January 4, 2014 5 comments

IMPORTANT! To run the pre-compiled EXEs in this article, you must have Windows 7 Service Pack 1 with Platform Update for Windows 7 installed, or Windows 8.

This article builds upon the demo project created in 2D Platform Games Part 11: Collision Detection Edge Cases for The Uninitiated. Start with 2D Platform Games Part 1: Collision Detection for Dummies if you just stumbled upon this page at random!

Download source code and compiled EXE for the code in this article as well as the complete source code and compiled EXE for the level editor.

We’ve spent a lot of time adding different types of platforms and collision detection behaviour to our project, but of course the real meat of any platform game is in the objects you can interact with like coins, baddies, levers and switches and so on.

Goals and Terminology

Over the next 5 parts of this series, we will build a framework in which we can place interactive game objects like enemies and collectibles, and look at all the complexities of this topic which must be tackled for a complete working implementation, including:

  • Defining a class hierarchy for interactive game objects (which I’ll call game entities from hereon to differentiate them from actual C++ objects and platform geometry and instances) (Part 12 – this article)
  • Handling the movement logic of static game entities (those which do not move in the game world), game entities with pre-defined paths (for example enemies which move backwards and forwards in a fixed pattern) (Part 13) and game entities which can move around the game world of their own accord under the rules of physics we have already defined (which I’ll call free-roaming) (Part 14)
  • Handling animation of game entities with a unified animation function (for example, changing the sprites used for animation depending on the direction the game entity is travelling in) (Part 13)
  • Unifying the collision processing code for entity-platform, entity-entity and player-entity collisions (Part 14, Part 16)
  • Allowing entities to have custom behaviour on collisions with other entities, platforms or the player (for example, making a coin disappear and adding its value to the player’s score when the player collides with it) (Part 16)
  • Unifying the internal representation of the game world to simplify the code and make it more easily extensible (Part 16)

We will also review the collision detection code and go through some really tricky edge cases that only come up when non-player game entities are added to the world, in Part 15.

Finally, I shall also present a new level editor which will allow you to place game entities and modify their properties, in turn giving way to a new level definition format for our level files (the level editor also contains a lot of other minor improvements and bug fixes). Read more…

Advertisements

2013 in review

January 1, 2014 Leave a comment

The WordPress.com stats helper monkeys prepared a 2013 annual report for this blog.

Here’s an excerpt:

The Louvre Museum has 8.5 million visitors per year. This blog was viewed about 110,000 times in 2013. If it were an exhibit at the Louvre Museum, it would take about 5 days for that many people to see it.

Click here to see the complete report.

From Katy: Thanks so much to everyone who supported my blog and donated in 2013! Personal circumstances are difficult these days but I will do my best to write lots more interesting and informative articles in 2014! Love to all of you, Katy.

Categories: Programming

Cutting Your Teeth on FMOD Part 6: Recording and visualizing sound card output

November 24, 2013 11 comments

In this article, we’ll take a look at how to intercept and record the output from a sound card. Our primary focus here will be to create a visualizer that reflects the output sound using the frequency analysis technique discussed in part 4, however you can of course use the recording code for any purpose you wish.

I won’t go into the details of FFT frequency analysis here (see part 4 for that); we’ll just look at how to capture the real-time sound output then provide the visualizer as a usage example. Read more…

Simple2D 1.12 now available

November 9, 2013 1 comment

A new major release of Simple2D is now available (the download link can be found at the bottom of the page).

Version 1.12 has a key focus on:

  • An improved, cleaner initialization interface
  • Basic Direct3D support including the ability to draw with both Direct2D and Direct3D onto the same render target
  • Full editing support for text boxes (navigation, editing, selection, Windows clipboard and infinite undo)
  • Some improvements to XInput gamepad support
  • Numerous bug fixes

Read more…

Living with M.E. as a software developer

October 26, 2013 17 comments

This is not a sob story. I’m just going to tell you about how I feel.

I wouldn’t normally write an article like this on my professional blog, but I’m fed up and want to reach out to people and share my experience for anyone who is interested.

Many of you have noticed that the posts on my blog are very sparodic. Well, a few years ago, I started to get tired easily and found myself needing 12 hours of sleep per day. I thought that I was just someone who needed more sleep than average, although it was frustrating that the days were so short. In the last 2 years, I’ve been extremely tired, and out of professional work, my sleep level rising to 16-20 hours per day, constant pain in my back, neck and shoulders (which is occasionally excruciating; I pop painkillers like candy), a strong sensitivity to changes in temperature making me feel very hot and cold all the time (thermostatic intolerance), regular headaches that I never used to get, periodic bowel irritation, weakness in the arms and legs to the point that some days I can’t walk and others I am so tired that I can’t even lift my phone to call someone for help. Sleeping does not actually make me feel any more refreshed, I am usually just as tired when I wake up as I was when I fell asleep. Mentally, my brain is full of thoughts and ideas, but physically I am quite destroyed almost all of the time. If I walk the ten minute distance to town and take a coffee, a typical result for me would be 1-2 days of sleep afterwards. Finally, in October last year, I received a diagnosis of M.E. Read more…

Tetris: Adding gamepad support

August 30, 2013 6 comments

In this article, we will look at how to add gamepad support to a game using our Tetris clone as an example.

Simple2D 1.11 includes gamepad support using XInput – the new replacement for DirectInput in DirectX 11 – and makes it ridiculously easy to add support to existing games as we shall see here. If you would rather code everything yourself and want the nitty gritty, check out my 2-part mini-series XInput Tutorial: Adding gamepad support to your Windows game for the low-level details.

Download (SimpleTetris 1.5): Source code | Executable

Read more…

%d bloggers like this: