def choose_character(self, character): """Handles player choosing which token want to use in the game Args: character (str): name of the token selected by player """ self.character_chosen = character char_button = self.ids[character + '_btn'] if self.previous_btn: self.previous_btn.remove_widget(self.previous_overlay) overlay = Image(source='images/Selected.png') overlay.center = char_button.center char_button.add_widget(overlay) self.previous_btn = char_button self.previous_overlay = overlay
def level_accomplished(self): self.app.sound['accomplished'].play() # store score in config: (i have to convert the string to a list to do specific char writing) levels_before = list(self.app.config.get('GamePlay', 'Levels')) levels_before[self.level - 1] = '1' self.app.config.set('GamePlay', 'Levels', "".join(levels_before)) self.app.config.write() # show up a little image with animation: size*2 and out_bounce and the wait 1 sec image = Image(source='graphics/accomplished.png', size_hint=(None, None), size=(200, 200)) image.center=self.center animation = Animation(size=(350, 416), duration=1, t='out_bounce') animation &= Animation(center=self.center, duration=1, t='out_bounce') animation += Animation(size=(350, 416), duration=1) # little hack to sleep for 1 sec self.add_widget(image) animation.start(image) animation.bind(on_complete=self.accomplished_animation_complete)
def level_accomplished(self): self.app.sound['accomplished'].play() # store score in config: (i have to convert the string to a list to do specific char writing) levels_before = list(self.app.config.get('GamePlay', 'Levels')) levels_before[self.level - 1] = '1' self.app.config.set('GamePlay', 'Levels', "".join(levels_before)) self.app.config.write() # show up a little image with animation: size*2 and out_bounce and the wait 1 sec image = Image(source='graphics/accomplished.png', size_hint=(None, None), size=(200, 200)) image.center = self.center animation = Animation(size=(350, 416), duration=1, t='out_bounce') animation &= Animation(center=self.center, duration=1, t='out_bounce') animation += Animation(size=(350, 416), duration=1) # little hack to sleep for 1 sec self.add_widget(image) animation.start(image) animation.bind(on_complete=self.accomplished_animation_complete)
def primary_image(self): frac = 0.3 img = Image(source='img/sun/generic_sun.png',color=self.color,mipmap=True,center=self.location.tolist(),allow_stretch=False,size_hint=(None, None),size=(round(75*frac*self.radius), round(75*frac*self.radius))) img.center=self.location.tolist() return img