コード例 #1
0
ファイル: ThrowedGrenade.py プロジェクト: dgalaktionov/Aleph
	def update(self, time, scene):
		self.floatX += self.speedX * time * GRENADE_SPEED
		self.floatY += self.speedY * time * GRENADE_SPEED
		self.rect.x = roundToInt(self.floatX)
		self.rect.y = roundToInt(self.floatY)

		self.timeToBoom -= time

		if self.timeToBoom <= 0:
			scene.bulletGroup.remove(self)
			scene.bulletGroup.add(Explosion(self.rect.x, self.rect.y))

			# Kill people!
			originalRect = self.rect.copy()
			self.rect.inflate_ip(80, 80)  # 80x80 area damage
			
			enemies_hit = sprite.spritecollide(self, scene.enemyGroup, False)

			for enemy in enemies_hit:
				# Friendly fire
				if self.creator.__class__.__name__ == enemy.__class__.__name__:
					continue
				enemy.receive_attack(self.atk)

			if sprite.collide_rect(self, scene.player):
				scene.player.receive_attack(self.atk)

			self.rect = originalRect  # Restore the real rect

		self.timeToStop -= time

		if self.timeToStop <= 0:
			self.speedX = 0
			self.speedY = 0
コード例 #2
0
ファイル: Bullet.py プロジェクト: martinaLopez/Aleph
	def update(self, time, scene):
		self.floatX += self.speedX * time * BULLET_SPEED
		self.floatY += self.speedY * time * BULLET_SPEED
		self.rect.x = roundToInt(self.floatX)
		self.rect.y = roundToInt(self.floatY)

		if isSolid(scene.collisionBg, self.rect.x, self.rect.y):
			scene.bulletGroup.remove(self)

		self.kill_people(scene)
コード例 #3
0
ファイル: ThrowedGrenade.py プロジェクト: martinaLopez/Aleph
	def update(self, time, scene):
		self.floatX += self.speedX * time * GRENADE_SPEED
		self.floatY += self.speedY * time * GRENADE_SPEED
		self.rect.x = roundToInt(self.floatX)
		self.rect.y = roundToInt(self.floatY)

		self.timeToBoom -= time

		if self.timeToBoom <= 0:
			scene.bulletGroup.remove(self)
			scene.bulletGroup.add(Explosion(self.rect.x, self.rect.y))

		self.timeToStop -= time

		if self.timeToStop <= 0:
			self.speedX = 0
			self.speedY = 0