I've searched the forum for posts about jumping and I saw that there were a number of them already. All of them required some sort of velocity or direction in order to function though.
The project i'm working on at the moment is my first and the movements that i've done so far are very rudimentary, so I'm not really sure how to adapt it to add velocities or gravity.
Is it possible to create a jumping motion using the "up" key while still allowing forawrds and backwards movement without rewriting my movement script? Something that allows the player to move 50 pixels or so on the Y-axis while still travelling along the X with the "left" and "right" keys?
Any pointers?
Soooo.....platform jumping?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Soooo.....platform jumping?
- Attachments
-
- Benni's Project.love
- (2.49 KiB) Downloaded 124 times
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: Soooo.....platform jumping?
No. Your movement script is just not flexible enough.Benni88 wrote:Is it possible to create a jumping motion using the "up" key while still allowing forawrds and backwards movement without rewriting my movement script?
You will need some sort of velocity control (at the very least) if you want to do movement at all in Löve. A good place to start is the "dt" parameter in love.update - you can read about it here.
When I write def I mean function.
Re: Soooo.....platform jumping?
Cheers, I'll have a go at it and come back if i get stuck.
Re: Soooo.....platform jumping?
A couple of things. You may want to take into account 'delta' in your movement script.Benni88 wrote:I've searched the forum for posts about jumping and I saw that there were a number of them already. All of them required some sort of velocity or direction in order to function though.
The project i'm working on at the moment is my first and the movements that i've done so far are very rudimentary, so I'm not really sure how to adapt it to add velocities or gravity.
Is it possible to create a jumping motion using the "up" key while still allowing forawrds and backwards movement without rewriting my movement script? Something that allows the player to move 50 pixels or so on the Y-axis while still travelling along the X with the "left" and "right" keys?
Any pointers?
In your case you're just adding 2 to the player's position.
That is, if your script runs slower on my machine the player would move slower too.
So what you need to do is multiply the player's speed (2 in your case) by delta and add that to the position.
Since delta is in seconds, you'll probably need to increase the speed constant or your player will move 2 pixels per second.
Code: Select all
Player_y = (Player_y +2)
Lastly, yes, sure you can avoid using a "velocity" vector but in that case your character will have NO intertia.
That is, if you release the keys he'll stop moving.
Velocities are not that complicated. Basically, the idea is you keep a velocity vector (vx, vy) and add that vector to the player's position each frame (taking delta into consideration again). When a key is pressed, you change the velocity vector instead of the player's position.
Last edited by ivan on Thu Oct 27, 2011 1:16 pm, edited 1 time in total.
Re: Soooo.....platform jumping?
here's a good example of using velocity to create a fireworks effect :
press space to release fireworks
(i still need to change the numbers a bit to make it more realistic)
press space to release fireworks
(i still need to change the numbers a bit to make it more realistic)
- Attachments
-
- fireworks.love
- (530 Bytes) Downloaded 103 times
Re: Soooo.....platform jumping?
Thanks too guys. I'm working on it now.
Re: Soooo.....platform jumping?
Wait! I changed the numbers a bit, and made everything constant with delta :
- Attachments
-
- fireworks.love
- (535 Bytes) Downloaded 109 times
Re: Soooo.....platform jumping?
I've made an example before that shows how to do this. I haven't taken a look at it in a while but it might be useful for you:
http://love2d.org/forums/download/file.php?id=2732
(Use the arrow keys to move)
Never mind, that one isn't speed consistent. Try this one:
http://love2d.org/forums/download/file.php?id=2732
(Use the arrow keys to move)
Never mind, that one isn't speed consistent. Try this one:
- Attachments
-
- JumpExample.love
- (2.85 KiB) Downloaded 110 times
Who is online
Users browsing this forum: No registered users and 4 guests