]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
FIXED TIMINGgit statusgit status oh yeah and jumping
authorClyne Sullivan <tullivan99@gmail.com>
Mon, 14 Sep 2015 19:39:12 +0000 (15:39 -0400)
committerClyne Sullivan <tullivan99@gmail.com>
Mon, 14 Sep 2015 19:39:12 +0000 (15:39 -0400)
src/World.cpp
src/main.cpp

index 0e8d8fc790c56299eae3e45562ac082d11bbe47a..45df63c86faaeb9e8c945d3c83bd919df7d0df17 100644 (file)
@@ -116,7 +116,7 @@ void World::detect(vec2 *v,vec2 *vel,const float width){
 //                             return; // ;)\r
                        }\r
                }else if(v->y>line[i].start+HLINE){                                                                     // Trashy gravity handling\r
-                       vel->y-=.0000001;\r
+                       vel->y-=.0000002;\r
                }\r
        }\r
 }\r
index 9f87c2b769ba7f56288e7a00afed5cc94aed319f..a92ff165e641361aca61d18fb880faa0a680412b 100644 (file)
@@ -1,9 +1,10 @@
 #include <common.h>
 #include <cstdio>
 #include <ctime>
+#include <chrono>
 
 #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<std::chrono::milliseconds>(m).count();
 }
 
 int main(int argc,char **argv){