Homebrew [WIP] Kairy - A 2D Game Framework

  • Thread starter Deleted User
  • Start date
  • Views 3,468
  • Replies 18
  • Likes 20
D

Deleted User

Guest
OP
Kairy - A 2D Game Framework

Hi, I'm Nanni one of the creators of the original Lua Player Plus.
Currently I'm working on a C++11 2D game framework for the 3DS named Kairy.

Right now the project is a WIP, many things don't work as expected and there are many bugs, but the library is still usable to make games. It's also pretty fast.

The library is heavily inspired to Cocos2D and SFML, so many things are similar.

This is a list of some supported features:

  • Kairy can be compiled for Windows, Linux and Mac making your life super easy when you want only to test the appearance of your game. It depends on GLEW, OpenGL and OpenAL. You should build it by yourself (for instance on Windows by adding all the source to a Visual Studio solution) but i'm planning to write a CMake file.
  • Tmx maps loading and rendering (with support for animated tiles)
  • A complete input engine
  • Loading of Bitmap Fonts and TTF (using stb_truetype) fonts
  • A resource manager to avoid loading of textures twice
  • Rich 2D math library (Vectors and Rectangles)
  • A decent scene graph
  • A class for images manipulation
  • Actions
  • Basic UI
  • A working Sound class
  • Some third party libraries are included in Kairy itself (like Box2D, tinyxml2 ... )
Here is an example to show how powerful Kairy is:

Code:
#include <Kairy/Kairy.h>

USING_NS_KAIRY;

class TestScene : public Scene
{
public:
    bool onCreate() override
    {
        auto sprite = Sprite::create("assets/sprite.png");
   
        sprite->setPosition((getScreenSize(Screen::Top) -
            sprite->getSize()) / 2.0f);
   
        sprite->runAction(RepeatForever::create(RotateBy::create(1.0f, 120.0f)));
   
        addChild(sprite);
   
        auto triangle = TriangleShape::create(Vec2(-30, 30), Vec2(0, 0), Vec2(30, 30));
        triangle->setPosition((getScreenSize(Screen::Bottom) - triangle->getSize()) / 2.0f);
        triangle->setColor(Color::Red);
        addChildBot(triangle);
   
        return true;
    }
private:
};

int main(int argc, char* argv[])
{
    auto device = RenderDevice::getInstance();
    auto audio = AudioDevice::getInstance();
    auto sceneManager = SceneManager::getInstance();

    device->init();
    audio->init();

    device->setQuitOnStart(true);

    sceneManager->changeScene(std::make_shared<TestScene>());

    while (device->isRunning())
    {
        sceneManager->update(device->getDeltaTime());
        sceneManager->draw();

        device->swapBuffers();
    }

    audio->destroy();
    device->destroy();

    return EXIT_SUCCESS;
}

And here is the result running on Citra:
ALy572u.png
And here is the result running on Kairy compiled for Windows:
hhlRZfK.png

If you like Kairy and you want to contribute, please help the project on GitHub.
Currently I don't have a enough time to put on it so i will greatly appreciate your help.

I've made Kairy to allow easily games creation for any interested C++ developer (or maybe because i wanted to play someting new on my 3DS...).

I can't wait to see what you can do with it =)

KNOWN BUGS:
  • Music streaming doesn't work (currently only wav mono files works)
  • Incomplete and shitty particle engine
  • PCM8 stereo playback is broken
  • RenderTexture doesn't work
  • CircleShape is broken
  • Threads creation inside classes could randomly crash
  • Converting some types of floats to strings (with Kairy utility functions or even with sprintf) will crash the 3DS
  • Incomplete UI
  • Incomplete Actions
  • Loading a Tmx map with a tsx tileset doesn't always work
  • Loading resources from zip files on the 3DS dont' work right now
  • Screenshots on Windows, Linux and Mac are upside down (I know the reason but i'm too lazy to fix it xD)
  • Directory class is super incomplete
  • Error handler isn't flawless

LINKS:
GitHub repository: https://github.com/CurryGuy/Kairy

Current version compiled with lastest libctru: https://mega.nz/#!CMNDgJTS!o3fVM2efQ2dfLeVCTMhAddPH1FwI4yfspR_2RQEDFwk

3DS compiled examples: https://mega.nz/#!Od80SK7Q!lDmSe2qP-cXJHZ-e0xpf-OUgJNS92GOlnUqfDPZuDVc
 
Last edited by ,

neobrain

-
Member
Joined
Apr 25, 2014
Messages
306
Trophies
0
XP
730
Country
Did you happen to forget committing some shader related files? In particular, source/Kairy/Graphics/RenderDevice.cpp includes base_vsh_shbin.h, which I suppose is supposed to be generated from a compiled shader. Couldn't find any of that in the git tree, though.

EDIT: Also, the downloads for the binaries demand some decryption key..
 
Last edited by neobrain,

ringo1206

Banned!
Banned
Joined
Oct 14, 2015
Messages
173
Trophies
0
Age
30
XP
84
Country
United States
Cool! Just wondering my 2D game do you mean like "not 3D by perspective or stereoscopic 3D?

I think a 2D game with 3D stereo. layers would be cool. Just a suggestion.
 
D

Deleted User

Guest
OP
Did you happen to forget committing some shader related files? In particular, source/Kairy/Graphics/RenderDevice.cpp includes base_vsh_shbin.h, which I suppose is supposed to be generated from a compiled shader. Couldn't find any of that in the git tree, though.

EDIT: Also, the downloads for the binaries demand some decryption key..

You're right, I've uploaded the shader to GitHub.
Also I fixed the links =)
That was my bad sorry
 
  • Like
Reactions: neobrain
D

Deleted User

Guest
OP
Any reason why there's a kernel exploit embedded into this project? Games should be entirely userland applications, so I don't understand why it goes through the trouble of privilege escalation at start up.
I was using it for testing purpose.
I've removed it, now the project on GitHub should be clean
 

cpasjuste

Well-Known Member
Member
Joined
Aug 27, 2015
Messages
1,108
Trophies
1
Age
44
XP
4,481
Country
France
Hum this is interesting. I'm developing my own c++ gui/windows library since a few weeks now (with the very little time I have). Your project seems to be a lot more advanced than mine (holy crap :P). I will probably take a look/port my current project to your lib and see how it goes. I mean I'll probably work with you on this and trash my own lib (which work fine tought, snif...).

I'll report in a few days ! By the way, nice work.

Edit: just a little question, it seems it currently only allow to create textures from rgba8 pixels buffer isn't it ?
 
Last edited by cpasjuste,
D

Deleted User

Guest
OP
First of all, sorry for the late reply:

Cool! Just wondering my 2D game do you mean like "not 3D by perspective or stereoscopic 3D?

I think a 2D game with 3D stereo. layers would be cool. Just a suggestion.

It's not 3D by perspective. Kairy supports stereoscopic 3D

This is awesome! One question though... Why the name Kairy?
Edit: one more question.. How do i set it up

I don't know why Kairy... I always wanted to call something 'Kairy' lol
However, you can setup Kairy copying the compiled files in the libctru folder (you should copy the Kairy lib and include directories to libctru)
Or if you want you can compile Kairy yourself. Just grab the source from GitHub and do a "make install". That will compile and install the library.
Then you can start a new project by using the example 0 (00-Template) as template from GitHub.

You should use the .hpp extension file for c++ header files.

You're right, I should. But I personally like the 'h' extensione more. I don't think it's a problem...

Nice, seems to have a lot of the same goals and characteristics of my library/framework. I did a more direct port of SFML with a more direct port of OpenGL. I like your examples, I need to add some in mine too. (Have some 3d classes implemented already when I get fragment lighting working well).

GJ for porting SFML and OpenGL, didn't know of that Project. However I don't like SFML much that's why I made Kairy xD
Feel free to take inspiration from my examples if you want =)

Hum this is interesting. I'm developing my own c++ gui/windows library since a few weeks now (with the very little time I have). Your project seems to be a lot more advanced than mine (holy crap :P). I will probably take a look/port my current project to your lib and see how it goes. I mean I'll probably work with you on this and trash my own lib (which work fine tought, snif...).

I'll report in a few days ! By the way, nice work.

Edit: just a little question, it seems it currently only allow to create textures from rgba8 pixels buffer isn't it ?

I'm glad to hear that. Since the UI part of Kairy is very poor I will be happy to include your library in Kairy if you want =)
Yeah it supports only the loading of RGBA8 pixel buffers. But I can easily add other formats too if it's a problem.
(If you need to pass a RGB8 buffer just create a vector of Color and pass its data pointer to it. If you need something like RGB565 I can add it)


I'm so happy of your feedbacks and comments. If you want to ask something or point out a problem, feel free to do it. I'm open to everything =)
 

cpasjuste

Well-Known Member
Member
Joined
Aug 27, 2015
Messages
1,108
Trophies
1
Age
44
XP
4,481
Country
France
Hi _Nanni,

So I did find the time to play with it and to me its one of the best stuff we have on the 3ds. Your library is a lot more advanced than mine so .. my work is now useless :) People who know a little of c++ (which is my case, I mainly know c) should really take a look at it for games/gui. I ported my actual project (a 3ds menu) in a few minutes/hours.

So here is my report/requests/questions :

- I think that rectangleShape::create is broken on latest commit (undefined reference)
- How would you reuse the same texture (image?) for multiple sprite ?
- I would love to see the possibility to create textures from rgb8 (rgb24?) buffers (I was using this format for loading smdh icons as smea does :
https://github.com/smealum/3ds_hb_menu/blob/master/source/smdh.c#L27)
- I did loose some time trying to override the "onTouch" nodes functions before I understand it only work on "top level" nodes (ie. not a child). Its maybe for perfs reasons ?
- I'm new to c++ sorry for the "common question" but are shared_ptr free(ed) automatically when allocated/created for a second time or do we need to free them manually ? If I understand correctly the answer is yes.
- I think Box2D could be built only if needed for size saving (ifdef box2d?)
- Do you have a preferred IDE ? I actually use code::blocks, its crap.

I had a lot more (little/positive) reports yesterday but unfortunately my little brain forgot them, I'll comeback when they do comeback to me :)

So once again, awesome work/lib, I do really, really like it. I'll try to help when possible but my time is very limited :x

Thanks !
 
Last edited by cpasjuste,
D

Deleted User

Guest
OP
Hi _Nanni,

So I did find the time to play with it and to me its one of the best stuff we have on the 3ds. Your library is a lot more advanced than mine so .. my work is now useless :) People who know a little of c++ (which is my case, I mainly know c) should really take a look at it for games/gui. I ported my actual project (a 3ds menu) in a few minutes/hours.

So here is my report/requests/questions :

- I think that rectangleShape::create is broken on latest commit (undefined reference)
- How would you reuse the same texture (image?) for multiple sprite ?
- I would love to see the possibility to create textures from rgb8 (rgb24?) buffers (I was using this format for loading smdh icons as smea does :
https://github.com/smealum/3ds_hb_menu/blob/master/source/smdh.c#L27)
- I did loose some time trying to override the "onTouch" nodes functions before I understand it only work on "top level" nodes (ie. not a child). Its maybe for perfs reasons ?
- I'm new to c++ sorry for the "common question" but are shared_ptr free(ed) automatically when allocated/created for a second time or do we need to free them manually ? If I understand correctly the answer is yes.
- I think Box2D could be built only if needed for size saving (ifdef box2d?)
- Do you have a preferred IDE ? I actually use code::blocks, its crap.

I had a lot more (little/positive) reports yesterday but unfortunately my little brain forgot them, I'll comeback when they do comeback to me :)

So once again, awesome work/lib, I do really, really like it. I'll try to help when possible but my time is very limited :x

Thanks !

Hi, I'm so happy you appreciate my work =)

Now, about your questions:
- I think that rectangleShape::create is broken on latest commit (undefined reference)
Yes the create function with no arguments was missing. I've added it.
- How would you reuse the same texture (image?) for multiple sprite ?
If the texture you should reuse is loaded from a file, just load every sprite from the same texture file. The ResourceManager will use the same data for all textures.
If your texture is loaded from a buffer for instance, just set it to every sprite. (In the old version that was possibile with: sprite.getTexture() = texture. I've added the setTexture function now that's more intuitive). So if you have a texture and 2 sprites just do something like this:
Code:
Texture t(......);
sprite1->setTexture(t);
sprite2->setTexture(t);
- I would love to see the possibility to create textures from rgb8 (rgb24?) buffers (I was using this format for loading smdh icons as smea does :
https://github.com/smealum/3ds_hb_menu/blob/master/source/smdh.c#L27)
I've tweaked a bit the Sprite and Texture class. Now you can load textures from RGB8 pixel buffers.
- I did loose some time trying to override the "onTouch" nodes functions before I understand it only work on "top level" nodes (ie. not a child). Its maybe for perfs reasons ?
I'm sorry you have lost some time. It's just bad design, I will fix that
- I'm new to c++ sorry for the "common question" but are shared_ptr free(ed) automatically when allocated/created for a second time or do we need to free them manually ? If I understand correctly the answer is yes.
Yeah, it gets deleted automatically.
- I think Box2D could be built only if needed for size saving (ifdef box2d?)
If you don't use Box2D the size of your executable shouldn't increase. If you meant remove it from the library itself I don't think it would matter.
- Do you have a preferred IDE ? I actually use code::blocks, its crap.
I like Visual Studio with Visual Assist X. I think is even better than CLion.
 
Last edited by ,

cpasjuste

Well-Known Member
Member
Joined
Aug 27, 2015
Messages
1,108
Trophies
1
Age
44
XP
4,481
Country
France
Hehe thanks for the fast additions/fixes and reply, your so nice. I've just setup CLion before your post, its already awsome to me in combination with kairy (I'll probably test VS in the future but I'm not a fan of windows/devkitpro mysys stuff).

This is seriously a game changer, people really need to try/play with Kairy..

Count on me for further reports and maybe some help on github (not sure of that when I see how nice kairy is already :).
 
  • Like
Reactions: Deleted User

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    OctoAori20 @ OctoAori20: Not a lot, just relaxing