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.
Physics tutorial question
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
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.
Hello, I am not dead.
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.
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
You could draw the image with width and height of 2 times the radius of the shape:
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.
Code: Select all
love.graphics.circle("fill", bodies[1]:getX(), bodies[1]:getY(), shapes[1]:getRadius(), 20)
Code: Select all
love.graphics.draw(theImage, bodies[1]:getX()-shapes[1]:getRadius(), bodies[1]:getY()-shapes[1]:getRadius())
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.
Re: Physics tutorial question
Finally, someone else points out the big fat warning happily camping on the physics module documentation.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.
Hello, I am not dead.
- tentus
- Inner party member
- Posts: 1060
- Joined: Sun Oct 31, 2010 7:56 pm
- Location: Appalachia
- Contact:
Re: Physics tutorial question
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.zac352 wrote:Finally, someone else points out the big fat warning happily camping on the physics module documentation.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.
Kurosuke needs beta testers
Re: Physics tutorial question
I'll make a lightweight physics library. Eventually.
Hello, I am not dead.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Physics tutorial question
Perhaps we could have a community physics library, meant as a sort of frontend to love.physics?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.
Help us help you: attach a .love.
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?
Re: Physics tutorial question
That's the first thing I did, too. Spawned a bunch of boxes and started knocking them around.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.
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot], Majestic-12 [Bot], MrFariator and 4 guests