FPS issues in platformer
Posted: Tue Feb 21, 2012 4:48 pm
Hey fellow Lovers!
I started making games in Löve 2 weeks before and it's amazing!
My only problem is that in my platformer that has been written 48 hours, I have issues regarding the Fps (dt exactly),
trying out multiple solutions and limiting the fps didn't work, so here's my crappy OOP code:
My issue is that on my low-end laptop the game runs just fine, but on my friend's High-end pc the player jumps to the top of the screen. Please help!
I started making games in Löve 2 weeks before and it's amazing!
My only problem is that in my platformer that has been written 48 hours, I have issues regarding the Fps (dt exactly),
trying out multiple solutions and limiting the fps didn't work, so here's my crappy OOP code:
Code: Select all
function Player:handleInput(dt)
if self.onGround==false then
if self.velocity.y<400 then
self.velocity.y=self.velocity.y+1
end
else
self.velocity.y=0
end
self.TLbind:update()
if self.control.left and not self.hitLeft then
if self.onGround then
self.velocity.x=-200
else
self.velocity.x=-150
end
elseif self.control.right and not self.hitRight then
if self.onGround then
self.velocity.x=200
else
self.velocity.x=150
end
else
self.velocity.x = self.velocity.x * (1 - math.min(dt*10, 1))
end
if self.control.jump and self.onGround then
self.velocity.y=-300*dt
self.onGround=false
end
if self.control.tap.menu then
self:die()
end
end
function Player:stayInScreen(dt)
local center=self.body:center()
if center.x-16+self.velocity.x*dt<=0 or center.x+16+self.velocity.x*dt>=650 then
self.velocity.x=0
end
if center.y-16>650 then
self:die()
elseif center.y-16+velocity.y*dt<=0 then
self.velocity.y=0
end
end
function Player:move(dt)
self.body:move(self.velocity.x*dt,self.velocity.y*dt)
self.leg:move(self.velocity.x*dt,self.velocity.y*dt)
self.left:move(self.velocity.x*dt,self.velocity.y*dt)
self.right:move(self.velocity.x*dt,self.velocity.y*dt)
self.head:move(self.velocity.x*dt,self.velocity.y*dt)
end