One Way To Go
Re: One Way To Go
Please tell me that you have used the good ol '*dt' in there. It goes way too fast even on easy.
Re: One Way To Go
I didn't use dt. I will fix that, sorry.Ruirize wrote:Please tell me that you have used the good ol '*dt' in there. It goes way too fast even on easy.
Re: One Way To Go
It's strange. If I use dt in velocity, I can't make it constant. It changes from time to time. Wth?
Here's the code:
It should be constant, but it isn't.
Here's the code:
Code: Select all
dv = difficulty * dt
if love.keyboard.isDown("left") then
velx = -dv
vely = 0
end
if love.keyboard.isDown("right") then
velx = dv
vely = 0
end
if love.keyboard.isDown("up") then
vely = -dv
velx = 0
end
if love.keyboard.isDown("down") then
vely = dv
velx = 0
end
x = x + velx
y = y + vely
Last edited by gordebak on Tue Jan 03, 2012 4:42 pm, edited 4 times in total.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: One Way To Go
dt changes all the time, and that's the way it's supposed to be. Or is that not what you meant?
Help us help you: attach a .love.
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: One Way To Go
dt is not meant to be constant. It's smaller in faster machines, and bigger in slower machines. Your code must take that into account.
When I write def I mean function.
Re: One Way To Go
So I won't use dt then. I want the velocity to be constant.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: One Way To Go
That's why you should use dt.gordebak wrote:So I won't use dt then. I want the velocity to be constant.
The faster the machine, the smaller dt. If you multiply the velocity with dt, it remains constant.
If you have 10 FPS, dt will be 0.1, if you have 100 FPS, dt will be 0.01. If you multiply the speed in seconds by dt, you get the speed in frames.
pixels/second * seconds/frame = pixels/frame.
EDIT: also, it would be nice if after X levels, you get an extra life.
Help us help you: attach a .love.
Re: One Way To Go
But it doesn't stay constant on my machine. Sometimes it goes faster if I use dt. Isn't it a bit strange?
Edit: Sorry if I sound like a moron. Look at the code please, what am I doing wrong?
And you get an extra life on level 10.
Edit: Sorry if I sound like a moron. Look at the code please, what am I doing wrong?
And you get an extra life on level 10.
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: One Way To Go
The problem might be that you are calculating velx and vely correctly ... but you never use them.
I take this should be
Or something along those lines.
PS: Please, indent your code. It will help you program much easily. In addition, it's a common courtesy if you are going to ask others to review your code. Kindof similar to brushing up your teeth between eating smelly cheese and going to the dentist.
Code: Select all
x = x + dv
y = y + dv
Code: Select all
x = x + velx
y = y + vely
PS: Please, indent your code. It will help you program much easily. In addition, it's a common courtesy if you are going to ask others to review your code. Kindof similar to brushing up your teeth between eating smelly cheese and going to the dentist.
When I write def I mean function.
Re: One Way To Go
Actually I use velx and vely. I just wrote it here incorrectly.
Edit: Corrected the code.
Edit: Corrected the code.
Who is online
Users browsing this forum: No registered users and 2 guests