Weekly Update #13 – Data Persistence and Levelling Mechanics

These weeks are zipping by rather quickly, don’t you think? We’re 13 weekly updates into full production on this project. That puts us about 30% of the way through development. That feels about right to me, with the game engine coming along nicely, place-holder menus present, data inputs functioning, and the game generally feeling playable.

Here’s what I’ve accomplished this week.

+ Persistent data storage
+ Basic Experience Point and Levelling mechanics

Data Persistence

Data persistence is an important part of most, if not all, games. My games up until now have been very basic with the only persistent data required being a level number, and points value to continue from. NSUserDefaults, whilst not intended for this, has been more than adequate.

The development of Coffee Cellar lead me into the murky world of Core Data. Core Data abstracts the data models from the storage method. I ended up using it in conjunction with SQLite3 and it worked quite nicely (Especially since I had relationships between coffees, tasting notes, etc).

For this game I decided to ask my peer group on twitter and got a decent number of opinions. Suggested solutions included plist’s, the NSCoding protocol, and JSON. These solutions all have their pro’s and cons.

The data I want to persist in this game is…

  • The players character level, experience points, and class.
  • The inventory – quantities of each tile and amount of “gold” (This is complicated slightly by the crafting system)
  • Quest Data – completed quests and quests in progress
  • The levels that have been completed

Its not a trivial amount of data but neither is it absolutely huge (something you can’t know without knowing the underlying solutions for each of those concepts). The solution I’ve opted for is a single plist (Property List). A plist can only contain a small number of data types but they are more than sufficient for my needs and they tie in well to the solutions for the systems mentioned above. I also use a plist for all of my level data (its the output from my level editor).

There are a couple of downsides to using a plist. All of the data is loaded into memory – this isn’t a problem for the persistent data because I know its maximum size up front (and its not storing huge amounts of data). The levels are another matter and I may end up splitting them into individual plist’s – I’ll run performance tests to make that decision.

The other issue is that a plist is not obfuscated in any way so, should someone wish, they have easy access to the data (and therefore easy access to modify it).

That last point is really a non-issue for me right now. This game does not have a competitive element to it (I’m not planning on leaderboards). I figure I can use a slightly different concept for score data if I do ever feel the desire to incorporate some form of leaderboard.

So, for now, its a singleton writing to, and reading from, a single plist.

Character Levelling

PPRPG is going to have the concept of levelling-up your character. I wan’t to keep it simple so that its totally transparent to the user as to why they gained a level. I also want to ensure that the complexity fits with the iPhone as a gaming device (i.e. people playing on the go).

You’re character will not have any attributes other than experience points. No health, stamina, strength, charisma, and what not – they’re too complicated for a game that you play when you have a few moments to spare. That’s not to say the game won’t have depth (I just don’t want statistical depth).

(This image is just to show you the concept. It won’t be this ugly in the finished game.)

So, you’ll start off as a level 1 character with 0 experience points.

You’ll be show how many experience points you need for the next level. This is currently calculated as ((current character level * 200) + 50). Adding a static value to the simple multiplication formula ensures that the early levels take a little while to reach, with this effect becoming less relevant in later levels. These values will be tweaked once I have the content in place. I may have oversimplified this but I think it will be easier to tell once I have my 5 level demo.

Tiles in the game have a number of experience points assigned to them. You are awarded these points when you pass over them in the game (that is, you need to have successfully placed them on the board and been able to use them). The experience points will vary dependent upon the tile type and the widget applied (see a future post on crafting :). The experience points you’ve earned in the current level are displayed during gameplay (This shows you what you’re playing for).

If you successfully reach the level exit, you keep those points (otherwise they are lost).

You are presented with a screen that shows experience points earned, accumulated total experience points, current character level, and experience points needed for the next level.

Levelling up will give you a choice between 3 perks. These will be randomly generated but influenced by your current level. Potential perks are likely to include a special tile type, a quantity of basic tiles, widgets, a decent amount of gold, a new tile queue slot. These aren’t defined yet.

I’m also toying with the possibility of rewarding the player with something more minor (gold and/or basic tiles) for simply reaching the exit.

Balancing all of this is going to be a challenge. That’s another reason to keep the formula’s simple. The more complexity added here, the more difficult it will be to create a stable playing experience throughout the full game, across a wide range of players.

I’m also thinking about grinding. I think ideally I want to avoid it (especially with no stats to level). The easiest way to do this is to prevent the player from earning experience points when replaying completed levels.

Something else I need to consider is a level cap. This is essentially an artificial system for prevent overpowered players. Again, without player statistics, I’m unlikely to need to do this.

Level 1 Done

So, I’ve reached my level 1 milestone. Its now onto level 2 which means a new tileset, the loot system, and the quest system.

A few asides that I need to work on. The menu screens need an overhaul since I now dislike them severely. I also feel compelled to get some placeholder sound effects into the game. Oh, and the background for level 1 (or that tileset) is horrible so I’m going to rework it.

Stuff I liked this week

I totally omitted this the last few times. Oops! Anyway, here’s some interesting stuff from around the internet.

Thanks for reading. More Soon.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.