projects
/
physics.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
3b368b7
)
wip: main testing
author
Patrik Gornicz
<Gornicz.P@gmail.com>
Fri, 22 Aug 2008 02:08:40 +0000
(22:08 -0400)
committer
Patrik Gornicz
<Gornicz.P@gmail.com>
Fri, 22 Aug 2008 02:08:40 +0000
(22:08 -0400)
src/main.cpp
patch
|
blob
|
blame
|
history
diff --git
a/src/main.cpp
b/src/main.cpp
index
228c238
..
8c3134b
100644
(file)
--- a/
src/main.cpp
+++ b/
src/main.cpp
@@
-70,13
+70,17
@@
int update_Count, draw_Count;
long int last_Second;
long int last_Second;
-float target_time_steps_per_second = 100;
+float target_time_steps_per_second = 1000;
+float times;
+float time_steps_Count;
// experiment with rolling averages
float rUpdate = 100;
float rDraw = 100;
// experiment with rolling averages
float rUpdate = 100;
float rDraw = 100;
+float rInput = 100;
float rRun = 100;
float rRun = 100;
+
float num = 10;
float num = 10;
@@
-125,6
+129,8
@@
void clean()
/// ***** Private Methods *****
/// ***** Private Methods *****
+float total = 0;
+
void run()
{
is_Running = true;
void run()
{
is_Running = true;
@@
-143,7
+149,9
@@
void run()
rRun = (rRun * (num-1) + time) / num;
rRun = (rRun * (num-1) + time) / num;
- cout << "rR:\t" << rRun << endl;
+ //cout << "total:\t" << total << endl;
+ //cout << "rR:\t" << rRun << endl;
+ //total = 0;
}
}
}
}
@@
-151,7
+159,7
@@
void blockUpdate()
{
long int start = tickCountMicro();
{
long int start = tickCountMicro();
- cout << "Block" << endl;
+
//
cout << "Block" << endl;
// Calculate the updates that should be run for the next draw
update_Sum += (start - last_Block_Update) / (1000000 / (float)target_UPS);
// Calculate the updates that should be run for the next draw
update_Sum += (start - last_Block_Update) / (1000000 / (float)target_UPS);
@@
-164,13
+172,13
@@
void blockUpdate()
{
// 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)(start - last_Block_Update)) / iupdate_sum;
+ float time_step = ((float)(start - last_Block_Update)) / iupdate_sum
/ 1000
;
// run the updates
for (int i = 1; i <= iupdate_sum; i++)
{
handleInput();
// run the updates
for (int i = 1; i <= iupdate_sum; i++)
{
handleInput();
- update(time_step
/ 1000
);
+ update(time_step);
}
// remove the updates that where run from the sum
update_Sum -= iupdate_sum;
}
// remove the updates that where run from the sum
update_Sum -= iupdate_sum;
@@
-185,26
+193,37
@@
void updateFPSCounters()
{
ups = update_Count;
fps = draw_Count;
{
ups = update_Count;
fps = draw_Count;
+ times = time_steps_Count;
update_Count = 0;
draw_Count = 0;
update_Count = 0;
draw_Count = 0;
+ time_steps_Count = 0;
last_Second = tickCountMicro();
#ifdef FPSUPS
cout << "ups:\t" << ups << endl;
cout << "fps:\t" << fps << endl;
last_Second = tickCountMicro();
#ifdef FPSUPS
cout << "ups:\t" << ups << endl;
cout << "fps:\t" << fps << endl;
+ cout << "times:\t" << times << endl;
#endif
}
}
void handleInput()
{
#endif
}
}
void handleInput()
{
- input::update();
+ long int time;
+
+ time = tickCountMicro();
+ input::update();
- game::handleInput();
+
game::handleInput();
- if(cfg::endGame())
- is_Running = false;
+ if(cfg::endGame())
+ is_Running = false;
+ time = tickCountMicro() - time;
+
+ rInput = (rInput*(num-1) + time) /num;
+
+ total += rInput;
}
void update(float time_step)
}
void update(float time_step)
@@
-212,6
+231,7
@@
void update(float time_step)
long int time;
update_Count++;
long int time;
update_Count++;
+ time_steps_Count += time_step;
time = tickCountMicro();
game::update(time_step);
time = tickCountMicro();
game::update(time_step);
@@
-219,8
+239,10
@@
void update(float time_step)
rUpdate = (rUpdate * (num-1) + time) / num;
rUpdate = (rUpdate * (num-1) + time) / num;
- cout << "ru:\t" << rUpdate << endl;
- cout << "ts:\t" << time_step << endl;
+ //cout << "ts:\t" << time_step << endl;
+ //cout << "ru:\t" << rUpdate << endl;
+
+ total += rUpdate;
}
void draw()
}
void draw()
@@
-236,10
+258,12
@@
void draw()
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
//SDL_Delay(5
0);
+
// SDL_Delay(2
0);
time = tickCountMicro() - time;
rDraw = (rDraw*(num-1) + time) /num;
time = tickCountMicro() - time;
rDraw = (rDraw*(num-1) + time) /num;
- cout << "rd:\t" << rDraw << endl;
+ //cout << "rd:\t" << rDraw << endl;
+
+ total += rDraw;
}
}