python - Detecting sprite object within a sprite group on collision -
i new pygame , working on distributed peer-peer multiplayer game. tried doing following not able figure out how.
i have player class , enemy class. player , enemies part of different sprite groups. in 4 player game there 1 player object , 3 enemy objects, when player fires , use spritecollide method check collision enemy sprite group. want identify in specific enemy has been shot within spritegroup. quite not able figure out. possible ?
seeing sounds enemy objects , player objects can same thing, maybe should have 1 common class both enemy
, player
.
this called example creature
class. based on if creature
enemy
or player
can control using enemyai
class or userinput
class.
as identifying hit, can add name
variable within each of creature
classes define upon declaring new creature
. when evaluate hits, can have function return name
of creature
hit.
Comments
Post a Comment