Exemple #1
0
    def __init__(self, name, pos=None):
        pygame.sprite.Sprite.__init__(self)

	self.cfg = res.SPRITE.get(name, "ERROR")

	# display
	self.surfaces = res.get_image_surface(name)

	self.width, self.height = self.cfg["size"]
	if not pos: pos = (0, 0)
        self.rect = pygame.Rect(pos[0], pos[1], self.width, self.height)

	self.rate = self.cfg.get("rate", 100)
	self.layer = self.cfg.get("layer", LAYER)

	self.image = None

	# logic
	self.life = self.cfg.get("life", 1)
	self.cash = self.cfg.get("cash", 1)

	# start
	self.change_action("move")

	#FishAll.add(self)
	self._dietime = 0
	self.last_player = -1
Exemple #2
0
    	def __init__(self, name, pid, pos):
		pygame.sprite.Sprite.__init__(self)

		self.cfg = res.SPRITE.get("cannon", "ERROR")

		# display
		self.img_cannonbase = res.get_image_surface("cannonbase")[0]
		self.surf_cannon = res.get_image_surface("cannon")
		self.img_cannons = [self.surf_cannon[x] for x in xrange(pid*5, pid*5+5)]
		self.img_cannon = pygame.Surface((48, 80))
		self.img_cannon.blit(self.img_cannons[1], (0,0))
		self.img_cannon.set_colorkey((0,0,0))
		#self.img_cannon.scroll(0, -10)
		#self.img_cannon = self.img_cannon.subsurface(cut_rect)
		
		self.pos = pos
		self.rect = pygame.Rect(pos[0], pos[1], 101, 77)
		self.rect_cannon = pygame.Rect(pos[0] + 26, pos[1], 48, 65)
		self.bullet_pos = [ pos[0]+50, pos[1]+36 ]

		self.font = pygame.font.Font(None, 16)
		self.font.set_bold(True)
		self.cash_pos = (pos[0]+14, pos[1]+58)
		self.score_pos = (pos[0]+52, pos[1]+58)

		# logic
		self.pid = pid
		self.cash = 5000
		self.score = 0
		self.direction = 0
		self.power = 1.0

		self.fire_time = 0

		# start
		self.action = "move"
		self.change_action("move")

		self.need_redraw_cannon = True