Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / [DBP] Dynamic Time-System

Author
Message
Mr Kohlenstoff
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Germany
Posted: 25th Aug 2007 03:04
Hey again...

For the game we are currently developing I created a function library (at lest the 20th..^^) managing ingame-time. I searched the forum and it doesn't seem as if there was a thread with such a system, at least not with as much functionality, so it might be usefull for someone.

So, what are the functions good for?
They can handle an more or less independent time, with a variable speed. Also there's a function to pause the time, so it needn't go on running while the player is in a menu for example.
Very easy to use, there's also a possibility of getting a possible sun-angle or height to simulate day-night-circles.

Functions:

Prefix is always "gte_" [Game Time-Engine], for all functions, variables, constants etc.

-gte_init() //Must always be called before all other functions!!!
-gte_update() //This one in your mainloop to update the time-value
-gte_pause() //This function should be called in or after a menu-routine when the time is not supposed to run
-gte_UpdateTime() //Updates the next 3 functions
-gte_GetHour$()
-gte_GetMinute$()
-gte_GetSecond$()
-gte_GetNewDay() //Returns a 1 if a new day has started
-gte_SetFactor(Factor#) //Defines the speed in which the time is running
-gte_SetTime(Hours,Minutes,Seconds) //Specifies the time of day
-gte_SaveSetTime(Hours,Minutes,Seconds) //Same like above, just with mod to avoid to high times

Intern:
-gte_FillNumber(Num,Decimalplaces) //Adds 0s to the beginning of numbers (6 -> "06")
-gte_SetCounter(CounterValue) //Sets the counter-value and updates variables

Variables:
-gte_SunHeight (float) //Height always between 2 (12:00, high) and 0 (00:00, low)
-gte_SunAngle (float) //Angle 0: Sun on top->midday(12:00), Angle 180: Night


I think that are the most important things..
If you have any questions, issues or whatever just ask.

Here the code with example:





And here just the functions:




Sopo the tocho
17
Years of Service
User Offline
Joined: 12th Jun 2007
Location:
Posted: 25th Aug 2007 04:12
Thank you! I might use it for my game, I thought in a real time (a real 24 hours day) system for my game however my game still in early stages but if use it I will give you feedback and comment the results!

Intel Pentium core 2 duo T6600 2,6 mhz 4mb, 4 gb ram 600 mhz ddr2, ATI X1650 radeon

http://www.freewebs.com/raycosantana/

Login to post a reply

Server time is: 2024-11-22 19:12:31
Your offset time is: 2024-11-22 19:12:31