Advertisement



Go Back   Zune Boards > Zune Discussions > Zune Games > Development Discussions

New Member?



 
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Development Discussions All developers who are coding games may stop by here for any help, suggestions, and everything development related.

Reply
 
LinkBack Thread Tools
Old 08-08-2008, 05:46 PM   #1 (permalink)
Purger of Ignorance
zB Programmer
Section Staff
Super Zuner
 
Netrix's Avatar
 
Join Date: Jun 2008
Location: In my own world
Posts: 1,670
Reputation: 231
Send a message via MSN to Netrix
Awards Showcase
Favorite zB Extremity 
Total Awards: 1
Default gameTime.ElapsedRealTime bug?


In an XNA game, in your main constructor, add "double elapsed = 0;".

Then put "elapsed = gameTime.ElapsedRealTime.TotalSeconds;" at the beginning of your main Update(GameTime gameTime) function.

Run it, then after 30 seconds, add a breakpoint, then check the "elapsed" amount of time. It should be much higher than 30 seconds. This happens both on the Zune and Windows.

Does anyone know if this is a know problem?



__________________
"Against logic there is no armor like ignorance." - Laurence J. Peter

Solitaire for your Zune!
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.


Zune Book Reader!
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.

Last edited by Netrix : 08-08-2008 at 05:49 PM.




Netrix is offline   Reply With Quote
Old 08-08-2008, 06:56 PM   #2 (permalink)
Zuner
 
Join Date: Dec 2007
Posts: 56
Reputation: 26
Default

GameTime.ElapsedRealTime Property

It's not a bug, its just the elapsed real time since the last frame (ie the last call to draw method was made).



sableholic is offline   Reply With Quote
Old 08-08-2008, 07:53 PM   #3 (permalink)
Purger of Ignorance
zB Programmer
Section Staff
Super Zuner
 
Netrix's Avatar
 
Join Date: Jun 2008
Location: In my own world
Posts: 1,670
Reputation: 231
Send a message via MSN to Netrix
Awards Showcase
Favorite zB Extremity 
Total Awards: 1
Default

Quote:
Originally Posted by sableholic View Post
GameTime.ElapsedRealTime Property

It's not a bug, its just the elapsed real time since the last frame (ie the last call to draw method was made).
Yes, I am very well aware of that. It is a bug. It would be correct if games run at 6.666 frames per second, but they do not.

Each time that Update() is called, on average it claims that 0.15 seconds has passed since the last frame. That means that about 6.666 frames should be displayed per second. One Zune 30, 60 frames are drawn per second.
__________________
"Against logic there is no armor like ignorance." - Laurence J. Peter

Solitaire for your Zune!
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.


Zune Book Reader!
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.




Netrix is offline   Reply With Quote
Old 08-08-2008, 09:07 PM   #4 (permalink)
Zuner
 
Join Date: Dec 2007
Posts: 56
Reputation: 26
Default

Quote:
Originally Posted by Netrix View Post
Yes, I am very well aware of that. It is a bug. It would be correct if games run at 6.666 frames per second, but they do not.

Each time that Update() is called, on average it claims that 0.15 seconds has passed since the last frame. That means that about 6.666 frames should be displayed per second. One Zune 30, 60 frames are drawn per second.
It's not a bug and you can't use that to determine the FPS. See Shawn Hargreaves comment here:
Shawn Hargreaves Blog : Displaying the framerate


Quote:
> Surely 1 / gameTime.ElapsedRealTime.TotalSeconds

> will therefore give the current framerate.

That will tell you how long it was since the previous call to Update, but that is not the same thing as your framerate!

a) If the game is dropping frames, Update will be called more frequently in order to catch up. You want to time the number of actual draws that are taking place, not just these extra catch-up logic frames.

b) The time for a single Update can fluctuate widely, so the figure you get out of that will be too flickery to be easily readable.



sableholic is offline   Reply With Quote
Old 08-09-2008, 01:41 AM   #5 (permalink)
Purger of Ignorance
zB Programmer
Section Staff
Super Zuner
 
Netrix's Avatar
 
Join Date: Jun 2008
Location: In my own world
Posts: 1,670
Reputation: 231
Send a message via MSN to Netrix
Awards Showcase
Favorite zB Extremity 
Total Awards: 1
Default

I was not using it figure out the frame rate. I know to put it in the Draw() function and not the Update() function if I want to know the frame rate.

I was using the code above to determine the amount of time that had passed. I know I could have used two variables (lastTime and currentTime), then subtract the former from the latter, but I figured that was not necessary.

The MSDN explanation says that it tells the real time since the last frame, but apparently it tells the real time since the last Update() call. So then. To correct my previous statements: Each time that Update() is called, on average it claims that 0.15 real seconds has passed since the last Update() call. That means that about 6.666 Update() calls are made per real second, unless by real time they mean something other than the actual time of which all of my clocks keep track without any problems.

Also, there is no visible lag, so obviously Update() is being called much more than it makes it seem.
__________________
"Against logic there is no armor like ignorance." - Laurence J. Peter

Solitaire for your Zune!
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.


Zune Book Reader!
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.

Last edited by Netrix : 08-09-2008 at 01:46 AM.




Netrix is offline   Reply With Quote
Old 08-11-2008, 12:02 PM   #6 (permalink)
Experienced Zuner
 
Join Date: Nov 2007
Posts: 112
Reputation: 38
Default

Quote:
Originally Posted by Netrix View Post
Also, there is no visible lag, so obviously Update() is being called much more than it makes it seem.
actually that's not necessarily true. studies have shown that a program responding in surprisingly long periods of time(on the order of 1/5 to 1/10 of a second) appears instantaneous to the users.
__________________
-Mark
Check out my new game, "Squadron Z":
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.


Check out my version of pong with multiplayer:
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.



MarcusMaximus is offline   Reply With Quote
Old 08-11-2008, 01:43 PM   #7 (permalink)
Purger of Ignorance
zB Programmer
Section Staff
Super Zuner
 
Netrix's Avatar
 
Join Date: Jun 2008
Location: In my own world
Posts: 1,670
Reputation: 231
Send a message via MSN to Netrix
Awards Showcase
Favorite zB Extremity 
Total Awards: 1
Default

Quote:
Originally Posted by MarcusMaximus View Post
actually that's not necessarily true. studies have shown that a program responding in surprisingly long periods of time(on the order of 1/5 to 1/10 of a second) appears instantaneous to the users.
Each time Update() is called, I have the ElapsedRealTime added to a double variable. Since it says that 0.15 seconds passes between Update() calls, that means that it thinks that about 6.66 of those Update() calls are called each second. (0.15 times 6.66 is approximately 1.0)
__________________
"Against logic there is no armor like ignorance." - Laurence J. Peter

Solitaire for your Zune!
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.


Zune Book Reader!
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.




Netrix is offline   Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT -8. The time now is 08:53 PM.

 
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0 RC8
vB Ad Management by =RedTyger=
(C) ZuneBoards 2006-2007
Copyright © 2006 - 2008 Zune Boards | About Zune Boards | Legal | A member of the Crowdgather Forum Community