Nearly playable

I’ve got an extremely short episode written that contains what I think is most of the elements to the game. Right now I’ve got a sort of playable thing happening except for variable text. There are variable options and blurts said by your bridge crew as well as random ones, but the text displayed to the player isn’t variable yet.

A gif to demonstrate.

Authoring tool 90% complete and GUI animation

This past week I’ve worked some more on the authoring tool. I think it’s now in a state where it’s fairly usable. It probably needs a lot of work if it was ever to be a product, but right now I’m just considering it like a modding tool. The modding tools I’m used to were all buggy (like the Battlefield 2 map editor), so I don’t see it as a big deal for now.

I’ve also implemented an Animation system in the UI.

Authoring Tool

I worked some more on the Authoring Tool. Hopefully the interface is easy to use and doesn’t get in the way too much. Once I really start using it, I might find some annoyances in it that I’ll want to fix.

The interface for creating Episodes and Events

Space Adventure

Now that I finished Pong, over a year ago, it’s time to work on the next project. Space Adventure.

I’m calling it Space Adventure because I’ve not worked out a better name for it yet. Maybe I’ll call it “The Last Boundary: A Space Adventure” or something like that.

It is a game idea that I had while watching Star Trek: The Next Generation. Wouldn’t it be cool to play a game that’s like Star Trek? I’m not the only person who’s ever thought this because there’s a heap of Star Trek games. I’ve played a bunch. But it was never really like Star Trek, you know? It was always you conducting missions and getting into space battles, or it was leading an away team or something.

There was never a game where you played as the Captain, or the bridge crew, and you found a strange new phenomena and it turned out to be a relic from an ancient civilisation and it spawned a computer virus that infected the ship and you have to use diplomacy on a derelict AI satellite to convince it to disable the virus and return control of the ship back to you.

That’s what my game is about.

Continue reading “Space Adventure”

Architectural Problems so Pong

I’ve found that I’ve programmed myself into a bit of a corner.

The issue is that my game engine, despite my best efforts, is architecturally bad. I think this is probably a regular occurrence for a first-time effort of a project this large. This poor design came about despite having read Design PatternsGame Engine Architecture and Game Programming Patterns.

I think this was inevitable. Reading books such as the above, and I highly recommend them all, isn’t the same as applying the patterns in practice. There are many patterns throughout the code, don’t get me wrong, but I think the logical separation of state isn’t as logical as it should be.

So; having stepped back from the code and given it a very thorough critical review… it needs to be re-coded in large portions.

It’s not only the architecture that’s a problem, I think my build chain is poorly designed. Having known no better, I started as one large project; whereas each component likely could’ve been it’s own project, each outputting .dll files.

Further to this; I’ve just been programming and testing as I went along. Unit Testing, something I’ve never done before, is probably something I should look into. It makes complete sense, by enforcing unit tests on myself, I’d naturally enforce the decoupling of systems. I’m concerned about the amount of time and effort that needs to go into test driven development, but having never undertaken it, I’ll look into it.

Another problem I’ve found is that I didn’t architect the engine for networking. Something that I’ve learned the hard way, needs to be designed into the code up-front.

So; in order to begin applying patterns, networking, and possibly unit testing into my code; I’ve decided to make a 2D network-multiplayer Pong clone. Should be simply enough to code the actual game; but where it should get interesting is in applying network into the core of the engine.

I’ve designed it already.

Pong Architecture

Pong is probably too simple to really apply Design Patterns; however there’s the few usual patterns that you’d expect in a game, really just Update and a Game Loop. However, what I’ve done here is focused on the separation of game data from the rendering and looked heavily into Networking.

For the rendering, I’ve decided to use SFML rather than my own engine code. SFML is great, it’s quick and easy and does 2D brilliantly. The reason I’m making Pong isn’t for the graphics, so I had no desire to go that deep.

SFML also has a great networking abstraction layer which I’m using for Pong. I’m not too worried about ensuring packets are delivered correctly, so abstracting that out works well for me.

I’ll probably go back and replace SFML with my own code later.

I’ve read over the Multiplayer-Neworking information on the Valve Developer Wiki a few times to learn about how to implement my Pong game. The reason I’m looking so much into Valves information is that their networking is for fast-paced action games. My Pong game is going to use the mouse to control the paddles, therefore it is fast-paced.

This has led me to determine that a Server-Client model won’t work for Pong. I really wanted it to, as that’s the sort of common way big games do it; but I can’t see how that would work for me. One player, the Listen-Server player, would always have an advantage. In a one-on-one game, I don’t think that’s fair, sure it works for 16v16 or something, but not 1v1.

So instead, my Pong game will be a bit… funny. Whoever is currently in “possession” of the ball will be the “server”, and whoever is waiting on the ball will be the “client”. So, as soon as I hit the ball and return it, my opponent will now be deciding the game state.

This allows each player to locally control the very time sensitive hit-detection etc. For a real game, it would be disastrous. Cheating would be rampant. But no one is going to cheat at my Pong game, I’m sure.

Signed and Unsigned Integer Comparisons

Occasionally I find that I need to compare signed and unsigned int values. This understandably throws warnings. So I wrote the following helpful functions to safely compare the values when needed. Obviously I try not to, but there’s times when I’m forced to.

It allows me to compare signed int and unsigned int values as either the left or right parameters.

Bringing bits together

I’ve now got what’s shaping up to be a pretty good UI system:

  • The UI styling is defined via data in space-format (JSONish)
  • The layout of the UI is then defined by a second space-format file:
  • Then the “actions”, in the case above the single button, are defined in a space-script file:

    Basically, the UI Layout says the button will execute the function named “SeedButton”. That function creates a new button that will execute the function named “OutputNum”.

This all works well, surprisingly. The only gap is that every “execution” of the script, or execution of a function in the script, is completely independent of any other execution. Meaning that I can’t store information between button presses, at least not in the script.

To get around this, I’ll likely implement a key-store as a regular Engine Function so that scripts can store information for later use, even when it’s only ever needed by the script.

I didn’t think of this before because I only ever imagined scripting things like enemy behaviour, which would just access and set what it needed to.

A Recursive Variant Type in C++

Because one of my goals is to rely on as few external libraries as possible, I am not using Boost. As a result, there comes times when I need to roll my own, extremely useful, library-like code that isn’t a part of the C++ standard yet.

One of these, is the Variant. A tagged union / discriminated union / sum type, that allows you to store multiple data types in one section of memory. A sort of type-erasure gimmick.

I need a type like his for two reasons so far. The first is that my scripting language, space script, is quasi-type safe. You define variables using your usual data types, but any variable type can be cast to any other type.

I did it this way mostly because I was curious to see how a language like that would behave. Probably not the best idea.

I’ve also allowed my Variant type to be recursive. This means that it can contain members of itself. I’ve done this specifically because my data format, space format, is JSON-esque, and basically every node can contain any number of numbers, strings and other objects etc. That’s the second reason I need a variant type.

This took me quite a bit of screwing around to get right. A lot of the code for the base Variant was taken from someone else’s code that I found online. This code was fundamentally broken though; so I’ve fixed it up and allowed for recursion.

I’ll probably do a write up on this at some point. I like it over the boost::variant primarily because I don’t want a never-empty guarantee. I can’t imagine why I’d want a type that doesn’t allow for null-states.

EDIT: Fixed up some of that code.

EDIT 20/05/2016: Fixed up some more of that code.