So if I add a rect to a variable like so
box = pygame.Rect(x, y, w, h) How do I check if the variable rect holds a pygame.Rect? Ideally it would return something similar to this
int = 9 #int is not a rect #box is a rect Use isinstance(object, classinfo):
Return
Trueif the object argument is an instance of the classinfo argument [...]
if isinstance(box, pygame.Rect): print('is a rect') else: print('is not a rect')
Rectthen it should always keepRect- don't mess it. And if you want to keep different objects on list - ie. Player, Enemy, etc. then all of them should have exactly the same methods -draw,update, etc. instead ofdraw_player,draw_enemy,update_player,update_enemy- and then you don't have to check class to decide if you have to usedraw_playerordraw_enemy- you always has to usedraw.