From 329c8cb80d29aff078284db227af6c2cb114fc2f Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Mon, 14 Sep 2015 15:39:12 -0400 Subject: FIXED TIMINGgit statusgit status oh yeah and jumping --- src/World.cpp | 2 +- src/main.cpp | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/World.cpp b/src/World.cpp index 0e8d8fc..45df63c 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -116,7 +116,7 @@ void World::detect(vec2 *v,vec2 *vel,const float width){ // return; // ;) } }else if(v->y>line[i].start+HLINE){ // Trashy gravity handling - vel->y-=.0000001; + vel->y-=.0000002; } } } diff --git a/src/main.cpp b/src/main.cpp index 9f87c2b..a92ff16 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,9 +1,10 @@ #include #include #include +#include #define TICKS_PER_SEC 20 -#define MSEC_PER_TICK (1000/TICKS_PER_SEC) +#define MSEC_PER_TICK 500//(1000/TICKS_PER_SEC) SDL_Window *window = NULL; SDL_Surface *renderSurface = NULL; @@ -30,7 +31,10 @@ void render(); static unsigned int initTime; unsigned int millis(void){ - return ((float)(clock()-initTime)/(float)CLOCKS_PER_SEC)*2000; + //return (float)(clock()-initTime)/(CLOCKS_PER_SEC/1000.0f); + std::chrono::system_clock::time_point now=std::chrono::system_clock::now(); + std::chrono::nanoseconds m=now.time_since_epoch(); + return std::chrono::duration_cast(m).count(); } int main(int argc,char **argv){ -- cgit v1.2.3