Mad Skills

Sorry for the lack of updates lately, we’ve been working on Prisonscape a lot in last few weeks, but this has been mostly on optimizing the code, creating new graphics and writing the story line and jobs. I’m very excited of some of the stuff we’ve come up lately. We came up with a battle system that has something original and also something borrowed from great older games. We also developed a skill system where the player can train skills that you usually need in a prison environment, and of course some extra skills that might come up handy later in the game.

Skills have different levels, so for example Fighting 2 comes after Fighting 1 and so on. Each skill is learned once you meet the training point requirements of that particular skill. Each week you get a certain amount of training points based on your basic statistics (Strength, Agility & Intelligence). Some skills (for example Fighting) require multiple statistics, and in these cases the lowest score is used (the lower score is slowing your training down). Some inmates can train you which gives you a small boost to your training points. Of course the best way to train is to practice the skill in a real-life situation, so if you want to be an effective fighter you have to fight a lot.

Here’s an example:

The player wants to train Fighting 1 which gives him some new attack and defense modes. Fighting 1 requires 500 training points (arbitrary value) and the character has a Strength value of 40 and Agility value of 45. We use the lower value for determining the weekly training points, which is 40 in this case. For two weeks he practices on his own and gets 80 training points towards getting to his goal. He gets into a fight, and gets 40 from it in addition to the weekly training points (40). He now has gathered 160 training points after three weeks. After this he finds a trainer, who gives him a multiplier of 1,5 to his weekly training points. It would take 6 more weeks to get Fighting to level 1. These numbers are of course arbitrary and will be subject to heavy tweaking and testing, but this is the basic mechanism of training skills in Prisonscape.

Here are some skills that we’re planning on putting into the game:

  • Reading / Writing
  • Fighting
  • Intimidation
  • Persuasion
  • Electronics
  • Computers
  • Pickpocketing
  • Lockpicking

We also got some new areas done with David and Tuomas has been working hard on the battle system. On the next blog post about game mechanics I will hopefully give a comprehensive look on that.

Engine work, part 1

As Pekka mentioned in the last post, I have been working on the engine features for the last month. I basically rewrote the game loop and collision detection system from scratch because the earlier versions weren’t cutting it.

I noticed how the animation was not smooth at all and tracked the issue to bad game loop design. After identifying the problem, I spent a good amount of time researching on how to build a proper game loop. I guess every programmer will eventually end up reading the ‘Fix Your Timestep!’ article by Glenn Fiedler. He does a fantastic job of going through different game loop implementations and explaining why they work or don’t work. You can read the article here. Long story short, I implemented a version of the semi-fixed timestep game loop and it’s working nicely!

Next up was fixing the collision detection system. The earlier version worked fine, but things started to go south when I implemented partial collisions in the game. The partial collisions allow us to define regions of a tile which are not accessible, instead of blocking the whole tile. For example, we can create walls the player can walk right next to, giving the game a sense of depth. Because I didn’t refactor the old collision detection system properly, weird glitches and bugs started appearing when new tiles with partial collisions were created.

What followed was an exercise in rewriting the collision detection system again and again. I have to admit it was really frustrating when you thought you were about to nail an implemention only to realize it would crap out in certain special cases. I could sense when a certain version of the system wasn’t going to work because I started adding a lot of special cases in the code. And sure enough, the special cases were not tight enough and the system would break.

For example, one of the older versions looked like this.


Separate external lines

The problem with this system was that the player would get stuck at the edges between the tiles. I tried working around this issue in several ways but all of them ended up breaking the collision detection system in some way or another. Finally, I found out that the way to handle this issue is to collapse all the external edges into combined lines. This fixed the ‘getting stuck’ issue nicely. Having this implementation also enables you to have arbitrary sized shapes in your engine (like we have with different sizes of rectangles). You can see the new collision lines below.


Collapsed external lines

Here’s the algorithm I came up with:

Loading the level

* First find all the external edges in the tiles
* Then sort the edges into horizontal and vertical edges (we only have rectangles in the game)
* Detect adjacent edges by comparing their start or end point. If the edges are combined, keep the combined line and remove the lines you just compared.


* Collide the player rectangle(s) against the lines
* Detect if the lines have a corner point and if the player needs to resolve a corner collision
* Resolve collisions, adjust the player’s x or y position back to the previous position

This is just a high level view of the algorithm, but I think it illustrates how the collision detection works in general.

Anyways, I guess that’s enough of tech stuff for now. Next up, I’ll start reworking the battle system. Until next time, stay classy San Diego!