コード例 #1
0
ファイル: game.py プロジェクト: valeriansaliou/medius
def animer(dt):
	# Can animate?
	if scene.get() is not 'game':
		return False
	
	# Game won
	if state() is 'win' or state() is 'loose':
		cursor.set('default')
		background.scene_speed('pause')
		
		return False
	
	# Game not paused
	if not paused() and state() is not 'win' and state() is not 'loose':
		if mode.get() is 'bacteria':
			cell.creerCellule(corps)
			creerPhagocyte(corps)
			mitosis.mitose(corps)	
			projectile.creerProjectile(corps)
			dynamics.deplacerCorps(corps)
			set_state(corps)
		elif mode.get() is "virus":
			cell.creerCellule(corps)
			creerPhagocyte(corps)
			virus.creerVirus(corps)
			dynamics.deplacerCorps(corps)
			set_state(corps)

	
	# Schedule the next update
	pyglet.clock.schedule_once(animer, 0.01)
	
	return True
コード例 #2
0
ファイル: game.py プロジェクト: valeriansaliou/medius
def init(game_type):
	assert type(game_type) is str
	
	
	# Store scene (when ready)
	scene.set('game')
	
	# Store mode (when ready)
	mode.set(game_type)

	# Load the data
	data.load()

	# Not yet loaded
	if not GAME_IMAGES:
		# Main layers
		GAME_IMAGES['delay'] = pyglet.image.load('./data/img/backgrounds/game.delay.bg.png')
		GAME_IMAGES['pause'] = pyglet.image.load('./data/img/backgrounds/game.pause.bg.png')
		GAME_IMAGES['win'] = pyglet.image.load('./data/img/backgrounds/game.end.win.bg.png')
		GAME_IMAGES['loose'] = pyglet.image.load('./data/img/backgrounds/game.end.loose.bg.png')
		
		# Sprites
		GAME_IMAGES['projectile'] = pyglet.image.load(data.get_image('projectile'))
		GAME_IMAGES['bacteria'] = pyglet.image.load(data.get_image('bacteria'))
		GAME_IMAGES['virus'] = pyglet.image.load(data.get_image("virus"))
		GAME_IMAGES['cell'] = pyglet.image.load(data.get_image('cellule'))
		GAME_IMAGES['cell1'] = pyglet.image.load(data.get_image('cellule1'))
		GAME_IMAGES['cell2'] = pyglet.image.load(data.get_image('cellule2'))
		GAME_IMAGES['cell3'] = pyglet.image.load(data.get_image('cellule3'))
		GAME_IMAGES['phagocyte'] = pyglet.image.load(data.get_image('Phagocyte'))
	
	# Faster backgrounds
	background.scene_speed('game')
	
	# No game cursor
	cursor.disable()
	
	# Game music
	if game_type is 'bacteria':
		music.play(data.get_musique())
	else:
		music.play('04')
	
	# Launch the game
	launch()
	
	# Process first update
	animer(0)
	
	return True
コード例 #3
0
ファイル: levels.py プロジェクト: valeriansaliou/medius
def init():
	# Not yet loaded
	if not LEVELS_IMAGES:
		# Main layers
		LEVELS_IMAGES['select'] = pyglet.image.load('./data/img/backgrounds/levels.select.bg.png')
		LEVELS_IMAGES['bottom'] = pyglet.image.load('./data/img/backgrounds/menu.bottom.bg.png')
		
		# UI images
		LEVELS_IMAGES['fight_button'] = pyglet.image.load('./data/img/buttons/levels.fight.button.png')
		LEVELS_IMAGES['help_button'] = pyglet.image.load('./data/img/buttons/levels.help.button.png')
		LEVELS_IMAGES['logo'] = pyglet.image.load('./data/img/logos/levels.logo.png')
		LEVELS_IMAGES['back_button'] = pyglet.image.load('./data/img/buttons/levels.back.button.png')
		
		# UI labels
		LEVELS_IMAGES['bacteria_label'] = pyglet.image.load('./data/img/labels/levels.bacteria.label.png')
		LEVELS_IMAGES['virus_label'] = pyglet.image.load('./data/img/labels/levels.virus.label.png')
		
		# UI texts
		LEVELS_IMAGES['bacteria_text'] = pyglet.image.load('./data/img/texts/levels.bacteria.text.png')
		LEVELS_IMAGES['virus_text'] = pyglet.image.load('./data/img/texts/levels.bacteria.text.png')
		
		# UI buttons
		LEVELS_IMAGES['difficulty_easy_disabled'] = pyglet.image.load('./data/img/buttons/levels.difficulty.easy.disabled.png')
		LEVELS_IMAGES['difficulty_easy_enabled'] = pyglet.image.load('./data/img/buttons/levels.difficulty.easy.enabled.png')
		
		LEVELS_IMAGES['difficulty_medium_disabled'] = pyglet.image.load('./data/img/buttons/levels.difficulty.medium.disabled.png')
		LEVELS_IMAGES['difficulty_medium_enabled'] = pyglet.image.load('./data/img/buttons/levels.difficulty.medium.enabled.png')
		
		LEVELS_IMAGES['difficulty_hard_disabled'] = pyglet.image.load('./data/img/buttons/levels.difficulty.hard.disabled.png')
		LEVELS_IMAGES['difficulty_hard_enabled'] = pyglet.image.load('./data/img/buttons/levels.difficulty.hard.enabled.png')
	
	# Faster backgrounds
	background.scene_speed('levels')
	
	# Levels cursor
	cursor.set('default')
	
	# Levels music
	music.play('02')
	
	# Store scene (when ready)
	scene.set('levels')
	
	return True
コード例 #4
0
ファイル: menu.py プロジェクト: valeriansaliou/medius
def init():
	global MENU_IMAGES
	
	# Not yet loaded
	if not MENU_IMAGES:
		# Top & bottom layers
		MENU_IMAGES['top'] = pyglet.image.load('./data/img/backgrounds/menu.top.bg.png')
		MENU_IMAGES['bottom'] = pyglet.image.load('./data/img/backgrounds/menu.bottom.bg.png')
		
		# UI images
		MENU_IMAGES['logo'] = pyglet.image.load('./data/img/logos/menu.logo.png')
		MENU_IMAGES['play_button'] = pyglet.image.load('./data/img/buttons/menu.play.button.png')
		MENU_IMAGES['info_button'] = pyglet.image.load('./data/img/buttons/menu.info.button.png')
		MENU_IMAGES['music_checkbox_checked'] = MENU_IMAGES['sound_checkbox_checked'] = pyglet.image.load('./data/img/checkboxes/menu.checkbox.checked.png')
		MENU_IMAGES['music_checkbox_unchecked'] = MENU_IMAGES['sound_checkbox_unchecked'] = pyglet.image.load('./data/img/checkboxes/menu.checkbox.unchecked.png')
		
		# UI labels
		MENU_IMAGES['music_label'] = pyglet.image.load('./data/img/labels/menu.music.label.png')
		MENU_IMAGES['sound_label'] = pyglet.image.load('./data/img/labels/menu.sound.label.png')
		
		# About bubble
		MENU_IMAGES['about_bubble'] = pyglet.image.load('./data/img/others/menu.about.png')
	
	# Add backgrounds
	background.add(1, 0.2)
	background.add(2, 1)
	background.add(3, -1)
	
	# Slower backgrounds
	background.scene_speed('menu')
	
	# Menu cursor
	cursor.set('default')
	
	# Menu music
	music.play('01')
	
	# Store scene (when ready)
	scene.set('menu')
	
	return True