projects
/
physics.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
292b13c
)
time step fixed
author
Patrik Gornicz
<Gornicz.P@gmail.com>
Fri, 22 Aug 2008 14:52:58 +0000
(10:52 -0400)
committer
Patrik Gornicz
<Gornicz.P@gmail.com>
Fri, 22 Aug 2008 14:52:58 +0000
(10:52 -0400)
src/main.cpp
patch
|
blob
|
blame
|
history
diff --git
a/src/main.cpp
b/src/main.cpp
index
8c3134b
..
01afeaa
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
, fps
;
+int ups
=100, fps=100
;
int update_Count, draw_Count;
long int last_Second;
int update_Count, draw_Count;
long int last_Second;
@@
-158,11
+158,12
@@
void run()
void blockUpdate()
{
long int start = tickCountMicro();
void blockUpdate()
{
long int start = tickCountMicro();
+ long int diff = start - last_Block_Update;
//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 +=
(start - last_Block_Update)
/ (1000000 / (float)target_UPS);
+ update_Sum +=
diff
/ (1000000 / (float)target_UPS);
// 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;
@@
-172,10
+173,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 / 1000;
+
+ //float time_step = ((float)diff) / iupdate_sum / 1000;
+ //float time_step = 1000 / (100000 / rUpdate) / iupdate_sum;
+ float time_step = 10;
// run the updates
// run the updates
- for (int i =
1; i <=
iupdate_sum; i++)
+ for (int i =
0; i <
iupdate_sum; i++)
{
handleInput();
update(time_step);
{
handleInput();
update(time_step);
@@
-258,7
+262,7
@@
void draw()
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-// SDL_Delay(
2
0);
+// SDL_Delay(
1
0);
time = tickCountMicro() - time;
rDraw = (rDraw*(num-1) + time) /num;
time = tickCountMicro() - time;
rDraw = (rDraw*(num-1) + time) /num;