LOVE cpu overload
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: LOVE cpu overload
Interesting. Can you try some more games, see what happens? Perhaps we can find out what causes the issue that way.
Help us help you: attach a .love.
- Alexintosh
- Prole
- Posts: 9
- Joined: Mon Apr 04, 2011 11:18 am
- Location: Italy
- Contact:
Re: LOVE cpu overload
I'm actually using love.timer.sleep(1000 / 50) -- for 50 FPS, it works very well anyway at least the cpu run at 80% with the game opened.
Thre is the project if anyway want to check
@Robin Why that tutorial was criticized?
Thre is the project if anyway want to check
@Robin Why that tutorial was criticized?
- Attachments
-
- test.love
- (927.42 KiB) Downloaded 84 times
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: LOVE cpu overload
Well, nothing obvious seems wrong with it.Alexintosh wrote:Thre is the project if anyway want to check
Several reasons. I think it might foster some misunderstandings later on, it has some examples of bad coding practice (thankfully not many, nor is it that bad), and in addition it seems to encourage to copy or type without understanding, but that might be me.Alexintosh wrote:@Robin Why that tutorial was criticized?
Help us help you: attach a .love.
- Alexintosh
- Prole
- Posts: 9
- Joined: Mon Apr 04, 2011 11:18 am
- Location: Italy
- Contact:
Re: LOVE cpu overload
Can you tell me how it run in your pc? cpu, temperature and which os is.Well, nothing obvious seems wrong with it.
The tutorial was fine for me I was asking something about make a class constructor and destructor.
Can you link the thread or explane the examples of bad coding practice you talked about, I'd like to know them before carry on.
Re: LOVE cpu overload
Hi,
this is a little codeblock I use in every project. The routine tries to regulate the delay between frames, to reach the destination framerate.
this is a little codeblock I use in every project. The routine tries to regulate the delay between frames, to reach the destination framerate.
Code: Select all
function love.run()
if love.load then love.load(arg) end
local dt = 0 -- time for current frame
local tau = 36 -- initial value for delay between frames
local runtime = 0
-- Main loop time.
while true do
love.timer.step()
dt = math.min(0.1, love.timer.getDelta() )
runtime = runtime + dt
-- do regular stuff
love.graphics.clear()
love.update(dt)
love.draw()
love.graphics.print("FPS: ["..love.timer.getFPS().."] delay: ["..math.floor(tau).."ms] idle:["..math.floor(100 * (tau/1000)/dt).."%]", 10, 10)
-- correct delay
if(runtime > 2) then
tau = tau + (love.timer.getFPS()-25)*0.2*dt
end
-- Process events
if love.event then
for e,a,b,c in love.event.poll() do
if e == "q" then
if love.audio then love.audio.stop() end
return
end
love.handlers[e](a,b,c)
end
end
-- sleep
if love.timer then love.timer.sleep(tau) end
if love.graphics then love.graphics.present() end
end
end
Last edited by Adamantos on Wed Apr 06, 2011 6:01 pm, edited 1 time in total.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: LOVE cpu overload
CPU and temperature normal, I'm on Linux.Alexintosh wrote:Can you tell me how it run in your pc? cpu, temperature and which os is.Well, nothing obvious seems wrong with it.
Unfortunately, I don't remember where it was.Alexintosh wrote:Can you link the thread or explane the examples of bad coding practice you talked about, I'd like to know them before carry on.
Help us help you: attach a .love.
- Alexintosh
- Prole
- Posts: 9
- Joined: Mon Apr 04, 2011 11:18 am
- Location: Italy
- Contact:
Re: LOVE cpu overload
@Adamantos Thanks for sharing
@Robin Thanks for informationm I will upgrade to ubuntu 10.10 in these days, maybe works better
@Robin Thanks for informationm I will upgrade to ubuntu 10.10 in these days, maybe works better
- sharpobject
- Prole
- Posts: 44
- Joined: Fri Mar 18, 2011 2:32 pm
- Location: California
Re: LOVE cpu overload
@Adamantos where do you define and modify the variable named runtime?
Setting it to 0 and incrementing it each frame seems to work pretty well. It takes about four seconds to converge on 60fps for me, though.
Edit: Oh, nevermind about that. Initializing tau to a better guess (like 13) fixes it.
Setting it to 0 and incrementing it each frame seems to work pretty well. It takes about four seconds to converge on 60fps for me, though.
Edit: Oh, nevermind about that. Initializing tau to a better guess (like 13) fixes it.
Re: LOVE cpu overload
Ups sorry... i deleted the part for incrementing the runtime.sharpobject wrote:@Adamantos where do you define and modify the variable named runtime?
In the startup phase LÖVE doesn't calculate the FPS rate right, so i had to skip the first seconds.
Who is online
Users browsing this forum: pgimeno and 2 guests