Re: [pygame] Line collision detection?

2012-02-21 Thread Julian Marchant
Ah, the linear equation. I'd forgotten about it, silly me. Thanks! I think I can get that to work easily enough even without examples. Regarding using multiple lines, that would be the ideal solution (it seems you could do even better by having four lines for each object, one for each corner),

Re: [pygame] Line collision detection?

2012-02-21 Thread Silver
On 2/20/2012 1:50 PM, Julian Marchant wrote: Hi, I tried searching the internet for an answer, but didn't find anything, so I'll ask here. One problem with normal collision detection I'm sure we're all aware of is the problem that objects moving too fast can pass through other objects

[pygame] Line collision detection?

2012-02-20 Thread Julian Marchant
Hi, I tried searching the internet for an answer, but didn't find anything, so I'll ask here. One problem with normal collision detection I'm sure we're all aware of is the problem that objects moving too fast can pass through other objects without a collision happening. I'm experiencing this

Re: [pygame] Line collision detection?

2012-02-20 Thread Sam Bull
Just a quick idea off the top of my head. What if you just get a rect covering from the bullets previous position to the bullets new position? Quick psuedo-code: xpos = min(old.left, new.left) xpos2 = max(old.right, new.right) width = pos2 - pos #Do the same for y/height Rect(xpos, ypos, width,

Re: [pygame] Line collision detection?

2012-02-20 Thread Ian Mallett
On Mon, Feb 20, 2012 at 3:58 PM, Sam Bull sam.hack...@sent.com wrote: Just a quick idea off the top of my head. What if you just get a rect covering from the bullets previous position to the bullets new position? What about the diagonal motion? I'd recommend something similar, though. Just

Re: [pygame] Line collision detection?

2012-02-20 Thread Miriam English
You could use the point of intersection between two lines. One line is the bullet trajectory. The other line is the target trajectory. You have to take into account the time of the intersection too. If the intersection falls inside the target at the right time for both projectile and target

Re: [pygame] Line collision detection?

2012-02-20 Thread stabbingfinger
Or if you like spoilers maybe somebuddy has some Python code you can rip, like this guy: http://code.google.com/p/gummworld2/source/browse/branches/tiled2/gamelib/gummworld2/geometry.py Specifically, functions line_intersects_line and point_in_poly. Gumm On Mon, Feb 20, 2012 at 3:33 PM,