Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My team is planning to create a simulation game using Javascript, CodeIgniter and MySQL for the backend.

It will be mostly click based, ie: There will be buttons for activities like Eat, Play, Study, etc, and in the game environment, one day will contain 3 phases, day, noon, night . And for each phase, users can pick between those activities and those activities will increase certain character parameters (Intelligence, Focus, Fun, etc) then the game will progress to the next phase. Once it's night, the game will progress to the next day.

So I need feedbacks on how to saving the game progress. Here's what I had in mind :

There will be a table for Users (obviously) that will contain users' data including the parameters/stats, money, etc. Do you think the stats etc must be separated to another table so there will be a history of stat increases?

For the saving, I'm thinking of using a Logs table that record every activity is by users. So if in day 1 phase 1 (phase day) the user picks Eat, I will insert to this logs table more or less like : user_id = 1, day = 1, phase = 1, activity = eat. So for example when the user stops playing and exits the game after day 1 phase night, the database will have :

user_id = 1, day = 1, phase = 1, activity = eat
user_id = 1, day = 1, phase = 2, activity = play
user_id = 1, day = 1, phase = 3, activity = sleep

And when they continue the game, I will read from this table and get the latest row of this user_id, and after checking that the latest row is day 1 phase 3, the game interface will display day 2 phase 1. However, this means that the phases for a day must be fixed from the start, so I can't include, for example, random additional time phases outside these phases (think of it as an extra opportunity to increase the stats).

So what do you think? I hope the explanation is clear enough.

share|improve this question
up vote 1 down vote accepted

Because of the problem you mentioned I would recommend you to simply keep track of the current day and phase of the user separately, instead of trying to compute it from the Logs table everytime.

The simplest solution is just adding these fields to the Users table:

user_id = 1, current_day = 30, current_phase = 3, other_stats...

That makes things easier than the process you described and you just need to update those values whenever there's a phase change. Other than that, it seems okay to me. Also...

Do you think the stats etc must be separated to another table so there will be a history of stat increases?

If the only way that users can increase their stats is through activities, then you already have a history of stat changes in the Logs table. Just keep the total current stats on the Users table for ease of use.

share|improve this answer
thank you very much! didn't think of that! – Henson Jan 7 '12 at 7:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.