creating an object in pyqt4 python -


here's code pygame ive created. can create object in pyqt4 one? create array of object has own attributes. or there better way of creating it? thanks

main.py:

   comp = pygame.sprite.group()     dic = [{"name":"aa","loc":[30,170],"status":0},            {"name":"bb","loc":[130,170],"status":0},            {"name":"cc","loc":[230,170],"status":1}]      in range(len(dic)):         comp.add(pcsprite(dic[i])) 

mysprites.py:

class pcsprite(pygame.sprite.sprite):     image = none     pcname = ""     location =""     status=""       def __init__(self,data):         pygame.sprite.sprite.__init__(self)         self.pcname = data['name']         self.status = data['status']         self.location = data['loc']          if self.status ==1:              pcsprite.image = pygame.image.load("res/images/x.png")         else:             pcsprite.image = pygame.image.load("res/images/y.png")          self.image = pcsprite.image         # make our top-left corner passed-in location.         self.rect = self.image.get_rect()         self.rect.topleft = self.location      def clicked(self, target):         hitbox = self.rect.inflate(-5, -5)         return hitbox.colliderect(target)      def hovered(self, target):         hitbox = self.rect.inflate(-5, -5)         return hitbox.colliderect(target) 


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -