It errors when you start the game, sorry.Ertain wrote:I am at my wits end. I can't figure out why, at the end of my little demo here, it completely freezes up. I don't know if it's all of the ships I'm drawing, or it's a combination of the drawing and the collision detection.
If you guys wish to sample my game, here it is.
Managing a consistent framerate
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Managing a consistent framerate
Help us help you: attach a .love.
Re: Managing a consistent framerate
Hmm, must be the framebuffer.
Booted, suited, and ready to get executed.
Re: Managing a consistent framerate
Yeah, it returns an error to do with love.graphics.setRenderTarget()
Do you recognise when the world won't stop for you? Or when the days don't care what you've got to do? When the weight's too tough to lift up, what do you? Don't let them choose for you, that's on you.
Re: Managing a consistent framerate
I think the reason here is that you keep moving your enemies inifinitely (so their y position becames a really large number, and drawing anything at such extreme locations can be demanding, and using such numbers for computations also). You should remove your enemies when they go off-screen both for drawing and collision detection.Robin wrote:Ertain wrote:I am at my wits end. I can't figure out why, at the end of my little demo here, it completely freezes up. I don't know if it's all of the ships I'm drawing, or it's a combination of the drawing and the collision detection.
This one line fixes the crashing for me (remember, this is a hacky workaround, not a real solution):
Code: Select all
pincerAttack = function(changeInTime)
if swarm.enemy[2].buzzard1.y>1000 then return end
Code: Select all
if condition then love.keypressed=myFirstFn else love.keypressed=mySecondFn end
Code: Select all
if not menus.letsGetThePartyStarted then
...
elseif menus.letsGetThePartyStarted then
...
end
Code: Select all
if not menus.letsGetThePartyStarted then
...
else
...
end
In summary, this code could get lots of optimization (or, should I write, it could waste way less resources).
Change line 28 in libs/background.lua fromRobin wrote:It errors when you start the game, sorry.
Code: Select all
mr_framebuffer = pcall(love.graphics.newFramebuffer, gf.getWidth()+50, gf.getHeight()+50)
Code: Select all
_status, mr_framebuffer = pcall(love.graphics.newFramebuffer, gf.getWidth()+50, gf.getHeight()+50)
My lovely code lives at GitHub: http://github.com/miko/Love2d-samples
Re: Managing a consistent framerate
Thank you for the help, Miko.
Booted, suited, and ready to get executed.
- BlackBulletIV
- Inner party member
- Posts: 1261
- Joined: Wed Dec 29, 2010 8:19 pm
- Location: Queensland, Australia
- Contact:
Re: Managing a consistent framerate
Even shorter would be:miko wrote:Also, you can shorten this construct:into this:Code: Select all
if not menus.letsGetThePartyStarted then ... elseif menus.letsGetThePartyStarted then ... end
Code: Select all
if not menus.letsGetThePartyStarted then ... else ... end
Code: Select all
if menus.letsGetThePartyStarted then
<code that was in the else part>
else
<code that was in the if part>
end
Re: Managing a consistent framerate
Yeah, maybe I should organize it like that. :-?
Booted, suited, and ready to get executed.
Re: Managing a consistent framerate
By the way, about that framebuffer issue: how shall I exactly draw to it? I know I first load it in love.load(), but do I first set the render target (in the draw() step) as the framebuffer, and then use a draw() function to set the images in the buffer?
Booted, suited, and ready to get executed.
- BlackBulletIV
- Inner party member
- Posts: 1261
- Joined: Wed Dec 29, 2010 8:19 pm
- Location: Queensland, Australia
- Contact:
Re: Managing a consistent framerate
To render to it, either use love.graphics.setRenderTarget or Framebuffer:renderTo.
or
Code: Select all
love.graphics.setRenderTarget(fb)
-- draw stuff
love.graphics.setRenderTarget() -- set back to screen
Code: Select all
fb:renderTo(function()
-- draw stuff
end)
Re: Managing a consistent framerate
There is lots of examples in this forum, check them out! For example, my code here: https://github.com/miko/Love2d-samples/ ... e/main.luaErtain wrote:By the way, about that framebuffer issue: how shall I exactly draw to it? I know I first load it in love.load(), but do I first set the render target (in the draw() step) as the framebuffer, and then use a draw() function to set the images in the buffer?
My lovely code lives at GitHub: http://github.com/miko/Love2d-samples
Who is online
Users browsing this forum: Bing [Bot] and 7 guests