Category Archives: General

hxE2 + Entity Systems

[Update 2016.01.26] hxE2 is now deprecated in favour of Eskimo. If someone wants to try and fix issues, sure why not, but I’m not actively using or maintaining this!

[Update] hxE2 has been released in Alpha status here. It corresponds to the topics and improvements to hxE mentioned in this post. All feedback and comments are welcome! :)

I like talking about Entity Systems. And unlike most things I’ve talked about on this website, I have actually finished several implementations of different ECS designs.

My first one was pretty much a port from the Artemis ECS, which I’ve mentioned before, called hxE. But this design was very limited. Each System could only process 1 type of entity, and because of this, it could over complicate simple tasks like checking the distance between “Item” entities and “Inventory” entities. Ideally I would have looped over all <Item, Transform> entities, and checked the distance between all <Inventory, Transform> entities. Simple. The System limit of 1 entity type meant I needed to have 2 systems processing each type of entity, as well as some sort of communication between those systems, or further, generalize the concept of collisions which means more components…etc. etc.

[For those that didn’t understand much about what I just wrote, I recommend reading through the T-Machine blog posts on entity systems. He brings up the core concepts of how they work, as well as addressing common questions.]

Summed up, my ideology is a complete separation of Data and Logic. Systems are logic, and Components are data. What this means is that most components are PODs (Plain Old Data) with no functions, except where they are only helper functions in processing the data of that component. A System can be considered as anything that does work on components, though I usually formalize this concept as a class in most of my engines, simply to provide a common interface/reduce work required to have it running in the engine.

Moving onwards from hxE’s design, my current entity systems have the entity filtering detached from the systems. So now a System is just an empty shell with some function hooks to override (onWorldAdded, onWorldRemoved, process(delta:Float) … ). This means that a system can take in as many entity types as it needs to:

var items = new View2(world, Transform, Item);
var inventories = new View2(world, Transform, Inventory);
for (item in items.entities)
for (inventory in inventories.entities)
     var item_transform = items.get1(item);
     var inventory_transform = inventories.get1(inventory);
     var dx = item_transform.x - inventory_transform.x;
     var dy = item_transform.y - inventory_transform.y;
     if (dx * dx + dy * dy <= distance_to_pickup * distance_to_pickup) // add item to inventory and destroy item entity.
//var example = new View4(world, Transform, Mesh, Material, Input);

Not only does this make Systems much more flexible, but this also separates the concept of System, and a View into the World. At this point, System classes are helper classes rather than essential parts of the engine – a system can be anything the user wants it to be, interaction with the world is much more direct using Views.

Internally, things are setup to work well in a multithreaded environment. Each View holds a list of updates to process – once this point is made threadsafe, the rest of the interaction with the EntityWorld always happens through the View. This update pushing is also a slight concern for performance, but I will work on having performant, single threaded implementations at a later time if this happens impact projects more than I’m expecting it to.

Over the next few weeks I have a project that will be based on hxE2, and could be interesting to people using it. As I’m doing that, I’ll try to go into more details about specific parts of the hxE2 implementation, focusing on parts I get questions about etc., but for now, this is just a quick introductory post for hxE2 and my way of implementing an ECS!

Enjoi :)


D + OpenGL = Fun

Thought I’d inform everyone on what I’m currently doing. Between working on a few games, and university, I’m starting to get into D programming as well as OpenGL and SDL.

You probably won’t have heard of D, but you can check it out here: < The homepage lists a lot of it’s features!

It’s like C++, but I like to think a more modern version, as well as has several snazzy features built into it, so it’s also convenient. The whole style of it feels way more comfortable to me than when I tried getting started with C++, and…well…I can’t really explain why I like it, and perhaps that’s a bad sign, but I like learning new things, so why not!

I figured if I’m coming from an AS3 background, then D is closer to what I’m used to than C++, seeing that it has garbage collection, and from what I read a few handy functions built-in that C++ doesn’t have (yes, you can use libraries either way, but why the hassle if the feature’s in the language itself?). Even the way you import modules is with dots, which is obviously really minor, but feels more like home:

import derelict.sdl.sdl2;

And of course, learning something new is hard if you don’t have motivation, so my motivation to learn D is to also learn OpenGL and SDL2 with it (and also vice versa), and make a simple game engine I could use to make some “real” games from scratch!

I just needed to quickly wrap my head around the general working of OpenGL, and now I’m already starting to understand it’s pipeline, and how it works (I think…). I haven’t really touched SDL too much, except to open up a GL window etc.. Either way, should get interesting. (I think any programmer (but nobody else :( ) will understand the rush of excitement I got when I saw a triangle with red, green, and blue corners rotating in a black window! To know that I commanded my GPU to do such things…the power I now wield!)

Seriously check out the D programming language though! The IRC is pretty active, and has a friendly community there that will help you if you ever get stuck on something, and all in all it’s new, interesting, and without it you’ll be useless.


NG Game Jam 8


I never write here anymore…and I always say that’s going to change…so no promises on that in the future.

Anyways, to the point. Last weekend I took part in the Newgrounds Game Jam 8, with my partner, Nicholas Deary. We both have worked together in NG Jams before, about 3 times together now, so we are starting to get to know each other pretty well in terms of working and mindflow. Interestingly enough, right after game jams, we usually just go back to our own business and start messaging each other again only right before the next jam!

This time that’s changing a bit, since we didn’t finish our game for the game jam deadline, even though the game engine is working almost 100% as we want it to. All that was lacking was content, in terms of puzzles, and art, and a point to the baddies, which all they did was run at you, if they hit you, you saw static for a bit, otherwise they just disappeared after 5 seconds.

Here are 4 screenshots of the current engine:

Screenshots x 4 of the game engine.
Screenshots of our game, which will hopefully be finished next week!

Currently you can walk around, look at certain things, pick up items, and toggle switches (open doors). Might not seem like a lot, but each item and switch can have a required item to pick it up/use it. Also, switches can be linked to multiple doors, with either open, close, or toggle commands, which gives us a chance to make puzzles in getting the right order or switches or something. It isn’t a lot…

But that’s why we’re going to jam things up this coming weekend again, and stick in a few more features, and prepare a proper level to explore and do stuff in! Additional things I want to get running from the engine side is switches not only open doors, but switches themselves having an active state, and they can be a requirement for picking up items or using other switches. And switches to have different types, like a user activated switch or auto switch, that activates when the player, or other entities are nearby. And also if it’s a toggle switch or a momentary switch (while standing on it, it’s on, when you leave, it’s off). This will already multiply the possibilities of different puzzles, especially if you need to use the bad guys to solve certain puzzles!

The whole take I’ve had on this project is not as an action top-down shooter, but much more like a puzzle game, with horror elements. Right now the horror is working out okay, but sound work as well as an improvement on the gfx should help. While you can do it, there is currently no point in equipping items, as you need to use them from the inventory with your mouse on other objects. I might change this to having to equip and hit other items to use it, if anyone actually reads this, they can leave a comment below suggesting something! :)

I have thought about doing pop-up puzzles, or password entries, and I’m starting to think it might be out of scope for the current game, but in the future, you can count on it!

A funny afterthought about this whole game jam thing….I’ve been working on and off on my zombie game engine for the past few months, with pretty good results. This last weekend I created a whole new engine (with a few parts tugged off of the zombie engine) in under 48 hours, and it is already better than my zombie engine in terms of features. This means that the old zombie game project is off, and I will be continuing work with this engine in the future. I think it is a really good base, since it also made improvements on level editing in Flash (it now parses a textfield that should contain a JSON object to give objects properties).

Pfff…anyways…if anyone is reading this, thanks for reading all the above, I guess it’s kind of a long read. Any questions? Comment below!


Gears are creaking…

Haven’t updated this place in ages, but then again, I highly doubt anyone reads it anyways.

But for the sake of having a blog, here’s an update on things:
I’ve been super busy.
Music “career” had a small boost, record label and whatnot, but nothing too huge yet.

Zombie game is back on!
I restarted the engine from scratch redesigning the architecture like mad. It’s making working with the engine much easier, plus I’m using the NAPE AS3 physics engine to handle collisions, and so I should have more features than initially planned, and overall it’ll hopefully look very shpamtastic.

So far where I’m at is having the physics running and just boring engine stuff. Still have some things to sort out with weapons and object spawning in general…can’t figure out a good way to stick it all in and keep everything nice and clean between classes.

I’ll up a demo as soon as I get something interesting going, but a big feature add is the ability to drag objects in the game (thanks to using a physics library). I’ll probably be using that a lot for puzzles and also to hide from/block zombies (Penumbra/Amnesia style, except 2D)

Humdumdum…I guess that’s it for now. I’ve been working on a snazzy tech demo for some dynamic grass, not sure if that’s worth uploading yet either. But depending on how much I can optimize it/make it work, one more treat to be seen in the zombie game! It gets a very nice moving atmosphere.

Till next time, hopefully in the next month you’ll be seeing some stuff. And by “you’ll” I mean the Google web crawlers who are probably the only ones who check out my blog.