Physics Image Support?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Physics Image Support?
Is there a way to have image support for love.physics at the moment? I couldn't find anything on the wiki, but do any of you know a workaround?
Request Programs
If Linux were a beer, it would be shipped in open barrels so that anybody could piss in it before delivery
If Linux were a beer, it would be shipped in open barrels so that anybody could piss in it before delivery
- ghostwriter
- Prole
- Posts: 38
- Joined: Sat Dec 11, 2010 11:08 pm
Re: Physics Image Support?
Can you describe what you mean by image support for love.physics? You can draw images with love.graphics
- tentus
- Inner party member
- Posts: 1060
- Joined: Sun Oct 31, 2010 7:56 pm
- Location: Appalachia
- Contact:
Re: Physics Image Support?
He probably means something along the line of "draw this shape". (Which would be a really useful feature, btw.) You can sort of pull it off using the below:
Note that this just draws a rectangle that is the same width and height as the shape, centered on the same pivot. It cannot show you the angle, it just isn't a part of the love.graphics.rectangle function. To do that you will need to make an image (or generate it in Love) and use getAngle() to draw it at the right orientation.
Code: Select all
width = 64
height = 48
body = love.physics.newBody(world, x, y)
shape = love.physics.newRectangleShape(body, 0, 0, width, height )
love.graphics.rectangle("fill", body:getX() - (width/ 2), body:getY() - (height / 2), body:getX() + (width/ 2), body:getY() + (height / 2))
Kurosuke needs beta testers
- TechnoCat
- Inner party member
- Posts: 1611
- Joined: Thu Jul 30, 2009 12:31 am
- Location: Milwaukee, WI
- Contact:
Re: Physics Image Support?
http://love2d.org/wiki/love.graphics.rotatetentus wrote:It cannot show you the angle, it just isn't a part of the love.graphics.rectangle function. To do that you will need to make an image (or generate it in Love) and use getAngle() to draw it at the right orientation.
- ishkabible
- Party member
- Posts: 241
- Joined: Sat Oct 23, 2010 7:34 pm
- Location: Kansas USA
Re: Physics Image Support?
using the function mentioned by TechoCat (love.graphics.rotate) and love.graphics.line calls you can make any shape you want. also if you want it to draw the image with physics just get the coordinates of the physics object and the rotations of it and display the image with love.graphics.draw.
- tentus
- Inner party member
- Posts: 1060
- Joined: Sun Oct 31, 2010 7:56 pm
- Location: Appalachia
- Contact:
Re: Physics Image Support?
I honestly forgot about that one, because I never use it. (I dislike having to store a value, call a function, call the function I originally wanted, and then call a function again with the stored value... it feels like four times the work that simply having an extra parameter in the original function would solve.)TechnoCat wrote:http://love2d.org/wiki/love.graphics.rotatetentus wrote:It cannot show you the angle, it just isn't a part of the love.graphics.rectangle function. To do that you will need to make an image (or generate it in Love) and use getAngle() to draw it at the right orientation.
Kurosuke needs beta testers
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Physics Image Support?
Store a value? push/pop seems like a better fit, especially if you have more transformations going on at the same time.tentus wrote:I honestly forgot about that one, because I never use it. (I dislike having to store a value, call a function, call the function I originally wanted, and then call a function again with the stored value... it feels like four times the work that simply having an extra parameter in the original function would solve.)
Help us help you: attach a .love.
- tentus
- Inner party member
- Posts: 1060
- Joined: Sun Oct 31, 2010 7:56 pm
- Location: Appalachia
- Contact:
Re: Physics Image Support?
I had alpha on my mind when I wrote that, so I didn't even consider push/pop, I should have. Still, that's three lines of code for what could be one.
Kurosuke needs beta testers
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Physics Image Support?
It is mostly useful as a different "context", that is if you need to draw more than one object transformed, for example if the whole world rotates, except for the HUD.tentus wrote:I had alpha on my mind when I wrote that, so I didn't even consider push/pop, I should have. Still, that's three lines of code for what could be one.
Help us help you: attach a .love.
Re: Physics Image Support?
/me is stupid.
I didn't look at the tutorial code properly, and I thought that love.physics automatically drew the shape, as tentus said would be a good feature.
Ignore my question, I now know that I can just draw the shape, draw the image, and make some code to keep them the same x and y.
God I feel so stupid.
I didn't look at the tutorial code properly, and I thought that love.physics automatically drew the shape, as tentus said would be a good feature.
Ignore my question, I now know that I can just draw the shape, draw the image, and make some code to keep them the same x and y.
God I feel so stupid.
Request Programs
If Linux were a beer, it would be shipped in open barrels so that anybody could piss in it before delivery
If Linux were a beer, it would be shipped in open barrels so that anybody could piss in it before delivery
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 9 guests