python - pygame - solid object collision detection -


i'm using pygame group develop game semester in school. i'm responsible building physics engine.

my question: how player object stop on collision rect object? i've scoured internet, , website answers, seems complicated grasp.

here's code particular block of code i'm trying work:

if player.rect.left == rect.right:         player.undo_right() 

this block preceded game loop. want make player consistently 20 pixels away box. i'll able apply better bounds once test work. right now, repels player sporadically, , never consistently. sometimes, i'll run it, , it'll bounce away once, , player go through rectangle freely.

i realize there numerous links on internet type of thing, wanted try collision work using simple code this. if i'm not able to, why? can exaplin simple , efficient way this?

thanks.


Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -