Here’s what I did this summer.

As I’m writing this the last day of the summer is approaching its end. It’s been an awesome study break. It lasted for two months and a lot of things were done in this period.

I see a lot of people who are disappointed in their summer. I’m not disappointed at all. I think I’ve accomplished some great things and while I didn’t reach some of the goals I’ve set, I’ll still work on them. My goals were not very specific (I found it very useful to set not very specific goals as I end enjoying my free time more): read some stuff, develop my game, write some blog posts and spend time with my family and SO. And I did it all. And it was great.

To be fair, I’m a little tired of this study break. I’m glad that I’ll have to study again. Hope this motivation won’t go away too soon. And now I’ll talk in detail about the things I did.

Continue reading

re:Creation dev log. Week #2 and #3. AI stuff and vacation

Week #0: Preparation

Week #1: Things are getting bigger

Week #2 and #3. AI stuff and vacation

I started to prototype the first “real” level of the game. As I was working on it, I realized all the flaws of level editor and features it lacked of. So I worked a lot on the level editor!

A lot of time was also put in optimization. Release build was always working at 60 fps without a problem, but as an object counter grew bigger and bigger Debug build started to slow down, so I decided to optimize my game a bit and now it’s running at 60 fps on Debug too. Neat.

I was also working on AI for some time. First I got NPC to go to the specified point of map.

I accidentally swapped walking animations and results were hilarious.

Continue reading

Using Lua with C++. LuaBridge makes everything easier. Variables and functions

Why use Lua?

Using scripts with C++ is great. They provide lots of flexibility and free you from using those .txt files for your configuration files and also let you write complex functions. You can modify your scripts without recompiling. This is really important because you get distracted less often. Even a short compilation can break your concentration.
And you can even design your system that even those people who don’t know how to code can create new scripts or modify existing object behavior without modifying your source code! If you want to know more reasons of what makes Lua great read the beginning of this article.

I wrote about how you can develop your own binding library in previous chapters. But this library is very basic, it doesn’t have the power some other libraries have. It’s really hard to write your own binding because it usually involves lots of templates magic and meta-programming.

I’ve tested lots of libraries and found LuaBridge to be the most awesome. It has MIT license, doesn’t have any dependencies(like Boost which some libraries use) and it doesn’t require C++11. You don’t need to build it. Just drop LuaBridge folder in your project folder, include one header and you’re ready to go!

Continue reading

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:

Continue reading

Using Lua with C++(Part 3)

Part 1. Why Lua is great and why you should use it. Writing simple wrapper/binding and using Lua for configuration files

Part 2. Getting arrays and calling Lua functions from C++

Part 2.5. Template getArray function and other modifications

Part 3. Calling C++ functions and creating C++ objects

I am very excited to write about this topic because it shows how great Lua is. While Lua is great for configuration files (as I’ve shown in my previous tutorials) it’s even greater when you use it to call C++ functions and you can even create C++ objects classes and modify them with Lua (I’ll cover this in part 4)
Let’s begin.

Note: if you don’t know about how Lua stack works, I recommend you to read this chapter of great “Programming in Lua” book :

Continue reading

Using Lua with C++(Part 2)

Part 1. Why Lua is great and why you should use it. Writing simple wrapper/binding and using Lua for configuration files

Part 2. Getting arrays and calling Lua functions from C++

Part 2.5. Template getArray function and other modifications

Part 3. Calling C++ functions and creating C++ objects

And you can view source code here:

Continue reading

Using Lua with C++ (Part 1)

You can view full source code of this article here

Russian version of this tutorial here

If you want to see Lua in real world practice, check out Using Lua with C++ in practice series.


This article is about building your own  Lua/C++ binding. If you want to use an existing library (which is a lot easier and faster), check out this article : Using Lua with C++: LuaBridge

So, why use LUA?

I’ve seen game devs using different data formats. Some of them use JSON, some use XML, some use plain .txt files etc.. As for me, I use Lua for data, because:

  • It is easy to use without any additional libraries(well, except of lua libraries, of course…)
  • You can use different formulas in your files, for example: some_variable = math.sqrt(2) * 2
  • It’s extremely lightweight and fast
  • It’s under MIT license, so you can use it in any way you want. Just download it and use it
  • It’s ported almost everywhere, because it’s written in C and compiles with almost any C compiler
  • You can use tables to categorize your data which is easy to edit and read

Let’s look at example Lua file:

player = {
    pos = {
         X = 20,
         Y = 30,
    filename = "res/images/player.png",
    HP = 20,
-- you can also have comments

With a little class(implementation is below) you can get data in this way:

LuaScript script("player.lua");
std::string filename = script.get("player.filename");
int posX = script.get("player.pos.X");

Pretty neat.


You can find lots of bindings here.
But I wanted to write my own, so here it is.

Note: my code is not perfect, but it works. I appreciate your suggestions on how I can improve my code. E-mail me if you find some errors or just to say thanks:

Continue reading