Frame Rate Questions

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
MarekkPie
Inner party member
Posts: 587
Joined: Wed Dec 28, 2011 4:48 pm
Contact:

Re: Frame Rate Questions

Post by MarekkPie »

Robin wrote:
MarekkPie wrote:Depending on his system speed, just flooring dt might skip or repeat frames and whatnot. For example, an average dt of 1.5 would give him:
You know, if dt is 1.5, you have an FPS of 0.67. Skipping frames is not your worst problem then.
It's a made up number to illustrate a point.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Frame Rate Questions

Post by Robin »

And I used math to show the point is moot. ;)
Help us help you: attach a .love.
User avatar
MarekkPie
Inner party member
Posts: 587
Joined: Wed Dec 28, 2011 4:48 pm
Contact:

Re: Frame Rate Questions

Post by MarekkPie »

Well, flooring a number less than 1 would also give you a problem as an index. That is unless we really like the first frame.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Frame Rate Questions

Post by Robin »

Not really, look at what I wrote earlier:
Robin wrote:You could use dt. ;)

Code: Select all

function A()
  return array[math.floor(index)] -- this is the trick that makes it work
  -- it rounds index to the nearest smaller-or-equal integer.
end

function love.update(dt)
  index = index + dt * speed
end
See math.floor for more information.
It is not stored as an integer, this works. Everyone uses this, all the time.
Help us help you: attach a .love.
User avatar
MarekkPie
Inner party member
Posts: 587
Joined: Wed Dec 28, 2011 4:48 pm
Contact:

Re: Frame Rate Questions

Post by MarekkPie »

From my understanding of his initial question, he has an array that represents the images of his jump animation (either as individual images or quads for spritesheets). He needs to cycle through that array in numerical order, and he needs to have the index change every time dt appears (aka once every call of love.update(dt)).

Code: Select all

index = 0
speed = -- whatever

function love.update(dt)
  index = index + speed * dt
  print(math.floor(index))
end
Clearly this doesn't update the array after every update call. It will update the array, it may even do it in numerical order, but it doesn't do every time love.update(dt) is called.

Again, like I said in another post, my brains hurting due to RL issues, so I may have misunderstood the question, or maybe your method of calculating the jump frames is better. But I think that method won't work for my understanding of his question.
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Frame Rate Questions

Post by Nixola »

I think you have understood the question, but if someone on a fast PC plays this without dt, he may not see the animation or see it too quick, and I may see it veeeery slow; that's why delta has to be called, and that's why LÖVE developers put delta in LÖVE
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
User avatar
MarekkPie
Inner party member
Posts: 587
Joined: Wed Dec 28, 2011 4:48 pm
Contact:

Re: Frame Rate Questions

Post by MarekkPie »

Oh...duh...

/hides
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Frame Rate Questions

Post by Nixola »

You don't have to hide ^^ , he asked how to do it without dt
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
User avatar
MarekkPie
Inner party member
Posts: 587
Joined: Wed Dec 28, 2011 4:48 pm
Contact:

Re: Frame Rate Questions

Post by MarekkPie »

I'm hiding because I made a very similar point on these forums to someone else and I fall into the same trap.
User avatar
verilog
Citizen
Posts: 97
Joined: Thu Nov 03, 2011 3:15 am
Contact:

Re: Frame Rate Questions

Post by verilog »

Hey guys,
Thanks for your posts; the matter is looking much clearer to me now. However, I’ve one final question. If I lock the FPS speed, wouldn’t that set a fixed execution speed for the game regardless of the user's CPU speed?
Post Reply

Who is online

Users browsing this forum: No registered users and 173 guests