Platforming Physics

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
User avatar
tcmg
Prole
Posts: 1
Joined: Tue Dec 30, 2008 6:20 am

Platforming Physics

Post by tcmg »

Hi all,

I've just started getting into Lua and LOVE. I've never used Lua before but I'm a big fan of JavaScript and Python - Lua reminds me of a combination of those two languages. Plus LOVE is really neat as well, especially the built-in physics. I've previously used PyGame and I think having physics provided is a big boon.

Anyway, speaking of physics, I thought a good first step to learning Lua and LOVE would be to program some platforming movement. I've setup 'the world' and created the body, attached the shape, got the ground as another shape to collide with. There's gravity, walking left, walking right and jumping. However, I'm confused as to why when ever I apply movement: walking or jumping, I find the new movement seemingly overrides the existing forces or velocity of the body. I'm not sure if the forces I'm applying are too strong? Or if I'm meant to be taking the existing speed into account when I apply new forces. I expected the physics engine to take care of that for me.

I've attached the existing code, sorry if the Lua code is hacky - I'm new to this!

Can anyone suggest why the movement is so jerky? [left and right arrow keys to move, space to jump]

PS: What's with the "obey" in everyone's avatars? Is it a requisite for using the forum? :D *edit:* ah, I just read the post urging members to do this... bizarre!
Attachments
moon.love
Simple attempt at platform movement
(12.47 KiB) Downloaded 289 times
User avatar
Dr. Magnusson
Prole
Posts: 22
Joined: Sun Jul 20, 2008 6:10 pm

Re: Platforming Physics

Post by Dr. Magnusson »

Fairly sure there's a function for getting the velocity of an object, is it not as simple as adding the two together?
User avatar
rude
Administrator
Posts: 1052
Joined: Mon Feb 04, 2008 3:58 pm
Location: Oslo, Norway

Re: Platforming Physics

Post by rude »

(I have looked into this, and I also find it peculiar. You made me realize that I've never really used impulses/forces that much during testing, I've generally just been using gravity. :ehem: I always look at the source to check for obvious bugs when people are having problems, but I couldn't find any this time. Yes, I found it necessary to parenthesize my entire post).
User avatar
osgeld
Party member
Posts: 303
Joined: Sun Nov 23, 2008 10:13 pm

Re: Platforming Physics

Post by osgeld »

rude wrote: I just thought it would be funny if all the avatars on every page said "OBEY" (OBEY, OBEY, OBEY). New users will be all liek "ZOMFG, why do all the avatars say `OBEY`lol". It will be funny. Some day ...
well um, heh :|
Post Reply

Who is online

Users browsing this forum: No registered users and 72 guests