Exemplo n.º 1
0
    def cast(self, c):
        # Revert if switching to biggie
        if isinstance(c.AI, c.Biggie):
            revert = Revert()
            revert.cast(c)

            # set change to 0 otherwise you get weird behaviour when
            # moving and switching
        c.player.delta_x, c.AI.delta_x = c.AI.delta_x, c.player.delta_x
        c.player, c.AI = c.AI, c.player
        # set both player and AI convo to false to prevent a conversation from starting
        c.player.convo = False
        c.AI.convo = False
        c.ACTIVE = c.player
Exemplo n.º 2
0
	def load(self):
		if os.path.exists('save/save.txt'):
			with open('save/save.txt', 'r') as f:
				
				if isinstance(self.player, Tracy):
					self.lvl_num, self.player.abilities, self.AI.abilities = pickle.load(f)
				else:
					self.lvl_num, self.AI.abilities, self.player.abilities = pickle.load(f)
				# read in level
				self.lvl_current = self.lvl_list[self.lvl_num]
				self.camera.updateCam(0, 0, self.lvl_current.level_width, self.lvl_current.level_height)
				self.player.level = self.lvl_current
				self.AI.level = self.lvl_current
				
				if isinstance(self.player, Tracy):
					revert = Revert()
					revert.cast(self)

				# reset player position
				self.player.rect.x = self.lvl_current.Px
				self.player.rect.y = self.lvl_current.Py
				self.AI.rect.x = self.lvl_current.Ax
				self.AI.rect.y = self.lvl_current.Ay
Exemplo n.º 3
0
	def update(self):
		# update camera
		self.camera.update(self.player)

		#update player
		self.active_sprites.update(self)
		if self.player.dead:
			death_sound = pygame.mixer.Sound("death.wav")
			death_sound.play()
			self.load()
			self.player.dead = False

		if self.climbing == 1:
			k = self.player.checkAbility(pygame.K_UP)
			if k is not None:
				k.cast(self)
		elif self.climbing == 2:
			k = self.player.checkAbility(pygame.K_DOWN)
			if k is not None:
				k.cast(self)

		# follow
		if self.player.delta_x > 0 and self.AI.rect.x < self.player.rect.x - FOLLOW_DIST-20 and not self.AI.locked:
			self.AI.move_right()

		elif self.player.delta_x < 0 and self.AI.rect.x > self.player.rect.right + FOLLOW_DIST and not self.AI.locked:
			self.AI.move_left()

		else:
			self.AI.stop()

		# unlock the wal ability for Biggie.

		if self.player.wallUnlocked:
			self.AI.wallUnlocked = True


		# update level
		self.lvl_current.update(self)

		# check if we've moved onto the next area

		if self.player.rect.right > self.lvl_current.level_width and self.lvl_num < len(self.lvl_list)-1:

			if isinstance(self.player, Tracy):
				revert = Revert()
				revert.cast(self)

			self.lvl_num += 1
			self.save()
			self.lvl_current = self.lvl_list[self.lvl_num]
			self.player.level = self.lvl_current
			self.AI.level = self.lvl_current

			self.player.rect.x = self.lvl_current.Px
			self.player.rect.y = self.lvl_current.Py
			self.AI.rect.x = self.lvl_current.Ax
			self.AI.rect.y = self.lvl_current.Ay

			self.camera.updateCam(0, 0, self.lvl_current.level_width, self.lvl_current.level_height)

			print(self.player.level)

			if isinstance(self.player.level, Tutorial_level):
				self.levelEnterConvo = True
				self.player.convo = True

		# go to previous area
		elif self.player.rect.left < 0 and self.lvl_num > 0:

			if isinstance(self.player, Tracy):
				revert = Revert()
				revert.cast(self)

			self.lvl_num -= 1
			self.lvl_current = self.lvl_list[self.lvl_num]
			self.player.level = self.lvl_current
			self.AI.level = self.lvl_current

			self.player.rect.y = self.lvl_current.ground_level
			self.AI.rect.y = self.lvl_current.ground_level-40
			self.player.rect.x = self.lvl_current.level_width-200
			self.AI.rect.x = self.lvl_current.level_width-200

			self.camera.updateCam(self.lvl_current.level_width-SCREEN_WIDTH, self.lvl_current.ground_level, self.lvl_current.level_width, self.lvl_current.level_height)

		elif self.player.rect.left < 0 and self.lvl_num == 0:
			self.player.rect.x = 1
			self.AI.rect.x = 1