コード例 #1
0
ファイル: events.py プロジェクト: valeriansaliou/medius
	def on_key_press(symbol, modifiers):
		current_scene = scene.get()
		game_state=game.state()
		corps = game.GET_CORPS()

		# Escape pressed
		if symbol == key.ESCAPE:
			# Game back action
			if current_scene is 'game':
				if game.pause() is True:
					cursor.set('default')
					background.scene_speed('pause')
				
				else:
					cursor.disable()
					background.scene_speed('game')
			
			# Levels back action
			elif current_scene is 'levels':
				menu.init()
			
			# Help back action
			elif current_scene is 'help':
				scene.set('levels')
				help.slide(1)
			
			# Menu back action
			elif current_scene is 'menu':
				pyglet.app.exit()
		
		# Arrow pressed
		elif current_scene is 'game':	
			if 'Phagocyte' in corps.keys():	
				if symbol == key.UP:
					corps['Phagocyte']['pushUp'] = 1
				if symbol == key.DOWN:
					corps['Phagocyte']['pushDown'] = 1
				if symbol == key.RIGHT:
					corps['Phagocyte']['pushRight'] = 1
				if symbol == key.LEFT:
					corps['Phagocyte']['pushLeft'] = 1
		
		return True
コード例 #2
0
ファイル: events.py プロジェクト: valeriansaliou/medius
	def on_mouse_motion(x, y, dx, dy):
		current_scene = scene.get()
		
		# Menu motion
		if current_scene is 'menu':
			# Music button
			if (x >= 40 and x <= 86 and y >= 13 and y <= 59) or (x >= 116 and x <= 294 and y >= 21 and y <= 50):
				cursor.set('pointer')
			
			# Sound button
			elif (x >= 404 and x <= 450 and y >= 13 and y <= 59) or (x >= 480 and x <= 790 and y >= 21 and y <= 50):
				cursor.set('pointer')
			
			# About button
			elif x >= 932 and x <= 978 and y >= 13 and y <= 59:
				cursor.set('pointer')
			
			# Play button
			elif x >= 40 and x <= 310 and y >= 497 and y <= 572:
				cursor.set('pointer')
			
			# Default
			else:
				cursor.set('default')
		
		# Levels motion
		elif current_scene is 'levels':
			# Back button
			if x >= 20 and x <= 204 and y >= 15 and y <= 57:
				cursor.set('pointer')
			
			# Fight (bacteria) button
			elif x >= 142 and x <= 392 and y >= 199 and y <= 244:
				cursor.set('pointer')
			
			# Fight (virus) button
			elif x >= 632 and x <= 882 and y >= 199 and y <= 244:
				cursor.set('pointer')
			
			# Help (bacteria) button
			elif x >= 142 and x <= 392 and y >= 164 and y <= 198:
				cursor.set('pointer')
			
			# Help (virus) button
			elif x >= 632 and x <= 882 and y >= 164 and y <= 198:
				cursor.set('pointer')
			
			# Difficulty (easy) button
			elif x >= 452 and x <= 482 and y >= 15 and y <= 57:
				cursor.set('pointer')
			
			# Difficulty (medium) button
			elif x >= 497 and x <= 528 and y >= 15 and y <= 57:
				cursor.set('pointer')
			
			# Difficulty (hard) button
			elif x >= 542 and x <= 573 and y >= 15 and y <= 57:
				cursor.set('pointer')
			
			# Default
			else:
				cursor.set('default')
		
		# Game motion
		elif current_scene is 'game':
			# End of game motion
			if game.state() is 'win' or game.state() is 'loose':
				# Quit button
				if x >= 260 and x <= 304 and y >= 124 and y <= 172:
					cursor.set('pointer')
				
				# Menu button
				elif x >= 324 and x <= 372 and y >= 124 and y <= 166:
					cursor.set('pointer')
				
				# Retry button
				elif x >= 694 and x <= 742 and y >= 124 and y <= 172:
					cursor.set('pointer')
				
				# Default
				else:
					cursor.set('default')
			
			# Paused game motion
			elif game.paused() is True:
				# Quit button
				if x >= 341 and x <= 386 and y >= 227 and y <= 270:
					cursor.set('pointer')
				
				# Menu button
				elif x >= 405 and x <= 453 and y >= 227 and y <= 270:
					cursor.set('pointer')
				
				# Resume button
				elif x >= 647 and x <= 683 and y >= 227 and y <= 270:
					cursor.set('pointer')
				
				# Default
				else:
					cursor.set('default')
		
		return True