Advertisement

architecture/stack ideas for 4x game with interactive console

Started by December 16, 2018 04:55 AM
6 comments, last by CrazyCdn 5 years, 8 months ago

Hello!  I'm working on an idea for an interstellar 4X strategy game, and although I have a lot of experience as a web programmer, there are a number of challenges here and I could use some help figuring out my "stack".  First, I'd like to use HTML/CSS for my display, even though I initially intend the game to be a single-player desktop game; the browser is a powerful design tool and responsive to changing window sizes, so I need to know how to do that. 

Second, the simulation is going to get big, possibly millions of rows of data tracking different objects and attributes.  I believe I'm going to need a real database as the backend.  Maybe PostgreSQL, because I know it and like it.  But -- I'd like to package and distribute my game as an "app" or "installer"... can I bundle a real database into it and yet keep that transparent from the user?  How?

Third, I'd like to build an interactive console into the game, so the user can issue commands to his planets and starships by command-line commands.  These would allow him to interact with game objects and perhaps write little scripts for them.  (My thinking is that this will allow him to automate the many little tedious micromanagement issues that happen in 4X games when the empire gets beyond a certain size later in the game.)  I have no idea how to implement this (either the console itself, or the commands and scripts that the user can enter).

I'm an experienced developer of web apps, and Python and Javascript are my best languages.  I'm very good at databases and data modeling.  But I've never made a program that downloads or is installed on desktop/laptop consumers and is packaged with all its dependencies as an app or executable.  To recap, my big architectural challenges are how to implement an HTML/CSS based screen to render my visuals, how to employ a serious database under the hood, how to implement a console and interactive scripting at runtime, and most of all how to package all these things into a standalone program.  I'm willing to learn a new language or platform for this, but would also be happy to be able to use what I already know.

So... any good ideas for me? 

Since no one's replied yet, I'll ask a couple questions.

I gather you intend for this to run in a browser, but correct me if I'm wrong. Assuming that's the case, what sort of display do you have in mind? (E.g. text, 2d graphics, 3d graphics, etc.) Apologies if the answer is clear from the context and I just missed it.

Advertisement

Thanks for helping me clarify.  My main display would be about 3/4 of the screen typically showing a game map (planets, stars, spaceships, and information) with a terminal/console on the right edge of the screen.  There would be buttons that open various modal screens from time to time.  To clarify, I'd like to use an HTML/CSS renderer, but don't want the user to have the experience of "opening up his web browser" to see it.  I believe there must be a library somewhere that would allow me to embed the HTML/CSS rendering engine into a window that I control.  I don't know what's the best way to accomplish that.

TL;DR: Libraries like you want exist, but are complicated and (likely) expensive. I would recommend going with a game engine and using their native UI libraries if possible, or finding a library with an existing integration into a game engine and use that.

Long version:

Unless you want to get down and dirty with game engine programming, you'll likely want to use an existing game engine (Unity, Unreal Engine, Ogre, there's a myriad of options depending on your requirements) in addition to an HTML UI library.

A separate concern is your desire to use HTML for UI design - there are various services out there for exactly that. Some examples that I know about that use familiar HTML + Javascript for UI layout and functionality:

  • Scaleform [Paid] (aka the Old Guard of this style - used by Blizzard in various games like Starcraft II iirc)
  • Coherent Labs' various products [Paid] (aka Scaleform's more modern alternative)
  • Ultralight [Free for individuals and small Indies] (aka the lighter-weight open alternative to Scaleform and Coherent)
    • Currently in Beta
    • Not as widely supported (no existing engine integrations I know of, you need to integrate it yourself in C / C++)
    • Missing lots of features in comparison to Scaleform/Coherent
    • https://ultralig.ht/
  • There are probably more, but those are the ones I know of. Maybe they'll be a good start for Googling

As to creating an in-game console, I don't see why you couldn't create that using HTML/Javascript (the visual aspects anyway). You basically want to give users a basic 'scripting' API that your console understands - when they enter a script / command you call an appropriate function in your API (the API itself could even be Javascript, but you'll have to somehow bind that API to an underlying game engine or game functionality to make things actually happen).

  • Example: > base.build scout 4
    • Tell the base object to build 4 scouts
    • Somehow you've hooked up a little interpreter that translates that into actual function calls in your API that do the equivalent to the user pressing the 'Build Scout' button in the base UI 4 times

Warning: From my personal experience (and some minimal communication with industry devs who've used Scaleform/Coherent stuff) there are some possible issues with building game UI this way.

  1. A full HTML/Javascript rendering engine is a relatively heavyweight thing, and you can easily run into performance issues with complicated UI.
  2. Integrating these systems into your engine / codebase / application can be a relatively complicated task requiring knowledge of C++.
  3. Expensive! (For the Big 2 anyway)
On 12/17/2018 at 6:11 AM, Valakor said:

From my personal experience (and some minimal communication with industry devs who've used Scaleform/Coherent stuff)

Some of my experiences using Scaleform were that it is very easy to produce memory leaks with Scaleform and so I suggest against it! It breaked us the neck when porting a game to PS Vita using Unreal Engine.

The other alternative is to use Electron and .Net/C# as your way to go. Electron-Edge hosts a .Net/C# Assembly in a NodeJS context so you could run HTML/CSS and Javascript in a Chrome based browser context and additionally call functions from javascript in the .Net Assembly.

Building a console is then easy as calling certain function from your script that pushes a string to the .Net backend Assembly and response using some events

Quote

Second, the simulation is going to get big, possibly millions of rows of data tracking different objects and attributes.  I believe I'm going to need a real database as the backend.  Maybe PostgreSQL, because I know it and like it.  But -- I'd like to package and distribute my game as an "app" or "installer"... can I bundle a real database into it and yet keep that transparent from the user?  How?

It's hard to simplify installation of a full up database engine like postgres or sqlserver. They are engineered with a lot of features that support concurrency, high availability and security which makes ease of use and installation hard to do.

The alternative is a file based database like sqlcompact or sqlite. They sacrifice the features I just mentioned for ease of use and simplicity. Very good for caching data though for a single app (this is why every Android app uses it's own sqlite file database for persistent storage).

I would suggest storing your big rich data set you speak of on an internet facing server. When a user installs their game it shouldn't be hard to install sqlite with it. Then sync down what the game needs from the internet database to the sqlite database. It'll give the user the cache they need without forcing them to jump through hoops to install a real database.

Advertisement

If your installer suddenly launches PostgresSQL installer most people are going to exit out and either want their money back or warn others off to be honest.  I'm personally going to wonder if you're also installing a miner with your program to boot :)  About the only 3rd party installer most people would be okay with is like DirectX from Microsoft to be honest.  If you're doing an online game and you're maintaining a remote database that is completely different though.  It was not very clear in your post.

"Those who would give up essential liberty to purchase a little temporary safety deserve neither liberty nor safety." --Benjamin Franklin

This topic is closed to new replies.

Advertisement