Simulating the passage of time

For discussions about game development that does not fit in any of the other topics.
Post Reply
User avatar
OldRod
Posts: 1320
Joined: Sun Sep 20, 2009 4:26 pm

Simulating the passage of time

Post by OldRod »

My game is growing slowly and becoming more than I thought it would. I would like to add a calendar now, so that I can simulate the passage of time.

Characters will age (although you won't die of old age) and certain events will happen as time moves, etc.

I'm assuming this will require the implementation of a tick system and probably a cron to update it? Or is there another way?
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Simulating the passage of time

Post by Jackolantern »

Could you not figure out a formula to truncate the real-world time into the format you want it in? This could be done with the time() function and some formatting, and would be much less taxing than implementing a tick with crons.
The indelible lord of tl;dr
User avatar
OldRod
Posts: 1320
Joined: Sun Sep 20, 2009 4:26 pm

Re: Simulating the passage of time

Post by OldRod »

That's what I'm wondering... if there's a better way than a cron?

I suppose I could just store a start time for the world calendar some place permanent, and then just update everything from that initial start time...
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Simulating the passage of time

Post by Jackolantern »

Ohhh, yeah, I see what you mean for the calendar. You would need to have one master calculation to increment the date. Yeah, I guess a crons would be the best way I can think of. Depending on how you wanted the dates to run in your game, there probably is some way to work it out with a formula on a player-by-player basis, though.
The indelible lord of tl;dr
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: Simulating the passage of time

Post by hallsofvallhalla »

you could still use normal time without a cron. Just setup the start time int he database and have everyone's character age checked when they log in.

Example, you start the server at 1pm on Monday. Characters age 1 year every 24 hours. I sign up on tuesday at 5pm. I am 0 years old

so I log in at wednesday 6pm and the log in script checks how much time has past since my first sign up, 25 hours, i am 1 years old. then it checks the server start date. 49 hours, the world is 2 years old. It updates the appropriate settings for the players page.
towcar
Posts: 316
Joined: Wed May 20, 2009 2:16 pm

Re: Simulating the passage of time

Post by towcar »

Have a weather forcast that is connected to real life weather forcast. That way in the later months its colder, other months its warmer etc :P
Image
ZeroComp
Posts: 648
Joined: Thu Oct 29, 2009 8:48 pm

Re: Simulating the passage of time

Post by ZeroComp »

@towcar That is somewhat the idea of some mmorts's but they have random weather like if its raining you get more wheat or if its scorching hot your workers quit early causing resource production to go down and in an rpg I think you could come up with some pretty sweet idea like if its raining or snowing it cost more turns to travel etc etc
Coding-PHP, Javascript, C++, HTML, mySQL
Modeling/Art-Blender, GIMP
Games-Unity, Game Maker 8
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Simulating the passage of time

Post by Jackolantern »

@OldRod

I may have an alternative for you to use outlined in this thread. I actually used your case as an example :) It is an alteration on the "On view" method.
The indelible lord of tl;dr
User avatar
OldRod
Posts: 1320
Joined: Sun Sep 20, 2009 4:26 pm

Re: Simulating the passage of time

Post by OldRod »

I just saw that thread. I'll be checking it out, thanks :)
Post Reply

Return to “General Development”