Hello!
With help from the wiki i manage to get my character to jump! but he can't jump while he is moving...try to press space while you hold "d"...
How can i make it jump while moving?
Also, as you can in the game, the character just passes through the crate...how can i make the crate to have a mass and be an obstacle to the character?
I attached the .love
Jump while walking and how to make a box solid
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Jump while walking and how to make a box solid
- Attachments
-
- Blondie.love
- (153.59 KiB) Downloaded 240 times
Re: Jump while walking and how to make a box solid
Ok it's very simple, in love.update make a function called, for example, walking.speed and jumping speed linked to your velocity. So in love.update write
Then in love.update, when you tell your character to jump, just do -1000 of course being your jumping speed.
Code: Select all
walking.speed, jumping.speed=getLinearVelocity
Code: Select all
character:setLinearVelocity(walking.speed, -1000)
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Jump while walking and how to make a box solid
As far as I can see, that works.clepto wrote:How can i make it jump while moving?
Note that you don't actually use the character's body. Get rid of objects.char.x and objects.char.y. Instead, use love.physics: for getting the character's position to draw it, use objects.char.body:getX and objects.char.body:getY. Instead of changing the x-position of the character directly in love.keypressed, use objects.char.body:applyLinearImpulse, and do the same for jumping.clepto wrote:Also, as you can in the game, the character just passes through the crate...how can i make the crate to have a mass and be an obstacle to the character?
Help us help you: attach a .love.
Re: Jump while walking and how to make a box solid
i am telling my character to jump in love.keypressed so i added in the love.update the
and in love.keypressed the
but i guess i'm doing something wrong
Code: Select all
walking.speed, jumping.speed=getLinearVelocity
Code: Select all
character:setLinearVelocity(walking.speed, -1000)
Re: Jump while walking and how to make a box solid
i can move while jumping but i can't jump while movingRobin wrote: As far as I can see, that works.
i'll make the changes and replyRobin wrote: Note that you don't actually use the character's body. Get rid of objects.char.x and objects.char.y. Instead, use love.physics: for getting the character's position to draw it, use objects.char.body:getX and objects.char.body:getY. Instead of changing the x-position of the character directly in love.keypressed, use objects.char.body:applyLinearImpulse, and do the same for jumping.
Re: Jump while walking and how to make a box solid
@Robin
something like that?
something like that?
Code: Select all
if key == "a" then
objects.char.body:applyLinearImpulse( 10, 0 )
char_direction = "left"
elseif key == "d" then
objects.char.body:applyLinearImpulse( -10, 0 )
char_direction = "right"
end
Re: Jump while walking and how to make a box solid
clepto you are doing something wrong, the getlinearvelocity, you have to do like character:getlinearvelocity, so if your character body is bloublou, it will be bloublou:getlinearvelocity. sorry
Re: Jump while walking and how to make a box solid
i know, i change that there was something else...raen79 wrote:clepto you are doing something wrong, the getlinearvelocity, you have to do like character:getlinearvelocity, so if your character body is bloublou, it will be bloublou:getlinearvelocity. sorry
@Robin i have a problem can you look at the code? i attached the .love
- Attachments
-
- Blondie.love
- (149.47 KiB) Downloaded 199 times
Re: Jump while walking and how to make a box solid
Everything looks good and working!! Thanks!
I attached the final .love in case someone want to see the code
I attached the final .love in case someone want to see the code
- Attachments
-
- Blondie.love
- (149.51 KiB) Downloaded 206 times
Who is online
Users browsing this forum: Amazon [Bot], Semrush [Bot] and 15 guests