I usually go with this CC http://creativecommons.org/licenses/by/3.0/Robin wrote:Also, it appears to lack a license. This makes böb sad:
EDIT: Licensed with CC3.0 https://bitbucket.org/dannyfritz/reboun ... e13f970402
I usually go with this CC http://creativecommons.org/licenses/by/3.0/Robin wrote:Also, it appears to lack a license. This makes böb sad:
CC BY 3.0 actually. And my team projects are usually CC BY-NC because my teammates are usually like that.Robin wrote:You mean CC-BY. Just saying "a Creative Commons license" isn't really clear. Luckily the URL was pretty explicit.
Code: Select all
function love.run ()
-- Prepare stuff
love.load(arg)
-- Set a reasonable FPS limit
local FPS = 60
local dt = 1 / FPS
-- Timekeeping variable
local time
-- Main loop
while true do
-- Update the time
time = love.timer.getTime()
-- Process events
for e, a, b, c in love.event.poll() do
if e == "q" then
if love.quit then love.quit() end
if love.audio then love.audio.stop() end
return
end
love.handlers[e](a, b, c)
end
-- Do the game mechanic
if love.update then love.update(dt) end
-- Draw the graphics
love.graphics.clear()
love.draw()
love.graphics.present()
-- Wait for another frame
local time_work = love.timer.getTime() - time
if time_work < dt then
local time_wait = dt - time_work
love.timer.sleep(time_wait * 1000)
end
end
end
Is it better than :Rad3k wrote:I know it's an old thread, but I've just tried this game and wanted to say a few words.
The game is really nice, although a bit slow at the beginning (the paddles could move faster too). I'll have yet to try it with a friend to see how it feels when playing against another human.
Oh, and I have a small suggestion for (technical) improvement. CPU usage - on my system it's over 60% out of 2GHz, and it's quite much for a simple game like this. For stationary PCs it may not be a big deal, but it's certainly not nice for laptop batteries. The cause of this CPU usage is that the default LÖVE game loop runs as fast as it can. And normally, there's no reason to go faster than 60fps - refresh rate of most computer displays. Add this to your main.lua and expect an order of magnitude drop in CPU usage, with no decrease in performance:This is the main loop I use in my projects - it runs with a constant framerate of 60fps.Code: Select all
function love.run () -- Prepare stuff love.load(arg) -- Set a reasonable FPS limit local FPS = 60 local dt = 1 / FPS -- Timekeeping variable local time -- Main loop while true do -- Update the time time = love.timer.getTime() -- Process events for e, a, b, c in love.event.poll() do if e == "q" then if love.quit then love.quit() end if love.audio then love.audio.stop() end return end love.handlers[e](a, b, c) end -- Do the game mechanic if love.update then love.update(dt) end -- Draw the graphics love.graphics.clear() love.draw() love.graphics.present() -- Wait for another frame local time_work = love.timer.getTime() - time if time_work < dt then local time_wait = dt - time_work love.timer.sleep(time_wait * 1000) end end end
Code: Select all
function love.update(dt)
if dt < (100/6) then
love.timer.sleep((100/6) - dt)
end
end
Code: Select all
function love.update(dt)
if dt < 1/60 then
love.timer.sleep(1000*(1/60 - dt))
end
end
I understand what this code is supposed to do, but it's unclear to me what it's actually doing. I assume you use the default love.run. You calculate the sleep time based on how much the previous frame took? Let's see:Robin wrote:Ehm, don't you mean something like:The example on the wiki is dead wrong, by the way. Fixing it right away.Code: Select all
function love.update(dt) if dt < 1/60 then love.timer.sleep(1000*(1/60 - dt)) end end
probably Edsger W. Dijkstra wrote:The computing scientist's main challenge is not to get confused by the complexities of his own making.
Oh, I don't know whether it actually works either. But love.timer.sleep is in milliseconds and dt in seconds, so the example from the wiki could never work.Rad3k wrote:I understand what this code is supposed to do, but it's unclear to me what it's actually doing.
Users browsing this forum: No registered users and 2 guests