Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Tilebased Game Engine (OpenGL)  (Read 2774 times)

JCD-Bionicman

  • Escaped Lunatic
    • View Profile
Tilebased Game Engine (OpenGL)
« on: August 02, 2019, 11:40:20 pm »

I'm in the planning phases of a tilebased game engine in OpenGL. I think OpenGL is a good choice because of how it is cross-platform and powerful enough for this purpose. I want to design the engine to be used to make new games in the same style as DF. I don't have much experience in these kinds of games other than DF, so I'm wondering if there is anything that I should know about. What existing engines for this type of thing are out there? What features would programmers like to have in an engine like this?
Logged

ollobrains

  • Bay Watcher
    • View Profile
Re: Tilebased Game Engine (OpenGL)
« Reply #1 on: August 03, 2019, 03:25:44 am »

well if u want to get experience, exposure or a look at how complex code works just check out the code base for cataclysm dark days ahead, it has a massively active community and its all open source (id also for procedural generation suggest u check out pioneer space sim codebase as well)
Logged

Virtz

  • Bay Watcher
    • View Profile
Re: Tilebased Game Engine (OpenGL)
« Reply #2 on: August 03, 2019, 05:19:30 am »

As far as existing engines go:

Unity comes with built in tilemaps (rectangular, isometric or hex), is fairly portable between different platforms, has a rather large community and a big library of assets (including scripts), both free and paid. You script it in C#, which is high-level heaven and has extensive use outside of the engine. I guess its downsides are that it takes work to optimize performance, it feels really heavy to be doing pure 2d with (it is a 3d engine first), it doesn't deal with pixel art well out of the box (requires some paid assets and/or know-how to work right, last I checked), and it can feel buggy at times.

There's BYOND, which is mostly meant for tile-based multiplayer games. It's got its own scripting language and graphic formats with editors. People complained about performance with this one, but that might just be because their one experience with it was Space Station 13, which does some insane things for a multiplayer game. I'm also not very familiar with what's changed in the last 10 or so years since I've last looked at it.


I'm not sure about making your own engine without a game on top of it, though. The market's fairly saturated with engines that've been developed for over a decade, and from a developer's point of view, without some truly amazing and comprehensive show of potential results, it is a huge risk to go into a little known engine and pray you get the technical support for what you want to do with it.
Logged

JCD-Bionicman

  • Escaped Lunatic
    • View Profile
Re: Tilebased Game Engine (OpenGL)
« Reply #3 on: August 03, 2019, 09:32:11 am »

well if u want to get experience, exposure or a look at how complex code works just check out the code base for cataclysm dark days ahead, it has a massively active community and its all open source (id also for procedural generation suggest u check out pioneer space sim codebase as well)

Very cool stuff. I don't think I'll add much to the engine in regard to procedural generation. I really just want a general library that handles drawing sprites on the screen in a grid and other basic game functions. These are my "goals" but they are not set in stone yet:


  *  Designed for games that use roguelike tilesets like NetHack, Rogue, and Dwarf Fortress
  *  Well optimized in C++ (with eventual support for any .Net language)
  *  Cross-platform with OpenGL (and maybe Vulkan later)
  *  Prebuilt (and optional) user tileset modding system
  *  Helpful tools for things like window resizing and GUI interfaces
  *  Integrated engine utilities like time management and ECS

The idea is that this will be a library with the basics that every tilebased game needs anyways, so that people can skip making all this basic stuff and get straight to work on the meat of their projects. Also, its going to be open source, and designed so that you can customize it to your hearts content.

As far as existing engines go:

Unity comes with built in tilemaps (rectangular, isometric or hex), is fairly portable between different platforms, has a rather large community and a big library of assets (including scripts), both free and paid. You script it in C#, which is high-level heaven and has extensive use outside of the engine. I guess its downsides are that it takes work to optimize performance, it feels really heavy to be doing pure 2d with (it is a 3d engine first), it doesn't deal with pixel art well out of the box (requires some paid assets and/or know-how to work right, last I checked), and it can feel buggy at times.

There's BYOND, which is mostly meant for tile-based multiplayer games. It's got its own scripting language and graphic formats with editors. People complained about performance with this one, but that might just be because their one experience with it was Space Station 13, which does some insane things for a multiplayer game. I'm also not very familiar with what's changed in the last 10 or so years since I've last looked at it.


I'm not sure about making your own engine without a game on top of it, though. The market's fairly saturated with engines that've been developed for over a decade, and from a developer's point of view, without some truly amazing and comprehensive show of potential results, it is a huge risk to go into a little known engine and pray you get the technical support for what you want to do with it.

Unity is too generalized. I want to make an engine specifically for tilebased games, and to make it myself from the ground up.  The engine will be much more specific to this genre, and thus easier to use and faster to develop. Also, it should be a bit faster running. Finally, stuff you make in Unity is not royalty free, which is not optimal for most people (Toady included). The engine I am working on will essentially be a public rendering engine like the one Toady designed for DF with a few differences: it wil use OpenGL instead of DirectX, and it will come many tools designed for generalized use across almost any tilebased game.

BYOND is neat, but I really want to make my engine be a static C++ library so that you can have complete control over the game as low level as possible. It also would be possible to make dynamic link libraries for C# and other .Net languages. Instead of having a custom language like what BYOND has, I would use already existing languages that are powerful and well supported, allowing for the inclusion of libraries and other stuff designed for these languages and thus increasing what programmers can do with the engine.

I could possibly make an IDE, but this is a long term possibility.  For now, I just want to get a working library that people can look at and use as soon as possible.
« Last Edit: August 03, 2019, 10:00:42 am by JCD-Bionicman »
Logged

Malus

  • Bay Watcher
    • View Profile
Re: Tilebased Game Engine (OpenGL)
« Reply #4 on: August 03, 2019, 10:31:08 am »

Getting sprites sliding along a plane with OpenGL isn't hard at all. I'd argue that Unity is massively overkill for this purpose. Unity does offer several advantages: live code editing/reloading, a great editor that is easily extensible in the same language you're writing your game in, and a fantastic ecosystem with tutorials and implementations of practically everything you could possibly imagine. C# also means mod support is powerful: modders can patch assemblies and do anything they want -- OTOH, I can't imagine asking modders to compile C++ .dlls, and that sounds like a cross-platform nightmare anyway, so you'd need some kind of scripting language if you still wanted to offer modding support on the level of Unity's, which would most likely incur a runtime performance hit.

Since we're talking DF-likes, Rimworld is an obvious point of reference: take a quick peek at the Steam workshop and see what modders are doing. I'm not convinced most of that would be possible without C# (or at the very least, another language that compiles to bytecode.)

Live code reloading is totally doable in C++ though, and something that should 100% absolutely be a part of your engine from day one like in https://nlguillemot.wordpress.com/2018/02/16/simple-live-c-reloading-in-visual-studio/. It's a massive ergonomics win: just being able to see results immediately makes C++ as painless as most interpreted languages.
Logged

JCD-Bionicman

  • Escaped Lunatic
    • View Profile
Re: Tilebased Game Engine (OpenGL)
« Reply #5 on: August 03, 2019, 10:49:28 am »

...

If you are concerned about mixing C# with C++, know that Unity is written in C++ deep down even though you use C# when making games with it. There are games that do this for modding. It wouldn't be hard to have something similar for this engine.

Live code reloading is something I will look into. Thanks for that tip.
Logged

JCD-Bionicman

  • Escaped Lunatic
    • View Profile
Re: Tilebased Game Engine (OpenGL)
« Reply #6 on: August 11, 2019, 08:23:52 pm »

Small update here. Nothing to show yet, but I am making good headway on a texture paging system. I have realized that this is the thing I need to get done first. In a nutshell, the system will be able to read image files from the disk (png, bmp, psd, jpg, gif, etc using stb_image) and then adjust them by taking account things like gaps between each frame and offsets that you can specify. The system will then combine all of these sheets together into texture pages which are loaded onto the GPU as single large textures for optimal preformance. You could even save each separate sprite in their own files, and they will all be put together in the end by this system. I am considering doing parts of this process on the GPU via compute shaders, but I will just do it on the CPU for now because it seems a bit overkill for when I'm just starting this. When the game runs, each tile on the screen (two triangles together to make a square) will be rendered by changing the UV coordinates of each tile to the sprite locations on the texture page. I also plan on adding a coloration system where you can colorize tiles kinda like how done in DF, which will be handled in the fragment shader on GPU of course.

With this system, sprites of various sizes will be supported. This will work great for when I eventually plan to add multi-tile sprites and stuff like that. Of course, all of this complicated stuff will be easy to ignore for the average developer who just wants to make a cool dungeon crawling tile-based game and doesn't know much about OpenGL.

Out of all the names I have heard so far, Rougescape sounds the best to me. I don't think its taken already by anything else. Anyone has ideas on this, let me know.
« Last Edit: August 11, 2019, 08:30:31 pm by JCD-Bionicman »
Logged

JCD-Bionicman

  • Escaped Lunatic
    • View Profile
Re: Tilebased Game Engine (OpenGL)
« Reply #7 on: August 14, 2019, 08:04:31 pm »

Lots happened in real life for me and has kept me busy. Still interested in doing this project. Also looking for people who might want to help or provide some guidance for certain things. Of course, knowledge of OpenGL or C++ would be helpful. Thanks!
Logged

Dark One

  • Bay Watcher
  • 'What do I care for your suffering?'
    • View Profile
Re: Tilebased Game Engine (OpenGL)
« Reply #8 on: August 20, 2019, 11:27:03 am »

I'm working on a similar project right now, though it's going to be in an isometric perspective (Diablo 1-like dimetric projection) and I'm using C++, SFML, bits of OpenGL and MinGW compilers. PM me if you'd like to get in touch.