About dt...(edit: and something else)
Posted: Wed May 30, 2012 10:28 pm
Question one:
Okay, so...
viewtopic.php?f=4&t=8957
There's an explanation here about dt, by timmeh, and I wanted to be sure that I understand this...
So dt's value is always 1/current fps, so, okay, let me give an example...
So...if the fps was 30, the speed would be 200 * 0.0333333333, which would be 6.66666666, and if fps was 60, the speed would be 200 * 0.0166666667, which would be 3.33333334...
Now, here comes the part that kinda confuses me...
Since the speed on 30 fps would be 6.66666666 and speed on 60 fps is 3.33333334, and now, I'm guessing there's some kind a boost by fps involved here...I'm not sure how to calculate it, but if the 6.66666666 was an absolute speed for 30 fps, and 3.33333334 was an absolute speed for 60 fps, that would actually make character move faster on 30 fps, than on 60 fps, and that's just absurd.
What I am wondering is...how does the speed even out in the end?
Does 6.66666666 get divided by 2 on 30 fps, while 3.33333334 on 60 fps just stays the same? so it's about the same speed, only 0.0000001 faster on 60 fps? or is there just something else in "dt", other than 1/fps?
EDIT:
question two:
Okay, another thing I'm wondering about...
Ok, there's a code that is called in my main with require. What I'm wondering is...why is "player = {}" necessary to require this code in my main code? The way I see this, it's just an empty table, right? If the variables that are under it, were actually inside, it would make some sense to me...but like this, I just don't get it...why do I get an error when I delete "Player = {}"? Why is an empty table needed in this code for require to function properly?
EDIT2:
question three:
I've also been trying to make it so that i get the speed of the player shown at all times, and change, as it changes, like 0 when not moving, and whatever the speed is when moving. I'm guessing it goes something like showing the fps, but I don't know how to do that, either, well...I didn't really search for this, but since I'm asking questions here, might as well put this here...
I tried using
in the update function. Didn't really think it would work, but gave it a shot xD
so I was wondering how would I show speed at all times, or anything, really...like if a player had a bunch of stats, like strength, health...and so on, and make it update, as you get items/level up or distribute stat points, in case it's that kind of a game.
Okay, so...
viewtopic.php?f=4&t=8957
There's an explanation here about dt, by timmeh, and I wanted to be sure that I understand this...
So dt's value is always 1/current fps, so, okay, let me give an example...
Code: Select all
if love.keyboard.isDown("left")
then player.x = player.x - 200 * dt
end
if love.keyboard.isDown("right")
then player.x = player.x + 200 * dt
end
Now, here comes the part that kinda confuses me...
Since the speed on 30 fps would be 6.66666666 and speed on 60 fps is 3.33333334, and now, I'm guessing there's some kind a boost by fps involved here...I'm not sure how to calculate it, but if the 6.66666666 was an absolute speed for 30 fps, and 3.33333334 was an absolute speed for 60 fps, that would actually make character move faster on 30 fps, than on 60 fps, and that's just absurd.
What I am wondering is...how does the speed even out in the end?
Does 6.66666666 get divided by 2 on 30 fps, while 3.33333334 on 60 fps just stays the same? so it's about the same speed, only 0.0000001 faster on 60 fps? or is there just something else in "dt", other than 1/fps?
EDIT:
question two:
Okay, another thing I'm wondering about...
Code: Select all
player = {}
player.x = 50
player.y = 50
player.speed = 200
player.pic = love.graphics.newImage("images/player.png")
function player_draw()
love.graphics.setColor(255, 255, 255)
love.graphics.draw(player.pic, player.x, player.y)
end
function player_move(dt)
if love.keyboard.isDown("left")
then player.x = player.x - player.speed
end
if love.keyboard.isDown("right")
then player.x = player.x + player.speed * dt
end
end
EDIT2:
question three:
I've also been trying to make it so that i get the speed of the player shown at all times, and change, as it changes, like 0 when not moving, and whatever the speed is when moving. I'm guessing it goes something like showing the fps, but I don't know how to do that, either, well...I didn't really search for this, but since I'm asking questions here, might as well put this here...
I tried using
Code: Select all
love.graphics.setColor(0, 255, 255)
love.graphics.print(player.speed, 400, 400)
so I was wondering how would I show speed at all times, or anything, really...like if a player had a bunch of stats, like strength, health...and so on, and make it update, as you get items/level up or distribute stat points, in case it's that kind of a game.