|
  
|
|
|||||||
| Development Discussions All developers who are coding games may stop by here for any help, suggestions, and everything development related. |
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 (permalink) |
|
Purger of Ignorance
zB Programmer
Section Staff Super Zuner Join Date: Jun 2008
Location: In my own world
Posts: 1,670
Reputation: 231
|
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. ![]() |
|
|
|
|
|
#2 (permalink) |
|
Zuner
Join Date: Dec 2007
Posts: 56
Reputation: 26
|
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). |
|
|
|
|
|
#3 (permalink) | |
|
Purger of Ignorance
zB Programmer
Section Staff Super Zuner Join Date: Jun 2008
Location: In my own world
Posts: 1,670
Reputation: 231
|
Quote:
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. ![]() |
|
|
|
|
|
|
#4 (permalink) | ||
|
Zuner
Join Date: Dec 2007
Posts: 56
Reputation: 26
|
Quote:
Shawn Hargreaves Blog : Displaying the framerate Quote:
|
||
|
|
|
|
|
#5 (permalink) |
|
Purger of Ignorance
zB Programmer
Section Staff Super Zuner Join Date: Jun 2008
Location: In my own world
Posts: 1,670
Reputation: 231
|
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. ![]() |
|
|
|
|
|
#6 (permalink) |
|
Experienced Zuner
Join Date: Nov 2007
Posts: 112
Reputation: 38
|
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. |
|
|
|
|
|
#7 (permalink) |
|
Purger of Ignorance
zB Programmer
Section Staff Super Zuner Join Date: Jun 2008
Location: In my own world
Posts: 1,670
Reputation: 231
|
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. ![]() |
|
|
|
![]() |
| Thread Tools | |
|
|
| |