Jump to content

  • Log In with Google      Sign In   
  • Create Account

Is separate past/present game state always necessary?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Nairou   Members   -  Reputation: 418

Like
0Likes
Like

Posted 23 August 2012 - 06:39 PM

By game state, I just mean data, such as object positions and attributes, active players, etc.

I know for FPS games, having separate past/present (or, more likely, current/next) states is useful, because things happen so fast and you want to allow multiple things to happen at once rather than sequentially. For example, two players shoot each other at the exact same time. If you have only one game state, player 2's shot could get ignored, since it gets processed after player 1's shot, by which time player 2 is marked as dead. If you have separate current/next game states, the shots fired are read from the "current" state but the players are marked as dead in the "next" state, which doesn't go into effect until the next cycle.

However, for other games such as RTS games, things happen at a much slower pace, and I can think of situations where separate game states might be weird. For example, two units are gathering a resource. If you have separate states, and both units happen to arrive at the resource at the same time, they will both get it, since there is no immediate knowledge if the resource being removed. Whereas with a single game state, one of the units would grab it and the other would find it missing and need to look for another.

I always assumed separate game states would be necessary, no matter what, to maintain the integrity of the simulation, but now I'm not so sure if that is true. Thoughts?

Sponsor:

#2 Ravyne   GDNet+   -  Reputation: 7330

Like
0Likes
Like

Posted 23 August 2012 - 07:06 PM

It's really a design issue more than anything -- double-buffering the state is one way of dealing with it, a careful ordering of update events is another, keeping things decoupled is yet another.

For example, most projectiles in most FPS games today aren't instantaneous (meaning, they travel and are affected by drop, and aren't just a simple ray-test) so they should be entities in their own right, and continue to exist even if the player that fired them has died. That's an example of de-coupling.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS