LOVE cpu overload

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: LOVE cpu overload

Post by Robin »

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.
User avatar
Alexintosh
Prole
Posts: 9
Joined: Mon Apr 04, 2011 11:18 am
Location: Italy
Contact:

Re: LOVE cpu overload

Post by Alexintosh »

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 :oops:

@Robin Why that tutorial was criticized?
Attachments
test.love
(927.42 KiB) Downloaded 83 times
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: LOVE cpu overload

Post by Robin »

Alexintosh wrote:Thre is the project if anyway want to check :oops:
Well, nothing obvious seems wrong with it. :?
Alexintosh wrote:@Robin Why that tutorial was criticized?
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.
Help us help you: attach a .love.
User avatar
Alexintosh
Prole
Posts: 9
Joined: Mon Apr 04, 2011 11:18 am
Location: Italy
Contact:

Re: LOVE cpu overload

Post by Alexintosh »

Well, nothing obvious seems wrong with it.
Can you tell me how it run in your pc? cpu, temperature and which os is.

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.
User avatar
Adamantos
Prole
Posts: 27
Joined: Sun May 16, 2010 10:47 pm

Re: LOVE cpu overload

Post by Adamantos »

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.

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.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: LOVE cpu overload

Post by Robin »

Alexintosh wrote:
Well, nothing obvious seems wrong with it.
Can you tell me how it run in your pc? cpu, temperature and which os is.
CPU and temperature normal, I'm on Linux.
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.
Unfortunately, I don't remember where it was.
Help us help you: attach a .love.
User avatar
Alexintosh
Prole
Posts: 9
Joined: Mon Apr 04, 2011 11:18 am
Location: Italy
Contact:

Re: LOVE cpu overload

Post by Alexintosh »

@Adamantos Thanks for sharing

@Robin Thanks for informationm I will upgrade to ubuntu 10.10 in these days, maybe works better
User avatar
sharpobject
Prole
Posts: 44
Joined: Fri Mar 18, 2011 2:32 pm
Location: California

Re: LOVE cpu overload

Post by sharpobject »

@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.
User avatar
Adamantos
Prole
Posts: 27
Joined: Sun May 16, 2010 10:47 pm

Re: LOVE cpu overload

Post by Adamantos »

sharpobject wrote:@Adamantos where do you define and modify the variable named runtime?
Ups sorry... i deleted the part for incrementing the runtime.
In the startup phase LÖVE doesn't calculate the FPS rate right, so i had to skip the first seconds.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 208 guests