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
Post a Comment