Re:creation dev log. March-June 2016. Part one. Game stuff and and some awesome Lua scripting

The last few months I was very busy finishing my bachelor’s degree (it’s over, I got an “A”!). But still, I’ve managed to do some cool stuff and improve the engine structure and tools in the last couple of months.

This dev log will be released in two parts. In this part I’m going to talk about game stuff I did and stuff I changed about Lua/C++ integration. In the second part I’ll talk about engine tools I’ve made with ImGui and different refactoring I’ve done.

Game stuff

Here’s one of the latest screenshots of the game. Houses were previously just big sprites, but right now they’re composed out of tiles which lets me reuse them for other houses and build new buildings more quickly.
i2yn8x4

Continue reading

Re:creation dev log. 2015. The most productive year yet.

It’s time to summarize what I’ve done during this year with Re:creation. It has been very good year, I’ve managed to do and learn lots of stuff.

Before I write about the stuff I’ve done I want to thank everyone who followed my progress and provided feedback. This stuff is really important for me and always keeps me motivated. With your support I never feel doubt about my game, I never want to stop making it. Thank you.

Special thanks to SFML community. It turned my dev log thread into a very cool discussion and helped me out with lots of stuff. This level of support is much more than I’ve ever expected and it’s very heartwarming.

I’ll show the most interesting stuff I’ve done and then explain some in more detail.
Some screenshots are taken at different parts of the year, so they may differ a lot!

Some gameplay gifs to get you started:



This one is my favorite gif so far. It really shows a lot of stuff I’ve made this year.

Continue reading

Using Lua with C++ in Practice. Part3. Controlling entities in Lua by calling C++ functions.

If you haven’t read the first part of the tutorial, I suggest you to read it, so you have a clear idea what’s going on. See the second part for the implementation details.

This article uses LuaBridge and if you’re not familiar with it, I suggest you to check out my tutorials about it. (Pt1, Pt2). If you’re using another Lua/C++ binding: that’s fine, you can totally implement everything I’m talking about with other bindings.

Intro

One of the coolest things in Lua is that you can call C++ functions from it. You can even register your own classes and call their member functions!

Suppose you have an entity class which contains a list of components:

class Entity {
    ...
private:
    std::vector<std::unique_ptr<Component>> components;
};

Suppose that you have a function which lets you get a component by its name.
What if you want to change animations in some Lua script? You can do it like this:

function someLuaFunction(entity)
  ...
    local graphics = entity:getComponent("Graphics")
    if(graphics) then
        graphics:setAnimation("someAnimation")
    end
  ...
end

I believe that this is not a greatest way to do things, because exposing components to Lua is not really necessary. Woudn’t it be nice to hide all the implementation details in C++? Here’s how the code above may look:

function someLuaFunction(entity)
  ...
    entity:setAnimation("someAnimation")
  ...
end

Continue reading

Using Lua with C++ in practice. Part 2. Implementing the basics

Source code for this article

Hello, this is a second part of “Using Lua with C++ in Practice” series. I recommend to read the first part to know what’s going on and why using Lua with C++ is awesome! (You’ll see it in this arcticle too, of course).

This tutorial will implement a simple ECS model which I’ll improve and use in other parts of tutorials. Note that this is not the best way to implement ECS. I’m making the most basic ECS which can be used to show the main principles of how things work in my game and how you can use them in general. This is not a tutorial about C++, so I won’t spend too much time discussing C++ parts and I’ll mostly focus on Lua/C++ interaction and binding. Let’s start!

Continue reading

Using Lua with C++ in practice. Part 1. Intro to ECS and basic principles

There are many reasons to use Lua with C++. One of them is that you can put some of the logic from C++ code into scripts, so you can easily change them without the need or recompilation. You can also write some good interfaces, so the scripts are easy enough for even non-coders to write them. Lua is free, Lua is fast, Lua is used in game development quite often.

While there are plenty of good articles about using Lua with C++, I think there are not enough articles about how to use Lua in real projects.

This article is one of the many articles I plan to write. Here are some topics which my articles will cover:

  •  Entity creation and other basic stuff (you’re reading this now)
  •  How to implement entity creation
  •  Managing Lua state and cleaning up
  •  Scriptable state machines
  •  Events and callbacks

The stuff described in the articles was mostly discovered during the development of my game called Re:creation.
I don’t think the methods here are perfect, but they’re good enough, fast and work well for me. So, your feedback is welcome. Feel free to leave comments and write e-mails to me about the stuff I can do better. I’m interested in hearing about your Lua/C++ usage!

While this is a C++ article, I think you can implement most of the things mentioned here in your favourite language. I’ll use Lua C API and LuaBridge for examples, so I recommend to read the following articles if you’re not familiar with them:

Continue reading

Re:creation dev log. April-May 2015. Recreation mechanic, archers, event system and more!

Last two months were pretty awesome. I had lots of free time and was able to implement lots of new stuff!

Recreation mechanic

Let’s start with a gameplay gif:

It’s another example of recreation mechanic.
For those who don’t know, recreation mechanic is the main mechanic in my game. When undead hero kills people, he can leave his body and control dead people with his ghost. He gains their abilities to progress through the game and solve various puzzles. But he can’t leave his body behind for a long time because he can’t carry the hammer while controlling other people. The hammer can do some stuff which normal weapons can’t. (break some floors, for example)
This hammer is very heavy so he can’t carry other weapons. So, for example, in order to shoot arrows, you need to kill archers and control them with your ghost.
He can also use his ghost to reach inaccessible areas. But this won’t be very useful if there are no corpses lying there because he won’t be able to interact with the world this way. But it has another use: you can look around and see what you have to deal with next. This will be very helpful when solving complex puzzles.

Continue reading

Re:creation dev log. March 2015. Graphics improvements, entity inheritance, improved state machines and more!

This month was great. I finally got in the flow of development and managed to get lots of things done. I worked hard to make game look better and here’s the result. Compare old screens with new screens:

October 2014

 

March 2015

Continue reading

Using Lua with C++. Using Lua scripts with C++ classes.

Read the first part about LuaBridge here to see how to install it and use it for basic things.

You can find the complete source code of this article here

This part will show you how to register C++ classes in Lua, call member functions and how to apply scripts to something practical like putting object behaviour code in scripts.
I’m a game developer, so I’ve used examples related to gamedev but you can use Lua almost everywhere, so take a look even if you’re not interested in gamedev.
The code used in this article is as simple as possible while also remaining a complete example which you can run and compile.
I leave out the details which are irrelevant to focus on the main topic: scripts.

Continue reading

Re:creation dev log. September 2014. Drawing art, being a solo dev, fixing bugs.

Lots of time passed since the last dev log. How’s the game? It’s doing pretty well.

Some things changed, the most notable thing is that I’ve become a solo gamedev now, because the artist abandoned the project. Every sprite you see in the latest screenshots was drawn by me.

Being solo dev is hard, very hard. I spend lots of time practicing art, drawing sprites, animating them and trying to make them as good-looking as possible without spending too much time. And I still have to do programming, scripting, designing and story writing!

Continue reading