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
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
def init(bg_type): assert type(bg_type) is str # Not yet loaded if not HELP_IMAGES or 'bg_type' in HELP_IMAGES and HELP_IMAGES['bg_type'] is not bg_type: # Main layer & its type HELP_IMAGES['bg'] = pyglet.image.load('./data/img/backgrounds/help.' + bg_type + '.bg.png') HELP_IMAGES['bg_type'] = bg_type # Help cursor cursor.set('down') # Store scene (when ready) scene.set('help') # Slide help slide(1) return True
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