コード例 #1
0
	def update(self, clock, player, enemies, surfaces):
		from config import keyboard, keymap

		#am i alive?
		if (self.health <= 0):
			self.alive = False

		vel = Vector2(0, 0);
		if keyboard.down(keymap.UP):
			vel.y -= 1
		elif keyboard.down(keymap.DOWN):
			vel.y += 1
		if keyboard.down(keymap.LEFT):
			vel.x -= 1
		elif keyboard.down(keymap.RIGHT):
			vel.x += 1
		self.vel = vel.normalized() * PLAYER_SPEED

		super(Player, self).update(clock, player, enemies, surfaces)

		if keyboard.downup(keymap.MAGIC):
			self.useMagic()

		# Check to see if we have touched edge of the screen
		if self.rect.left < config.TILEX * 2:
			self.gameState.nextMap("left", self.getPos())
		elif self.rect.right > config.WIDTH - config.TILEX * 2:
			self.gameState.nextMap("right", self.getPos())
		elif self.rect.top < 0:
			self.gameState.nextMap("up", self.getPos())
		elif self.rect.bottom > config.HEIGHT:
			self.gameState.nextMap("down", self.getPos())
コード例 #2
0
	def sudoNext(self):
	#Used for debugging,
		from config import keyboard, keymap
		mmap = None
		if keyboard.downup(keymap.DUP):
			mmap = self.wl.north[self.currentMap]
		elif keyboard.downup(keymap.DDOWN):
			mmap = self.wl.south[self.currentMap]
		elif keyboard.downup(keymap.DLEFT):
			mmap = self.wl.west[self.currentMap]
		elif keyboard.downup(keymap.DRIGHT):
			mmap = self.wl.east[self.currentMap]
		if mmap is not None:
			self.currentMap = mmap
			print "MAP: ", mmap
			self.environment = self.wl.getMap(mmap, self.worldMap)

			# Added for debugging purposes. Remove when not needed
			print "MAP: ", mmap
コード例 #3
0
	def update(self, clock):
		from config import keyboard, keymap
		super(TitleState, self).update(clock)
		self.tick += 1

		if self.tick < self.tickInterval/4:
			TitleState.btnStartGroup.add(self.btnStart2)
		else:
			TitleState.btnStartGroup.add(self.btnStart)

		if keyboard.downup(keymap.START):
			self.main.changeState(GameState(self.main))

		TitleState.btnStartGroup.update(clock)
		TitleState.titleGroup.update(clock)
コード例 #4
0
	def update(self, clock):
		from config import keyboard, keymap
		if keyboard.downup(keymap.MAP):
			self.show = not self.show