Oh, Hello!

So I’ve been away for a little while. I know, and I feel a little guilty, but hey, that’s what holidays are for. I’m now officially getting back to some degree of work, and to that end have created myself a goal with the pretty cool Beeminder to work for at least 20 hours per week on Piemaster-related stuff. Currently no pledge, but it’ll start going up if I start failing. Wish me luck!

So what am I up to now?

The main coding focus at the moment is Buffex, which I still haven’t written much about, despite promising to do so multiple times. Maybe I should write about it first to hash out the scope of the MVP. In any case, it’s coming along rather well, and I’m currently working on wrangling all the data.

In non-programming news, I’ve been spending a lot of time over the past couple of months cleaning up the garden (it’s been a jungle for years) into a presentable state, and performing some dedicated research into the wonders of aquaponics (see this Practical Aquaponics video for 12 minutes of introduction). I want to write lots about it because I’m kind of obsessed at present, but I’m afraid no one much cares. Once constructions starts in earnest (have to order a few more parts) I’ll get onto it.

I’m also heading back to uni this year and applying for a couple of jobs. One is pretty standard tutoring of relatively simple computing subjects, and the other is a pretty exciting engineering faculty project called MUtopia, for which I may be responsible for developing some kind of stakeholder feedback management system, rather than the actual simulation stuff. Still a cool project to be involved with (if approved), and the role sounds like a great experience (from what little I currently know).

Finally, I’ve had a request pop up to write a few sheets of drum tablature, for which I’ve resurrected the old Taboo! Talk about a blast from the past. Ran into a whole bunch of exceptions since I wasn’t a fantastic programmer back then, but it got me thinking again about my old plans to take Taboo to the web as a JavaScript application. Now that I’m actually using some JS in anger, I may give it a go when/if things cool down for a while.

So that’s me. I’ve been very busy with all kinds of things, but am now getting back to being busy with the right things (from this site’s perspective, anyway).

Speech Freer: Working Under PHP safe_mode

So I’ve mentioned I’d really like to migrate from WordPress to Drupal, for a number of reasons. One of those reasons was that my WordPress has, over time, become gunked up with errors about write access that I kind of understand but have been unable to resolve. Particularly, the awesome automatic updating of WordPress and its plugins had ceased to work, and every update had to be applied manually, which was never going to happen. I was hoping starting from scratch with Drupal would let me keep everything running smoothly.

However in trying to fix a similar issue with my new Drupal install, I can across a post detailing a solution for How to Get WordPress Working Under PHP safe_mode on NearlyFreeSpeech.net, and believe it or not it works. Thank you, Sarah Pin! It’s a long process written out, but really just SSH and 4 shell commands to change the group of everything to web rather than my account. This allows WordPress scripts to write to the server, and hence allows automatic updates. The name of the site, “I Am Completely Serious“, inspired some confidence that I might just be able to fix this mess, and I’m so happy with the results that I’m definitely reconsidering the value of switching to Drupal.

Now the main drawcard of Drupal is the integrated forum module which, while not as full-featured as say phpBB, is plenty good enough for me to offer simple support, and integrates natively with the Drupal user database. In addition, I like the way Drupal is engineered; it’s a programmer’s CMS. Everything is extremely decoupled and customisable, and although that may not add much to the site itself, I suspect it would be more extensible in the future. WordPress is positively rigid in comparison. Finally, I’d just like to learn Drupal for future use, so what better place to start.

One last thing, you’ll notice the theme of Piemaster.net has changed as well. I was so eager to update everything that I didn’t really consider the consequences. The Mystique theme I was using had been customised a bit, and it turns out that since my last update a while back a bunch of features were removed and moved to “Mystique 3+”, leaving the site a bit of a mess. Reverting to the WordPress default theme Twenty Eleven is quite serviceable for now, however.

So in conclusion, I’m actually pretty happy with WordPress for the minute now that it’s all smooth sailing again. Migrating to Drupal is possible (I’ve more or less done it locally), but inevitably hits a few snags. The menus need to be reconstructed, the themes aren’t very pretty, users will need to re-register (not that there really is any atm), etc. I will get around to it, but maybe not just yet.

Jario Update: Sounds and Semi-Passability!

Yes, thank you Chrome, only one of those is a word, and yet Jario now has both! Sounds were ridiculously easy to add through a generic SoundSystem with a handful of static sounds (courtesy of http://www.freesound.org/) and a static queue-push method, and then the single-line calls were peppered throughout the systems as required. The result is a game which is a lot more fun to play! Despite still being about 60 seconds long.

Go ahead, try it out!   Launch Java Web Start button

The issue of passability is a more technical one. Previously, all detected collisions were handled directly by each of the colliding entities. This is great for many cases, but there are some times when you don’t want to handle a collision, or when you want to not handle it under certain conditions, and for which adding in a bunch of conditional guards is ugly and inefficient.

My solution was to sneak an extra layer into my collision handling hierarchy (which I’ll talk more about when it’s a little more polished), right up the top, to manage collision persistence. In this context, persistence means that when two entities collide, all future collisions that are detected until they stop colliding can be grouped into a single collision, and handled only once at the beginning. This is important for a number of gameplay mechanics.

For example, the two cases I added just now were semi-passable platforms and improved handling of player recovery. Semi-passable platforms are those ones that you can jump through from below, as well as stand on top of. One way to get this behaviour is to say “if the collision is not from the top edge, do nothing, otherwise block the entity”. This may work, depending on your collision detection mechanism, but for the time being mine is very basic, and detects the edge of the collision based on the X and Y distance the two entities are overlapping by. The result is that if you jump through from the bottom, a bunch of collisions will occur for the handful of frames you’re passing through, and as you are about to exit from the top, one of those collisions will be detected as “top edge”, and the default behaviour is to place the player on top of the platform. The behaviour we want is for the player to keep jumping, eventually fall back down, and then be placed on the platform.

My solution is a little more complex than perhaps it needs to be, but it’s a good starting point. When a collision occurs, the handling systems can register the collision as a “passing through” case, after which future collisions will not be handled by the entity that is passing through (the ‘passer’) until the entities separate. However, the entity being passed through (the ‘passable’) will continue to receive handling calls in case the circumstances of its passability change. It can therefore also check whether the colliding entity has been previously registered as a passer. All of this handling is contained in PersistentEntityHandlingSystem class, which all current collision handlers extend.

In the case of the platforms, this is straightforward. On the first collision, if the player collides with a non-top edge of the platform, the platform registers the player as a passer, and the player continues unhindered. Once the player exits at the top, they are unregistered from the platform, and the next collision will be handled appropriately on the top edge.

Player recovery is a little trickier. By “recovery” I mean the period of invulnerability you get after being damaged with >1 health. During this time, you shouldn’t be able to stomp enemies from inside (i.e. walk into them from the left, then jump and kill them on the way out). So for this case, when the player collides with an enemy, he first checks whether he’s in recovery mode, and if so, if the enemy is not already registered as passing through, then the registration occurs. The enemy passing through the player means that the enemy is oblivious to the collisions (and so can’t die until the player leaves and comes back), but the player’s handler is still called each frame. Therefore when the test for recovery fails (i.e. recovery time has expired), then the enemy is unregistered as a passer, and the collision can be handled normally.

But wait, there’s more. It’s possible for recovery to expire while the player is standing right in the middle of the enemy, and if the position is right, it will register as a top-edge collision, and “handling normally” means the enemy will get stomped. This is not the desired behaviour – if the the player is standing inside the enemy when recovery expires, the player should get stomped instead. To work around this, I added a parallel map that records which passable-passer relationships should be unregistered in the next frame. This gives the player collision handler a chance to handle the collision manually and correctly (take damage) before unregistering. If the player manually takes damage AND unregisters in that frame, by the time the enemy handles the collision it will appear unregistered, and the potential top-edge problem persists. By delaying it one frame, the player’s damage will have been fully accounted for, and the enemy collision will not occur at all.

Problem solved! You can see all that in PlayerHandlingSystem if you like. Like I said, it’s quite complex and I’d like to simplify it a bit, but it’s a start. By experimenting with this approach, I’ve gained even more of an appreciation of the Artemis framework. You really can tackle your problems one at a time, in isolation. Even in the case of a two-entity collision, the collision handling of the two entities can be neatly decoupled. The future is looking bright!

Jario Update: Kinda Working!

I’ve just pushed an update to Jario with some pretty nice changes since I last mentioned it. As usual, you can check out the source if you’re interested or just Launch Java Web Start button!

I’ll be quick:

Features:

  • All the important items – coins, mushrooms, fire flowers and stars.
  • Goombas, Koopas and even empt shells, with the ‘proper’ graphics and animations.
  • Vastly improved input and collision handling.
  • Added a marginally more satisfying ending, though it still doesn’t do anything.
  • Fixed many, many bugs (but not the intermittent collision mesh one yet).

Architecture:

  • Cleaned up collision handling systems into a hierarchy of similar handlers for increasingly concrete entity types. I’ve found it to be very flexible and reusable so far, which is nice, since the logic of a game is little more than input and collisions.
  • Refactored image and animation spatials into a hierarchy of intermediate abstract classes, and added a SpatialComposer to group the different spatials of individual entity types and handle different states.
  • Inserted a hierarchy layer for spatial effect handling. Currently only processes changes in rendering alpha value, but does so quite nicely.
  • Played around with a TimerSystem to be used in conjunction with a Timer component, allowing systems to easily register callbacks with individual entities to be executed after a given delay. Makes it very easy to add temporary properties to entities. For instance, giving the player X seconds of invulnerability (hurt with >1 health, or press I) reduces to a single static function call. Still need to play with Artemis’ DelayedEntityProcessingSystem to see if that does a similar thing.

That’s all the significant bits so far. Still plenty more to go, though! Some of the above will need to change in order to support a complete level, which will be interesting. I also need some better game state transitions, though that’s nothing to do with Artemis. I’ll talk a little bit about some of the more interesting points soon, such as the collision handling and spatials, since those two are key to getting a game working smoothly.

Back In The Saddle

With semester one of university now completed (after my final exam yesterday), I am once again free to kick on with development of the good ship Piemaster and all that sail in her. There’s so very much work to do and I’ve been looking forward to it for quite some time now, having played around with a few new technologies during semester.

One of the primary objectives I hope to complete is to start posting more regularly about interesting new things as I come across them, and retrospectives of my experiences as I have them. I will try even harder now to make time for these, despite having said that repeatedly before.

I’ve also started working on a new game (a simple Asteroids clone at first, then something more sophisticated) taking advantage of a beautiful new framework I discovered, which I will write more about later. I’m putting development of my productivity-type applications on hold for the holidays and diving headlong into game development, for a few reasons: it was (indirectly) the topic of a subject at uni last semester; it’s much easier to get feedback from myself and others; it can more easily be defined as “finished”; and I just really enjoy creating games, whether in my head, on paper or with a computer. There should be plenty to write about along the way.

So that’s enough for now, and I’ll expand on a few of these points in the near future. Welcome back, and I hope to be able to provide a few things of real value within the next 3 weeks.