1. Get GamePlaying Time

Hello All,

I am currently working on a RPG Game. I am trying to figure out how I would get the game playing time. As in seconds, minutes and hours. I have an idea, however I am puzzled as to how to go about it. Any examples would be appericated, if needed I can show my code. Below is my code. I have the variables, but I'm not sure how would I go about using them to get the game playing time. As I said any examples would be great.

Another question unrelated to this. Every time I try to use Judiath Evan's IDE, I get this error that says it cannot find autoexec.bat, IDE will not run without it. I'm running under Windows Vista Home Premium. 64-Bit.

----------------------------------- 
integer MiliSecs,Secs,Mins,Hrs 
atom DeltaTime 
sequence Display_Clock 
atom LastTick,CurrentTicks 
atom Ticks,TotalTicks 
atom GamePlayingTime 
atom BattleTime 
atom ShoppingTime 
atom ClockGfx 
sequence ClockRect 
atom ClockWidth,ClockHeight 
------------------------------------- 
procedure GameTime() 
	 
end procedure 
-------------------------------------- 
new topic     » topic index » view message » categorize

2. Re: Get GamePlaying Time

Lone_EverGreen_Ranger said...

I am currently working on a RPG Game. I am trying to figure out how I would get the game playing time. As in seconds, minutes and hours. I have an idea, however I am puzzled as to how to go about it. Any examples would be appericated, if needed I can show my code. Below is my code. I have the variables, but I'm not sure how would I go about using them to get the game playing time. As I said any examples would be great.

The easiest thing is probably to note the start and stop times using now(), and then use diff(), which returns the number of seconds between the two. You can keep adding seconds for subsequent sessions, and then convert that sum as needed for display purposes.

Matt

new topic     » goto parent     » topic index » view message » categorize

3. Re: Get GamePlaying Time

mattlewis said...
Lone_EverGreen_Ranger said...

I am currently working on a RPG Game. I am trying to figure out how I would get the game playing time. As in seconds, minutes and hours. I have an idea, however I am puzzled as to how to go about it. Any examples would be appericated, if needed I can show my code. Below is my code. I have the variables, but I'm not sure how would I go about using them to get the game playing time. As I said any examples would be great.

The easiest thing is probably to note the start and stop times using now(), and then use diff(), which returns the number of seconds between the two. You can keep adding seconds for subsequent sessions, and then convert that sum as needed for display purposes.

Matt

Could I get a working example of that? It would be easier for me to figure out if I had a visual example.

new topic     » goto parent     » topic index » view message » categorize

4. Re: Get GamePlaying Time

Lone_EverGreen_Ranger said...

Could I get a working example of that? It would be easier for me to figure out if I had a visual example.

Something like this...

-- session times 
include std/datetime.e 
 
datetime start, finish 
export procedure start_session() 
    start = now() 
end procedure 
 
export procedure finish_session() 
    finish = now() 
end procedure 
 
export function session_duration() 
    return diff( finish, start ) 
end function 
 
-- convert seconds into a datetime 
export function convert_seconds( integer seconds ) 
    datetime duration = datetime:new() 
    duration[SECOND] = remainder( seconds, 60 ) 
 
    seconds = floor( seconds / 60 ) 
    duration[HOUR] = remainder( seconds, 60 ) 
 
    seconds = floor( seconds / 60 ) 
    duration[DAY] = seconds 
    return  
end function 
 
-- only works with DAY, HOUR, MINUTE, SECOND 
export function format( datetime duration ) 
    return sprintf( "%d Days %02d:%02d:%02d", duration[DAY..$] ) 
end function 

Matt

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu