projects
/
physics.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
2ea1d2d
)
.
author
Patrik Gornicz
<Gornicz.P@gmail.com>
Fri, 22 Aug 2008 15:12:45 +0000
(11:12 -0400)
committer
Patrik Gornicz
<Gornicz.P@gmail.com>
Fri, 22 Aug 2008 15:12:45 +0000
(11:12 -0400)
src/main.cpp
patch
|
blob
|
blame
|
history
diff --git
a/src/main.cpp
b/src/main.cpp
index
01afeaa
..
7576077
100644
(file)
--- a/
src/main.cpp
+++ b/
src/main.cpp
@@
-65,7
+65,7
@@
int target_UPS = 100;
long int last_Block_Update;
float update_Sum = 0;
long int last_Block_Update;
float update_Sum = 0;
-int ups
=100, fps=100;
+int ups=100, fps=100;
int update_Count, draw_Count;
long int last_Second;
int update_Count, draw_Count;
long int last_Second;
@@
-83,6
+83,7
@@
float rRun = 100;
float num = 10;
float num = 10;
+float total = 0;
/// ***** MAIN Method *****
int main()
/// ***** MAIN Method *****
int main()
@@
-129,8
+130,6
@@
void clean()
/// ***** Private Methods *****
/// ***** Private Methods *****
-float total = 0;
-
void run()
{
is_Running = true;
void run()
{
is_Running = true;
@@
-163,7
+162,7
@@
void blockUpdate()
//cout << "Block" << endl;
// Calculate the updates that should be run for the next draw
//cout << "Block" << endl;
// Calculate the updates that should be run for the next draw
- update_Sum +=
diff / (1000000 / (float)target_UPS)
;
+ update_Sum +=
(float)(diff * target_UPS) / 1000000
;
// insures the float to int cast is done once.
int iupdate_sum = (int)update_Sum;
// insures the float to int cast is done once.
int iupdate_sum = (int)update_Sum;
@@
-171,11
+170,12
@@
void blockUpdate()
// TODO the main run loop needs to be tested and pruned
if (iupdate_sum > 0)
{
// TODO the main run loop needs to be tested and pruned
if (iupdate_sum > 0)
{
- // Calculate a time step that spreads the updates out as much as
possible
- // used because really quick updates are nearly wasted
+ // Calculate a time step that spreads the updates out as much as
+ //
possible
used because really quick updates are nearly wasted
//float time_step = ((float)diff) / iupdate_sum / 1000;
//float time_step = 1000 / (100000 / rUpdate) / iupdate_sum;
//float time_step = ((float)diff) / iupdate_sum / 1000;
//float time_step = 1000 / (100000 / rUpdate) / iupdate_sum;
+ //float time_step = 1000 / ups / iupdate_sum;
float time_step = 10;
// run the updates
float time_step = 10;
// run the updates
@@
-184,7
+184,8
@@
void blockUpdate()
handleInput();
update(time_step);
}
handleInput();
update(time_step);
}
- // remove the updates that where run from the sum
+
+ // remove the updates that were run from the sum
update_Sum -= iupdate_sum;
last_Block_Update = tickCountMicro();
}
update_Sum -= iupdate_sum;
last_Block_Update = tickCountMicro();
}
@@
-262,7
+263,7
@@
void draw()
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
//
SDL_Delay(10);
+
//
SDL_Delay(10);
time = tickCountMicro() - time;
rDraw = (rDraw*(num-1) + time) /num;
time = tickCountMicro() - time;
rDraw = (rDraw*(num-1) + time) /num;