re:Creation Week #0: Preparation

Week #1: Things are getting bigger!

This week I don’t think I’ve accomplished something really huge, because I’ve decided to finally rest after month of studying hard. But now I can work almost full-time so lots of changes will come, I guess.

But still, I’ve managed to develop some cool stuff.


This isn’t really first week I’m programming this game. I’ve spent some month on engine and level editor, but this is the week I’m starting to see the game itself!

It’s called re:Creation. It’s oldschool top-down action rpg where you play as undead knight who wants to seek revenge for his death and free people from evil wizard who used trapped demon’s soul as the power source for 800 years.  Here’s what was implemented:

Runtime script reloading

Well, this thing is actually amazing and useful. I can now reload scripts when the game is running. That means that I can change lots of things without the need to recompile or restart the game. I think this will save me lots of hours.

Advanced script support and dialogues

Witch can heal the player now

This one is actually one of the most impressive things I’ve ever done, I think. I was using Lua as configuration language most of the time, but I can use even more now.
I’ve spent some time messing around with different Lua/C++ libraries and I think LuaBridge is the best. I think I’ll rewrite third part of my Lua/C++ tutorial which will show how to use it.

My game uses entity/component/system and each entity can be accessed by integer id. Here’s how I can get health value of some entity:

// in C++
std::shared_ptr<Entity> e = entityManager->getEntity(entityId);
HealthComponent* hc = e->get<HealthComponent>()
int health = hc->getHp();

Yeah, this is quite verbose. I didn’t want to translate it 1:1 to Lua, because it would be much easier to have some wrapper function, which only needs entity id to get its health value. It will be easier and safer to use it this way

// C++
int getHealth(int entityId) {
    std::shared_ptr<Entity> e = entityManager->getEntity(entityId);
    HealthComponent* hc = e->get<HealthComponent>()
    int health = hc->getHp();
    return health;

Of course, error checking can be done to improve function safety:

int getHealth(int entityId) {
	std::shared_ptr<Entity> e = getEntity(entityId);
	if(e) {
		HealthComponent* hc = e->get<HealthComponent>();
		if(hc) {
			return hc->getHealth();
	return -1; // entity not found or doesn't have HealthComponent

Let’s get to something more practical. I’ll show how witch in the gif above is scripted
I have witch.lua script which has a structure like this

Witch = {
    ... -- some components
    InteractionComponent = {
       interactionRect = { -16, 32, 64, 32 },
       interact = function (firstId, secondId)
            maxHp = getMaxHp(secondId)
            if (getHp(secondId) < maxHp) then
                say("Let me help you, stranger.")
                setHp(secondId, maxHp)
                say("Come back when you are\nwounded.")

I can get “interact” function and don’t even need to harcode witch’s behaviour! This is so cool!
Ah, and I’ve also added lots of error checking which is something that takes a lot of time but isn’t seen by many. If you misspell some name of a function, you get an error and the game ignores it.

Improved level editor

Added snapping to grid and help menu. Nothing very special

Well, that’s it for this week. I’ll try to work very hard this week (I hope I won’t be interrupted too often) and will post the next update in a week!


Read a cool book. “Game Project Complete” by Thomas Schwarzl. Very motivational and useful. Makes me want to become more disciplined. I cannot recommend this book enough. :)

I am also reading “Peopleware: Productive Projects and Teams” by Tom DeMarco and  Tim Lister. It’s a really great book about human errors in IT and why managers fail to control projects efficiently.

I also recommend you to watch this awesome talk by Jeff Atwood. The most important points for me were “Embrace the suck” and “Do it public“. Well, as you can see (look at this post!), I do these things. Nice.

3 thoughts on “re:Creation Week #0: Preparation

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s