## Physics tutorial question

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Czrlos
Prole
Posts: 14
Joined: Wed Nov 10, 2010 9:09 pm

### Physics tutorial question

Hi everyone, in the physics tutorial http://love2d.org/wiki/Tutorial:Physics,I want to know If it's possible to have an image instead of the ball shape as a physic's object, and if it is can you indicate me how?
Sorry to bother you people with such simple question but I'm new to programming.

zac352
Party member
Posts: 496
Joined: Sat Aug 28, 2010 8:13 pm
Contact:

### Re: Physics tutorial question

All I can think of for something like that is cutting the image into small rectangles connected with joints. Or maybe a function to edge detect on the image.

ninwa
Party member
Posts: 118
Joined: Tue Oct 12, 2010 1:21 am
Location: Metro Detroit
Contact:

### Re: Physics tutorial question

Zac is right. I don't think there's anyway to assign an image to a shape, you have to keep track of them yourself.

vrld
Party member
Posts: 917
Joined: Sun Apr 04, 2010 9:14 pm
Location: Germany
Contact:

### Re: Physics tutorial question

The shape is only used internally for collisions. You can have a circle shape but in fact draw an image instead of a circle. Instead of using

Code: Select all

love.graphics.circle("fill", bodies[1]:getX(), bodies[1]:getY(), shapes[1]:getRadius(), 20)
You could draw the image with width and height of 2 times the radius of the shape:

Code: Select all

love.graphics.draw(theImage, bodies[1]:getX()-shapes[1]:getRadius(), bodies[1]:getY()-shapes[1]:getRadius())
You should only do this if the image you are using is showing something that is approximately a circle though, otherwise you should use a rectangle shape.

Anyway, as the hammer suggests, you should probably not touch the physics module for a while. At least until you are comfortable with the basic concepts of both LÖVE and Lua.
I have come here to chew bubblegum and kick ass... and I'm all out of bubblegum.

hump | HC | SUIT | moonshine

zac352
Party member
Posts: 496
Joined: Sat Aug 28, 2010 8:13 pm
Contact:

### Re: Physics tutorial question

vrld wrote:Anyway, as the hammer suggests, you should probably not touch the physics module for a while. At least until you are comfortable with the basic concepts of both LÖVE and Lua.
Finally, someone else points out the big fat warning happily camping on the physics module documentation.

tentus
Inner party member
Posts: 1060
Joined: Sun Oct 31, 2010 7:56 pm
Location: Appalachia
Contact:

### Re: Physics tutorial question

zac352 wrote:
vrld wrote:Anyway, as the hammer suggests, you should probably not touch the physics module for a while. At least until you are comfortable with the basic concepts of both LÖVE and Lua.
Finally, someone else points out the big fat warning happily camping on the physics module documentation.
The problem is, there is not an alternative readily offered up. When I started my game, it was much easier to start wildly abusing the physics than it was to figure out and write my own collision system. I know I'm not the only one doing this either. If you want to berate newcomers for using physics, make sure there is an obvious alternative that is clearly easier for them.
Kurosuke needs beta testers

zac352
Party member
Posts: 496
Joined: Sat Aug 28, 2010 8:13 pm
Contact:

### Re: Physics tutorial question

I'll make a lightweight physics library. Eventually.

Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

### Re: Physics tutorial question

tentus wrote:The problem is, there is not an alternative readily offered up. When I started my game, it was much easier to start wildly abusing the physics than it was to figure out and write my own collision system. I know I'm not the only one doing this either. If you want to berate newcomers for using physics, make sure there is an obvious alternative that is clearly easier for them.
Perhaps we could have a community physics library, meant as a sort of frontend to love.physics?

Czrlos
Prole
Posts: 14
Joined: Wed Nov 10, 2010 9:09 pm

### Re: Physics tutorial question

Hi everyone, thank you for your responses so far. Maybe I expressed myself the wrong way but a good example of what I hoped to achieve is the loveavalanche demo that comes with love2d. The balls fall because of the set gravity, colide with each other and with the stairs. I want to spawn one of those balls as the player and move it arround. Can be easily done or is it the same hammer than before?

Mud
Citizen
Posts: 98
Joined: Fri Nov 05, 2010 4:54 am

### Re: Physics tutorial question

When I started my game, it was much easier to start wildly abusing the physics than it was to figure out and write my own collision system. I know I'm not the only one doing this either.
That's the first thing I did, too. Spawned a bunch of boxes and started knocking them around.

### Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 15 guests