Here is my code:
Code: Select all
-- jump speed is equal to jump speed minus jump acceleration
if (love.keyboard.isDown(' ')) then this.jspeed = this.jspeed - this.jspeedacc
Code: Select all
-- jump speed is equal to jump speed minus jump acceleration
if (love.keyboard.isDown(' ')) then this.jspeed = this.jspeed - this.jspeedacc
Thanks, but I already get the concept. What I don't get is how to write it down in code. I have it gradually slowing down when going up, but it jumps as far as I have defined instead of gradually jumping in regards to how long the key is held down, which is what I want.micha wrote:This article http://higherorderfun.com/blog/2012/05/ ... atformers/ has some thoughts on jump physics. Scroll down all the way to "jump control".
Try this: https://github.com/bartbes/Metaluaz wrote:P.S. I hate the "x = x - y" syntax, rather than "x -= y!"
Unfortunately the tutorial series seem to have the same jumping mechanism as I do. And I've tried searching the thread already, before posting.Roland_Yonaba wrote:Just search in the support and development threads, this have been covered a lot.
You can also give a look at this tutorial series, there's a handy solution provided there, in Lua, with Love2D.
That's nice! Thank you!Lafolie wrote:Try this: https://github.com/bartbes/Metaluaz wrote:P.S. I hate the "x = x - y" syntax, rather than "x -= y!"
Code: Select all
jumpTimer = 0
Code: Select all
if canJump then
camJump = false
player.vecolityY = jumpVelocity
jumpTimer = maxJumpTime
end
Code: Select all
jumpTimer = math.max(jumpTimer - dt,0)
if love.keyboard.isDown(jumpKey) and jumpTimer>0 then
player.vecolityY = player.velocityY - playerJumpAcceleration * dt
end
Thanks, I will definitely try it out! I've implemented the same idea, but it wasn't that well done, no dt and all. Right now I'm rewriting the game code from scratch, and at the moment I'm struggling at collision, as mentioned in another thread.micha wrote:The math.max function ensure that the value never is negative.
Try experimenting with the parameters maxJumpTime and playerJumpAcceleration. Note: playerJumpAcceleration should be smaller than gravity. If it is not, the player will jump like a starting rocket.
Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 5 guests