Falling

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.
Post Reply
thewifitree
Prole
Posts: 32
Joined: Sat Dec 21, 2013 5:16 pm

Falling

Post by thewifitree »

I've had many problems with jumping and gravity. I've been working on this project for not too long and I am having problems with gravity, I believe it is in the loop but I can't figure it out :? Please help!
Attachments
hells parkour.love
(73.31 KiB) Downloaded 146 times
User avatar
micha
Inner party member
Posts: 1083
Joined: Wed Sep 26, 2012 5:13 pm

Re: Falling

Post by micha »

Hi, the very basic equations for movement and gravity are these:

Code: Select all

player.vy = player.vy + gravity * dt

player.x = player.x + player.vx * dt
player.y = player.y + player.vy * dt
x and y are the coordinates, vx and vy are the velocity in x and y-direction and gravity is gravity. Put this into the update.

In your code, I currently don't see any velocity vector.
I also observed that you move all the blocks in the background and not the player. I suggest doing it the other way around: Move the player, not the blocks. Then you need a camera module to follow the player. That may sound more complicated to implement, but is a more consistent and intuitive approach (for example doing collision detection with a resting player and moving blocks is a bit strange for my kind of thinking)

If you want to get started with gravity, I suggest that you first ignore collision detection. Check out the tutorial on exploding rabbits. That covers many aspects already.
pielago
Party member
Posts: 142
Joined: Fri Jun 14, 2013 10:41 am

Re: Falling

Post by pielago »

this is how I learned gravity
Hope it helps you!
Attachments
gravity.love
(2.13 KiB) Downloaded 137 times
thewifitree
Prole
Posts: 32
Joined: Sat Dec 21, 2013 5:16 pm

Re: Falling

Post by thewifitree »

Thank you so much!
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 10 guests