Re: [pygame] Possible to detect collision with an image?
In that example, you need to detect a collision with any one of two triangles or a circle, excluding the other two. That could be a useful function; it's not on the wiki. Is that enough information? Or, there are some strategies for only checking collisions with nearby objects, if you need an optimization, that are on the wiki. Are they adequate? On Fri, Oct 7, 2011 at 4:51 PM, Florian Krause wrote: > Well, you could make the background of the image transparent and then > create a mask fro the pygame surface. This one can be checked for > collisions. > > Florian > > > > On Fri, Oct 7, 2011 at 11:44 PM, Alec Bennett wrote: >> I'm using an image with transparency as a Sprite. The image has an irregular >> shape: >> >> http://sinkingsensation.com/stuff/shape.png >> >> I'd like to detect collisions with it. >> >> My current strategy is to draw a polygon (pygame.draw.polygon) behind the >> image. That works, but its difficult to make the polygon accurately reflect >> the image, and I need to make a lot of them. >> >> So I'm wondering if there's some way to detect collisions with the image >> itself? >> >> Or maybe there's some clever way to draw a polygon based on an image? >> >> I don't need pixel-by-pixel accuracy, anything close would work. >> >> >> >> > > > > -- > www.fladd.de - fladd.de: Homepage of Florian Krause > blog.fladd.de - fladd's Blog: Blog of Florian Krause > intermezzo.fladd.de - Intermezzo: Music by Florian Krause and Giacomo Novembre >
Re: [pygame] Possible to detect collision with an image?
Well, you could make the background of the image transparent and then create a mask fro the pygame surface. This one can be checked for collisions. Florian On Fri, Oct 7, 2011 at 11:44 PM, Alec Bennett wrote: > I'm using an image with transparency as a Sprite. The image has an irregular > shape: > > http://sinkingsensation.com/stuff/shape.png > > I'd like to detect collisions with it. > > My current strategy is to draw a polygon (pygame.draw.polygon) behind the > image. That works, but its difficult to make the polygon accurately reflect > the image, and I need to make a lot of them. > > So I'm wondering if there's some way to detect collisions with the image > itself? > > Or maybe there's some clever way to draw a polygon based on an image? > > I don't need pixel-by-pixel accuracy, anything close would work. > > > > -- www.fladd.de - fladd.de: Homepage of Florian Krause blog.fladd.de - fladd's Blog: Blog of Florian Krause intermezzo.fladd.de - Intermezzo: Music by Florian Krause and Giacomo Novembre
[pygame] Possible to detect collision with an image?
I'm using an image with transparency as a Sprite. The image has an irregular shape: http://sinkingsensation.com/stuff/shape.png I'd like to detect collisions with it. My current strategy is to draw a polygon (pygame.draw.polygon) behind the image. That works, but its difficult to make the polygon accurately reflect the image, and I need to make a lot of them. So I'm wondering if there's some way to detect collisions with the image itself? Or maybe there's some clever way to draw a polygon based on an image? I don't need pixel-by-pixel accuracy, anything close would work.