Note that there are some explanatory texts on larger screens.

plurals
  1. POpython pygame physics rectange - circle collision
    text
    copied!<p>Again this question is on PyParticles4.<br> <a href="https://stackoverflow.com/questions/14137475/python-ball-physics-simulation">Link to last question for reference</a></p> <p>Comment if unclear...</p> <p>I am working on a Shooter game, much like <a href="http://www.gamenet.com/game/Shooting-Games-Avalon-Siege/" rel="nofollow noreferrer">this</a>, but on a flat land with a wall that varies it's height on every turn(something for fun in the game) and with 2 players,each with a cannon that can move some distance (there's a limit, and they can't move beyond a certain amount from their start position) on each turn(the player decides if he wishes to move). </p> <p>My code so far(for the Bullet and Shooter)</p> <pre><code>class Bullet(PyParticles.Particle): def hit(self,shooterlist): for shoot in shooterlist: #confusion dist = math.hypot(dx,dy) # other funcs to added class Shooter: def __init__(self,pos,size): self.rect = pygame.Rect(pos,size) # other funcs to added </code></pre> <h2>My Problems</h2> <p>Collision of the bullet with the Shooter. Any Ideas on how to know when the bullet collides with the rect?<br> I have been advised by someone to look at all the points on the edge of the rect, and see if it is within the circle but it seems to be very slow.<br> I think something faster would be better..<br> ..<br> ..<br> <strong>Update:</strong><br> The circle can have a rect around it, which if collides with the rect, I now know when the rect is close to the circle, maybe even touching it.. How do i move forward??(Thx to PygameNerd) </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload