Esempio n. 1
0
def main():
	# Create the Engine, setting up various window paramaters
	engine = Engine(640, 480, 60, 'Space Shooter')
	# Create a new GameRoom object, and set it to be the current world.
	# Setting PP.world is the 'correct' way of switching worlds.
	PP.world = GameRoom()
	# Start PyPunk!
	engine.start()
Esempio n. 2
0
	def update(self):
		if not self.world:
			return

		if self.collide_point(self.x - self.world.camera.x, self.y - self.world.camera.y, Input.mouse_x, Input.mouse_y):
			if Input.mouse_released() and self._callback:
				self._callback(*self._args, **self._kwargs)
			elif Input.mouse_down():
				self._map.play('down')
			else:
				self._map.play('over')
		else:
			self._map.play('up')

	def set_spritemap(self, asset, frame_w, frame_h):
		self._map = Spritemap(asset, frame_w, frame_h)
		self._map.add('up', [0])
		self._map.add('over', [1])
		self._map.add('down', [2])
		self.graphic = self._map
		self.set_hitbox(frame_w, frame_h)


if __name__ == '__main__':
	# Create an instance of the Engine, add a world, start it up
	engine = Engine(640, 480, 60, 'PyPunk Test')
	PP.world = GameWorld()
	engine.start()