Re: The epic love demo thread!
Posted: Wed Mar 26, 2008 3:16 pm
Old'd'd'd'd'dd'd'd'dd'd'd'ddddd
Code: Select all
t_start = love.timer.getTime()
-- draw here
t_end = love.timer.getTime()
t_used = t_end - t_start
Yeah, you're right. In AGen there is a preset target FPS (which ideally should be the monitor's refresh rate).also, I don't think this is the best way to benchmark. We should measure the time used to draw one frame, not the FPS
At the time I thought maybe you would get offended (probably silly of me). You can of course use the logo everywhere for all I care. ^_^ivan wrote:Lastly, sorry that I used the Love logo, but I was too lazy to find another image.
Aha. You have to rebuild the scenegraph when something moves ... that would slow things down. Isn't it better to be able to do this:ivan wrote:There's a number of reasons for this, but the major slowdown is rebuilding the scene graph.
Code: Select all
-- Init:
scene.add_child(sprite)
-- Update:
sprite:move() -- Or similar
Yeah ... this benchmark does not exactly illustrate all aspects of game creation, but it's a start.the payoff is fast culling, collision detection and instancing of the static geometry
Nah, when you make a change to the scene, it locks the entire branch of the graph up to the root of the tree.rude wrote:Aha. You have to rebuild the scenegraph when something moves ... that would slow things down. Isn't it better to be able to do this:
Code: Select all
-- initialize
function main ( )
object_list = { }
paused = false
moving = false
rotating = false
end
-- enable disable the different test
keyboard.on_press = function ( k )
if k == KEY_1 then
paused = not paused
elseif k == KEY_2 then
moving = not moving
elseif k == KEY_3 then
rotating = not rotating
end
end
-- update
game.on_update = function ( )
-- clock time between updates
window.title = "objects:" .. #object_list .. " fps:" .. game:get_fps ( ) .. " delta:" .. game:get_delta ( )
local delta = game:get_delta ( )
-- do not iterate if paused
if paused == false then
for k,v in ipairs ( object_list ) do
-- motion
if moving == true then
v.position.x = v.position.x + v.inc_x * delta
v.position.y = v.position.y + v.inc_y * delta
if v.position.x < 0 - 400 or v.position.x > 800 - 400 then
v.inc_x = -v.inc_x
end
if v.position.y < 0 - 300 or v.position.y > 600 - 300 then
v.inc_y = -v.inc_y
end
end
-- rotation
if rotating == true then
v.rotation = v.rotation + v.inc_rot * delta
end
end
end
-- create 5 new objects
if keyboard:is_down ( KEY_UP ) then
for i = 0, 5 do
local s = Sprite ( math.random ( 0, 800 ) - 400, math.random ( 0, 600 ) - 300 )
-- size
s.w = math.random ( 10, 20 )
s.h = math.random ( 10, 20 )
-- create object
s.canvas:rectangle ( s.w, s.h )
s.canvas:set_fill_style ( Color(255,0,0), 1 )
s.canvas:fill ( )
scene:add_child ( s )
-- motion
s.inc_x = math.random ( -100,100 ) / 100
s.inc_y = math.random ( 100,100 ) / 100
-- rotation
s.inc_rot = math.random ( -5, 5 )
table.insert ( object_list, s )
end
end
-- release 5 existing objects
if keyboard:is_down ( KEY_DOWN ) then
local diff = 5
if #object_list < diff then
diff = #object_list - 1
end
for i = 0, diff do
local s = table.remove ( object_list )
scene:remove_child ( s )
end
end
end
7. Primitivesivan wrote:Err? What else?
Haha, thanks. That's one of the perks of having a large framework.Noticed that the scene can be scaled and rotated using the mouse. Nice!
Maybe it could toggle when you press the spacebar between moving rectangles, textures or text.7. Primitives
8. Text rendering