ragDÖLL Physics Demo

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
CR4SH3D
Citizen
Posts: 67
Joined: Mon Mar 02, 2009 6:00 pm
Location: England
Contact:

ragDÖLL Physics Demo

Post by CR4SH3D »

This is my first attempt at learning LÖVE for a game concept i have

I will be using ragdoll physics to some extent so i tried composing a ragdoll and cant work out exactly how its done
* Are the body x y coordinates used for the top left pixel for the shapes?
* How is the polygon shape used? and can i just attatch multiple single pixel rectangles according to the image shape
* How to spawn another particle system
* Why does the foot sometimes fall off
* Do joints etc interfear with eachother if they overlap?

And lastly
* To animate the characters would the best way be to use timers and set each each position perframe and then create the ragdoll when a certain condition is met?
ragDOLL Demo v0.1.love
ragDÖLL Physics Demo v0.1
Controls:
space - applies force to head pulling body to mouse xy
click - spawn particles at feet
scroll wheel - scroll through particles
(135.28 KiB) Downloaded 685 times
User avatar
Skofo
Party member
Posts: 146
Joined: Mon Dec 22, 2008 10:55 pm

Re: ragDÖLL Physics Demo

Post by Skofo »

Yay ragDOLLs! :ultraglee:

One thing: the ragdoll's particle-emitting foot falls off after half a minute.

EDIT: But you know that. ;)
Working on: Viator
Need a 64-bit Debian package for LÖVE? Here it is!
User avatar
CR4SH3D
Citizen
Posts: 67
Joined: Mon Mar 02, 2009 6:00 pm
Location: England
Contact:

Re: ragDÖLL Physics Demo

Post by CR4SH3D »

haha yeah i know :P

might that be because the force applied is greater than the default although there's not one set? But then the other foot should fall off too :S
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: ragDÖLL Physics Demo

Post by bartbes »

Nice! Some gravity would be nice as well, though.
osuf oboys
Party member
Posts: 215
Joined: Sun Jan 18, 2009 8:03 pm

Re: ragDÖLL Physics Demo

Post by osuf oboys »

* Are the body x y coordinates used for the top left pixel for the shapes?
They specify the location of the body, nothing else. Think of it as the center of the body if you will. Shapes that are created for the body have coordinates relative the location of the body. So "body = ...newBody(world, 100, 200); newRectangularShape(body, 5, 10, 20, 4)" will create a body at (100,200) and a rectangle with center at (100,200) + (5,10) = (105,210). The rectangle stretches 20 in width and 4 in height, hence the upper left corner of the rectangle will be (100,200) + (5,10) - (20/2, 4/2) = (95, 208). If you create a rectangle with three arguments, then it will be placed at the center of the body with the second argument as width and third as height, just as the documentation says.

* How is the polygon shape used? and can i just attatch multiple single pixel rectangles according to the image shape
No, you give it up to 8 points that defines a convex polygon. The rectangle is a special case of the polygon shape. To create concave shapes (like the boots of the character), you need to add two different convex polygon shapes to the same body, e.g. the left and the right part of the boot. I would suggest that you add a key that will draw all the shapes on top of the sprites.

* How to spawn another particle system
You're practically already doing it.

* Why does the foot sometimes fall off
Note that you must save references to all bodies, shapes, and joints (until they've been destroyed) or weird stuff happens. This is the reason that it falls off. After you have fixed this, you should no longer create a new mouse joint each frame either. Also, the revolute joint for the left foot is not on both shapes, this can cause some other problems. (the left is at y=90 and the right at y=95).

* Do joints etc interfear with eachother if they overlap?
Overlap? Note though that shapes that do not have a common joint can collide with each other. In particular, the left and right foot can collide. If this is not desirable, you can set the collision masks and categories for the different parts. You may also want to tune the joints for optimal performance, e.g. by changing the frequency and maximum force.

* To animate the characters would the best way be to use timers and set each each position perframe and then create the ragdoll when a certain condition is met?
You can simply have a constant that tells how much power the physics engine has and how much power the animations have (rather than one OR the other), you could even let this be a parameter in the animation pack. Generalizing, the same constants can be used to have multiple running animations. For instance, a "sadness" animation with a weak constant together with a walking animation with a strong constant could reduce in a walk with somewhat hanging shoulders. By setting the constant differently for different parts of the animation (say, body parts), you may also have a walking animation primarily care about the legs and a fishing animation about the arms. Even if the walking cares weakly about the arms and the fishing about the legs, the result should be fairly good.

On another note, for accurate physics, you will want to rescale everything by making it at least ten times smaller, then draw it ten times bigger. This is easy to do on your own but you may also use CAMERA (http://love2d.org/forum/viewtopic.php?f=5&t=419) to do it for you and forget about it.
If I haven't written anything else, you may assume that my work is released under the LPC License - the LÖVE Community. See http://love2d.org/wiki/index.php?title=LPC_License.
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests