[RESOLVED]Render a lot of the same thing (i.e. bullets)
Posted: Sun May 12, 2013 8:20 am
Hello, a while ago I decided to use play around with love and I'm... well... loving it. I'm also pretty new to Lua and I'm loving that too! I feel bad posting here considering my first post is asking for help, but hopefully I'll be able to contribute with time as I get a better grasp on things.
I've been playing around with a kind of bullet-hell style game which involved rendering lots and lots of bullets onto the screen. What I have is a simple loop that renders entities. For bullets in particular it just renders a colored rectangle.
This works fine up until a point. Once about 450 entities pile up the game just freezes without notice or lag even. 450 might sound like a lot, and it is, but it's within the realm of possibility that there will be more than that. If it was just a little slower I wouldn't been as determined to fix it but this is a complete freezing of the game entirely. Before you ask, this is almost definitely rendering that's causing the problem, when I stop drawing entirely the game just slows down as they pile up, no freeze.
My goal is to, at the very least, stop the game from freezing when there's a lot of entities, but I haven't managed to find a way. I tried manipulating an ImageData and drawing a new Image in draw, there was no freeze, but it was incredibly slow. I don't think a canvas will help because the bullets will be moving in all directions constantly.
Could a shader work? Any undocumented tools that might be useful here? Why is it freezing in the first place?
Thanks.
I've been playing around with a kind of bullet-hell style game which involved rendering lots and lots of bullets onto the screen. What I have is a simple loop that renders entities. For bullets in particular it just renders a colored rectangle.
Code: Select all
-- Bullet is a 'class'
function Bullet:draw()
local x,y, w,h = physics.get_world_box(self) -- gets bounding box in 2d space (this is not not love.physics)
love.graphics.setColor(255,0,0, 255)
love.graphics.rectangle('fill', x,y, w,h)
love.graphics.setColor(255,255,255, 255)
end
My goal is to, at the very least, stop the game from freezing when there's a lot of entities, but I haven't managed to find a way. I tried manipulating an ImageData and drawing a new Image in draw, there was no freeze, but it was incredibly slow. I don't think a canvas will help because the bullets will be moving in all directions constantly.
Could a shader work? Any undocumented tools that might be useful here? Why is it freezing in the first place?
Thanks.