Bläddra i källkod

finished adding a delta-time behavior to the update function.

Adrien Boucaud 12 år sedan
förälder
incheckning
1a22c6782d
2 ändrade filer med 4 tillägg och 2 borttagningar
  1. 1 1
      struct.h
  2. 3 1
      wall.c

+ 1 - 1
struct.h

@@ -31,7 +31,7 @@ struct Camera{
 //id is self explanatory
 //nxt is used by the linked list
 struct Wall{
-    int d;
+    float d;
     int h;
     int id;
     int line;

+ 3 - 1
wall.c

@@ -61,6 +61,8 @@ Wall *removeWall(Wall *list, int d)
 
 void update(Wall *list, unsigned int delta_time)
 {
+	//we want to move the obstacle by 1 every two ticks (1/64 seconds ~= 1/60)
+	//
 	Wall *tmp;
 	tmp = list;
 
@@ -68,7 +70,7 @@ void update(Wall *list, unsigned int delta_time)
 		if(tmp != NULL)
 		{
 			//just reducing the distance from the center
-			tmp->d-=1;
+			tmp->d -= 0.5 * delta_time;
 		}
 		tmp = tmp->nxt;
 	}while(tmp != NULL);