Browse Source

Switch love.timer.sleep to seconds

Bart van Strien 14 years ago
parent
commit
3d1fac07b2

+ 3 - 3
src/modules/timer/sdl/Timer.cpp

@@ -79,10 +79,10 @@ namespace sdl
 		}
 		}
 	}
 	}
 
 
-	void Timer::sleep(int ms)
+	void Timer::sleep(float seconds)
 	{
 	{
-		if(ms > 0)
-			delay(ms);
+		if(seconds > 0)
+			delay((int) (seconds*1000));
 	}
 	}
 
 
 	float Timer::getDelta() const
 	float Timer::getDelta() const

+ 2 - 2
src/modules/timer/sdl/Timer.h

@@ -88,9 +88,9 @@ namespace sdl
 		/**
 		/**
 		* Tries to sleep for the specified amount of time. The precision is
 		* Tries to sleep for the specified amount of time. The precision is
 		* usually 1ms.
 		* usually 1ms.
-		* @param ms The number of milliseconds to sleep for.
+		* @param seconds The number of seconds to sleep for.
 		**/
 		**/
-		void sleep(int ms);
+		void sleep(float seconds);
 
 
 		/**
 		/**
 		* Gets the time between the last two frames, assuming step is called
 		* Gets the time between the last two frames, assuming step is called

+ 1 - 2
src/modules/timer/sdl/wrap_Timer.cpp

@@ -49,8 +49,7 @@ namespace sdl
 
 
 	int w_sleep(lua_State * L)
 	int w_sleep(lua_State * L)
 	{
 	{
-		int ms = luaL_checkint(L, 1);
-		instance->sleep(ms);
+		instance->sleep((float) luaL_checknumber(L, 1));
 		return 0;
 		return 0;
 	}
 	}
 
 

+ 1 - 1
src/scripts/boot.lua

@@ -350,7 +350,7 @@ function love.run()
 			end
 			end
 		end
 		end
 
 
-		if love.timer then love.timer.sleep(1) end
+		if love.timer then love.timer.sleep(0.001) end
 		if love.graphics then love.graphics.present() end
 		if love.graphics then love.graphics.present() end
 
 
 	end
 	end

+ 1 - 1
src/scripts/boot.lua.h

@@ -586,7 +586,7 @@ const unsigned char boot_lua[] =
 	0x09, 0x09, 0x65, 0x6e, 0x64, 0x0a,0x0a,
 	0x09, 0x09, 0x65, 0x6e, 0x64, 0x0a,0x0a,
 	0x09, 0x09, 0x69, 0x66, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x74, 0x69, 0x6d, 0x65, 0x72, 0x20, 0x74, 0x68, 
 	0x09, 0x09, 0x69, 0x66, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x74, 0x69, 0x6d, 0x65, 0x72, 0x20, 0x74, 0x68, 
 	0x65, 0x6e, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x74, 0x69, 0x6d, 0x65, 0x72, 0x2e, 0x73, 0x6c, 0x65, 0x65, 
 	0x65, 0x6e, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x74, 0x69, 0x6d, 0x65, 0x72, 0x2e, 0x73, 0x6c, 0x65, 0x65, 
-	0x70, 0x28, 0x31, 0x29, 0x20, 0x65, 0x6e, 0x64, 0x0a,
+	0x70, 0x28, 0x30, 0x2e, 0x30, 0x30, 0x31, 0x29, 0x20, 0x65, 0x6e, 0x64, 0x0a,
 	0x09, 0x09, 0x69, 0x66, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x73, 
 	0x09, 0x09, 0x69, 0x66, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x73, 
 	0x20, 0x74, 0x68, 0x65, 0x6e, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 
 	0x20, 0x74, 0x68, 0x65, 0x6e, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 
 	0x73, 0x2e, 0x70, 0x72, 0x65, 0x73, 0x65, 0x6e, 0x74, 0x28, 0x29, 0x20, 0x65, 0x6e, 0x64, 0x0a,0x0a,
 	0x73, 0x2e, 0x70, 0x72, 0x65, 0x73, 0x65, 0x6e, 0x74, 0x28, 0x29, 0x20, 0x65, 0x6e, 0x64, 0x0a,0x0a,