Need some help with Physic module ?

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
Neolitik
Citizen
Posts: 55
Joined: Sun Jun 28, 2009 3:13 pm

Need some help with Physic module ?

Post by Neolitik »

Hello any ,

I' m on the " physics way" in love.
I want make a Body , Can jump and move ....
But in my code , if i jump my body dont conserve right or left move !
I had search in the LovelBigPlantet code but i m dont understand all :o
i read this : --get the velocity, process the input, and set it, preserves untouched velocity..
i try make but dont work ^^
my code :

Code: Select all

function update(dt)
local x,y=Circle:getVelocity()
Circle:setSleep( false ) 
if love.keyboard.isDown(love.key_right) then
x= 500
end
if love.keyboard.isDown(love.key_left) then
x= -500
end
if love.keyboard.isDown(love.key_space) then
y= -500
end
Circle:setVelocity(x,y)
World:update(dt)
end
any solution welcome ^^ thank for all !
Raider
Prole
Posts: 11
Joined: Fri Jul 31, 2009 12:49 pm

Re: Need some help with Physic module ?

Post by Raider »

The code looks correct for a simple set-velocity jumping system.
Could you be more specific about what the problem is?

As in, what do you mean by, "It doesn't conserve left or right movement"?
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Denver, CO
Contact:

Re: Need some help with Physic module ?

Post by TechnoCat »

Could you post more code? It looks pretty correct to me too.
User avatar
Sardtok
Party member
Posts: 108
Joined: Thu Feb 21, 2008 2:37 pm
Location: Norway/Norge/諾威/挪威 (Yes, I'm teh back!)
Contact:

Re: Need some help with Physic module ?

Post by Sardtok »

Do you mean that you can turn around in mid-air?
Cause, if that's the problem, you would have to put in a check for whether you're in the air too before setting the x velocity.
Take off every Zigg for great rapist.
Now, outgay that!
LuaNewb
Prole
Posts: 1
Joined: Thu Aug 27, 2009 9:20 pm

Re: Need some help with Physic module ?

Post by LuaNewb »

My guess is, that, if you're making a platformer-type game and using the physics module that you found your guy sliding around on the floor like he was in a Super Mario Bros. 2 ice level; and perhaps you wrote some code to kill the X velocity when left and right where not being pressed... I'm guessing this because i've just started with Love and not 20 minuets ago did exactly the same thing ;)

If this is the case, perhaps, check that the player sprite is not colliding with the floor (i.e is in the air) before killing your x velocity.
Post Reply

Who is online

Users browsing this forum: No registered users and 110 guests