def setup(self): sound.set_volume(.25) self.rules_node = Node(parent=self) self.bg_color = ShapeNode( ui.Path.rounded_rect(0, 0, self.size.w * 0.73, self.size.h * 0.75, 10), color='#477148', position=(self.size.w/2, self.size.h/2), alpha=0.7, stroke_color='black', parent=self.rules_node) self.bg_color.line_width=2 self.bg_color_2 = ShapeNode( ui.Path.rounded_rect(0, 0, self.size.w * 0.70, self.size.h * 0.70, 10), color='#477148', position=(self.size.w/2, self.size.h/2), alpha=0.7, stroke_color='black', parent=self.rules_node) self.bg_color_2.line_width=1 self.rules_text = LabelNode('Find the Ace of Spades', ('Arial Rounded MT Bold', 38), position=(self.size.w/2, self.size.h/2 * 1.10), color='black', parent=self.rules_node) self.close_rules = LabelNode( 'CLOSE', ('American Typewriter ', 25), position=(self.size.w/2, self.size.h/2 * 0.75), color= 'black', parent=self.rules_node) self.rules_node.alpha=0 self.rules_node.run_action(A.fade_to(1, 2))
def touch_ended(self, touch): # this method is called, when user releases a finger from the screen pass if self.back_arrow_button.frame.contains_point(touch.location): sound.play_effect('8ve:8ve-tap-mellow') self.dismiss_modal_scene() if self.music_button.frame.contains_point(touch.location): sound.play_effect('8ve:8ve-tap-mellow') config.main_menu_music.play() config.music_on = True if self.no_music_button.frame.contains_point(touch.location): sound.play_effect('8ve:8ve-tap-mellow') config.main_menu_music.pause() config.music_on = False if self.sound_effects_button.frame.contains_point(touch.location): sound.set_volume(50) sound.play_effect('8ve:8ve-tap-mellow') config.sound_effects_on = True if self.no_sound_effects_button.frame.contains_point(touch.location): sound.play_effect('8ve:8ve-tap-mellow') sound.set_volume(0) config.sound_effects_on = False if self.girl_button.frame.contains_point(touch.location): sound.play_effect('8ve:8ve-tap-mellow') self.girl_button_down = True self.choose_character() elif self.boy_button.frame.contains_point(touch.location): sound.play_effect('8ve:8ve-tap-mellow') self.girl_button_down = False self.choose_character()
def setup(self): sound.load_effect('Beep') sound.set_volume(1.0) self.alarm_timer = 0 self.bg_red = True self.timer = 180 self.start_time = 0.0 self.running = False self.dt = 0.0 self.alert = False # gesture recognition self.gesture = Gesture.TAP self.start_touches = {} self.touch_count = {} #Render all the digits as individual images: self.numbers = {} font_size = 200 if self.size.w > 700 else 100 for s in chain(string.digits, [':', '.']): #render_text returns a tuple of #an image name and its size. self.numbers[s] = render_text(s, 'Helvetica-Bold', font_size)
def touch_began(self, touch): if touch.location in self.close_rules.frame: self.rules_node.run_action( A.sequence( A.fade_to(0, 2), A.wait(1), A.call(self.dismiss_scene))) sound.set_volume(.6)
async def watch_living_video(cid): import sound sound.set_honors_silent_switch(False) sound.set_volume(1) sound.play_effect('piano:D3') json_response = await bilibili.request_playurl(cid) print(json_response) if not json_response['code']: data = json_response['data'] print(data) webbrowser.open(data)
def touch_began(self, touch): # this method is called, when user touches the screen x, y = touch.location if self.fire_button.frame.contains_point(touch.location): self.create_new_ball() if config.sound == True: sound.set_volume(50) sound.play_effect('8ve:8ve-beep-bop') #elif self.pause_button.frame.contains_point(touch.location): #self.present_modal_scene(PauseScene()) else: self.paddle_target = x
def check_item_collisions(self): player_hitbox = Rect(self.player.position.x - 20, 125, 38, 75) for item in list(self.items): if item.frame.intersects(player_hitbox): if isinstance(item, Coin): sound.set_volume(.5) self.collect_item(item) elif isinstance(item, Meteor): sound.set_volume(1) self.player_hit() elif not item.parent: self.items.remove(item)
def setup(self): self.beat = 0.0 set_volume(1.0) self.sounds = ['Drums_01', 'Drums_02', 'Drums_03', 'Drums_06', 'Drums_10', 'Drums_11', 'Drums_11', 'Drums_15'] for effect in self.sounds: load_effect(effect) try: with open('Drums.data', 'r') as f: self.grid = pickle.load(f) except EOFError: self.grid = [[False for col in range(16)] for row in range(8)]
def new_game(self): for item in self.items: item.remove_from_parent() self.items = [] self.score = 0 self.score_label.text = '0' self.walk_step = -1 sound.set_volume(1) sound.play_effect('voice:male_go') self.player.texture = standing_texture self.player.position = (self.size.w/2, 110) self.player.size = (200, 76) self.speed = 1.0 self.game_over = False
def setup(self): self.beat = 0.0 set_volume(1.0) self.sounds = ['Drums_01', 'Drums_02', 'Drums_03', 'Drums_06', 'Drums_10', 'Drums_11', 'Drums_11', 'Drums_15'] for effect in self.sounds: load_effect(effect) try: with open('Drums.data', 'r') as f: self.grid = pickle.load(f) except EOFError: self.grid = [[False for col in xrange(16)] for row in xrange(8)]
def setup ( self): self.x = self.size.w * 0.5 self.y = self.size.h * 0.5 sound.set_volume(1) # 障害物のシーケンスを作成 w = 110 self.s_rect = [] while(self.size.w > w): h = 110 while(self.size.h > h ): self.s_rect.append(Rect( w, h, 40, 40 )) h += 160 else: w += 160
def touch_ended(self, touch): # if the back button is pressed, go to the main menu scene if self.back_button.frame.contains_point(touch.location): self.back_button.scale = 0.1 sound.play_effect('./assets/sounds/click.wav') self.dismiss_modal_scene() # on button for sound if self.on_button.frame.contains_point(touch.location): self.on_button.scale = 0.1 sound.play_effect('./assets/sounds/click.wav') sound.set_volume(100) # off button for sound if self.off_button.frame.contains_point(touch.location): self.off_button.scale = 0.1 sound.set_volume(0)
def setup(self): sound.set_volume(1) self.folder_setup() self.player = 'Player' self.moved = False self.background_color = '#00002A' self.first_touch = None self.board_size = 3 self.load_game() self.board = Board(self.board_size, parent=self) self.score_board = ScoreBoard(parent=self) self.add_child(self.board) self.add_child(self.score_board) self.score_board.load_highscore() self.board.load_state() self.show_menu()
def setup(self): # loading sound sound.set_volume(100) sound.play_effect('./assets/sounds/loading.wav') # create timer, so that after 2 seconds move to next scene self.start_time = time.time() # add white background self.background = SpriteNode(position=self.size / 2, color='white', parent=self, size=self.size) # company logo self.company_logo = SpriteNode('./assets/sprites/company_logo.PNG', parent=self, position=self.size / 2, scale=0.5)
def main(wav_file): # checking if this script is run properly (as an iOS extension) if not appex.is_running_extension(): print('This script is intended to be run from the sharing extension.') return None # gets selected picture picture = appex.get_image(image_type='pil') if not picture: print('No input image') return None # main operation of conversion and creating wav file pixels = np.array(Image.open(picture)) audio = picture_to_wave.image_to_sound(pixels) picture_to_wave.save_wav(wav_file, audio) # playing just created wav file sound.set_volume(1) player = sound.Player(wav_file) player.play()
def touch_ended(self, touch): # this method is called, when user releases a finger from the screen # This transitions to main menu scene if self.back_arrow_button.frame.contains_point(touch.location): sound.play_effect('8ve:8ve-tap-mellow') self.dismiss_modal_scene() # This plays music (turns on music) if self.music_button.frame.contains_point(touch.location): sound.play_effect('8ve:8ve-tap-mellow') config.main_menu_music.play() config.music_on = True # This stops music (turns off music) if self.no_music_button.frame.contains_point(touch.location): sound.play_effect('8ve:8ve-tap-mellow') config.main_menu_music.pause() config.music_on = False # This allows sound effects (turns on sound effects) if self.sound_effects_button.frame.contains_point(touch.location): sound.set_volume(50) sound.play_effect('8ve:8ve-tap-mellow') config.sound_effects_on = True # This does not allow sound effects (turns off sound effects) if self.no_sound_effects_button.frame.contains_point(touch.location): sound.play_effect('8ve:8ve-tap-mellow') sound.set_volume(0) config.sound_effects_on = False # This displays the girl robber and sets it as player for game if self.girl_button.frame.contains_point(touch.location): sound.play_effect('8ve:8ve-tap-mellow') self.girl_button_down = True self.choose_character() # This displays the boy robber and sets it as player for game elif self.boy_button.frame.contains_point(touch.location): sound.play_effect('8ve:8ve-tap-mellow') self.girl_button_down = False self.choose_character()
def set_volume(self, vol): sound.set_volume(vol)
def playSound(name, volume): sound.set_volume(volume) sound.play_effect(name)
def setup(self): # this method is called, when user moves to this scene self.score_position = Vector2() self.size_of_screen_x = self.size.x self.size_of_screen_y = self.size.y self.center_of_screen_x = self.size_of_screen_x/2 self.center_of_screen_y = self.size_of_screen_y/2 self.girl_button_down = False self.boy_button_down = False self.button_click = sound.play_effect('casino:ChipLay2', 50) self.choose_character_button_touched_once = False # This allows sound effects to play or to not play # based on whether the play sound effects or no sound effects was pressed (in settings scene) if config.sound_effects_on == True: sound.set_volume(50) elif config.sound_effects_on == False: sound.set_volume(0) # This plays or does not play music # based on whether the music or no music button was pressed (in settings scene) if config.music_on == True: config.main_menu_music.number_of_loops = -1 config.main_menu_music.play() elif config.music_on == False: config.main_menu_music.pause() # add blue sky background self.background = SpriteNode('./assets/sprites/main_menu_background.PNG', position = self.size / 2, parent = self, size = self.size) # add bush for background bush_position = Vector2() bush_position.y = (self.size_of_screen_y - (2 * (self.center_of_screen_y))) + 100 bush_position.x = self.size_of_screen_x - 100 self.bush = SpriteNode('./assets/sprites/bush.PNG', parent = self, position = bush_position, scale = 0.45) # add bush for background bush_2_position = Vector2() bush_2_position.y = (self.size_of_screen_y - (2 * (self.center_of_screen_y))) + 100 bush_2_position.x = (self.size_of_screen_x - (2 * (self.center_of_screen_x))) + 100 self.bush_2 = SpriteNode('./assets/sprites/bush.PNG', parent = self, position = bush_2_position, scale = 0.45) # This shows home button back_arrow_button_position = Vector2() back_arrow_button_position.y = self.size_of_screen_y - 90 back_arrow_button_position.x = (self.size_of_screen_x - (2 * (self.center_of_screen_x))) + 80 self.back_arrow_button = SpriteNode('./assets/sprites/back_arrow_button.PNG', parent = self, position = back_arrow_button_position, scale = 0.6) # This shows music button music_button_position = Vector2() music_button_position.y = self.size_of_screen_y - 300 music_button_position.x = self.center_of_screen_x - 360 self.music_button = SpriteNode('./assets/sprites/volume_button.PNG', parent = self, position = music_button_position, scale = 0.15) # This shows no music button no_music_button_position = Vector2() no_music_button_position.y = self.size_of_screen_y - 300 no_music_button_position.x = self.center_of_screen_x - 150 self.no_music_button = SpriteNode('./assets/sprites/no_volume_button.PNG', parent = self, position = no_music_button_position, scale = 0.15) # This shows sound effects button sound_effects_button_position = Vector2() sound_effects_button_position.y = (self.size_of_screen_y - (2 * (self.center_of_screen_y))) + 100 sound_effects_button_position.x = self.center_of_screen_x - 360 self.sound_effects_button = SpriteNode('./assets/sprites/volume_button.PNG', parent = self, position = sound_effects_button_position, scale = 0.15) # This shows no sound effects button no_sound_effects_button_position = Vector2() no_sound_effects_button_position.y = (self.size_of_screen_y - (2 * (self.center_of_screen_y))) + 100 no_sound_effects_button_position.x = self.center_of_screen_x - 150 self.no_sound_effects_button = SpriteNode('./assets/sprites/no_volume_button.PNG', parent = self, position = no_sound_effects_button_position, scale = 0.15) # This shows boy robber button boy_button_position = Vector2() boy_button_position.y = self.size_of_screen_y - 310 boy_button_position.x = self.size_of_screen_x - 155 self.boy_button = SpriteNode('./assets/sprites/boy_button.PNG', parent = self, position = boy_button_position, scale = 0.3) # This shows girl robber button girl_button_position = Vector2() girl_button_position.y = self.size_of_screen_y - 310 girl_button_position.x = self.center_of_screen_x + 145 self.girl_button = SpriteNode('./assets/sprites/girl_button.PNG', parent = self, position = girl_button_position, scale = 0.3) # This shows settings title label settings_title_position = Vector2() settings_title_position.y = self.size_of_screen_y - 100 settings_title_position.x = self.center_of_screen_x self.settings_title = SpriteNode('./assets/sprites/settings_title.PNG', parent = self, position = settings_title_position, scale = 0.45) # This shows music label music_label_position = Vector2() music_label_position.y = self.size_of_screen_y - 200 music_label_position.x = self.center_of_screen_x - 360 self.music_label = LabelNode(text = 'Music', font = ('Marker Felt', 45), color = 'black', parent = self, position = music_label_position) # This shows sound effects label sound_effects_label_position = Vector2() sound_effects_label_position.y = (self.size_of_screen_y - (2 * (self.center_of_screen_y))) + 200 sound_effects_label_position.x = self.center_of_screen_x - 285 self.sound_effects = LabelNode(text = 'Sound Effects', font = ('Marker Felt', 45), color = 'black', parent = self, position = sound_effects_label_position) character_gender_label_position = Vector2() character_gender_label_position.y = self.size_of_screen_y - 200 character_gender_label_position.x = self.size_of_screen_x - 260 self.character_gender = LabelNode(text = 'Choose Character', font = ('Marker Felt', 45), parent = self, color = 'black', position = character_gender_label_position) # This shows boy label (for boy robber button) boy_label_position = Vector2() boy_label_position.y = self.size_of_screen_y - 415 boy_label_position.x = self.size_of_screen_x - 155 self.boy = LabelNode(text = 'Boy', font = ('Marker Felt', 35), parent = self, color = 'black', position = boy_label_position) # This shows girl label (for girl robber button) girl_label_position = Vector2() girl_label_position.y = self.size_of_screen_y - 415 girl_label_position.x = self.center_of_screen_x + 145 self.girl = LabelNode(text = 'Girl', font = ('Marker Felt', 35), parent = self, color = 'black', position = girl_label_position) robber_position = Vector2() robber_position.y = self.center_of_screen_y - 150 robber_position.x = self.center_of_screen_x + 260 self.robber = SpriteNode(config.gender_type, parent = self, position = robber_position, scale = 0.135)
def setup(self): sound.set_volume(1) self.root_layer = Layer(self.bounds) self.user_input = {'ans': '', 'text': ''} self.buttons = [] self.create_buttons()
def update(self): # this method is called, hopefully, 60 times a second if config.gamescene == True: config.gamescene = False self.dismiss_modal_scene() self.move_paddle() if (self.started == False): self.load_level(levels[self.level]) self.started = True # check every update to see if a ball has touched a brick else: pass #move the ball self.Ball.position = self.Ball.position + self.ball_velocity # now check if the ball has touched the paddle if self.Ball.frame.intersects(self.paddle.frame): # you should change the velocity to a different angle here self.ball_velocity.y = self.ball_velocity.y * (-1) if config.sound == True: sound.set_volume(50) sound.play_effect('8ve:8ve-tap-mellow') else: sound.set_volume(0) # bounce ball off walls if self.Ball.position.y <= 0: self.ball_velocity.y = self.ball_velocity.y * (0) self.present_modal_scene(GameOver()) # really it should not bounce, the game should end if self.Ball.position.x <= 0: self.ball_velocity.x = self.ball_velocity.x * (-1) if self.Ball.position.x >= self.size_of_screen_x: self.ball_velocity.x = self.ball_velocity.x * (-1) if self.Ball.position.y >= self.size_of_screen_y: self.ball_velocity.y = self.ball_velocity.y * (-1) if self.size.w > 760: #iPad brick_w, brick_h = 64, 32 else: #iPhone brick_w, brick_h = 32, 16 if len(self.bricks) > 0 and len(self.shoot_ball) > 0: #print('missile check') for brick in self.bricks: for shoot in self.shoot_ball: if brick.frame.contains_rect(shoot.frame): shoot.remove_from_parent() self.shoot_ball.remove(shoot) brick.remove_from_parent() self.bricks.remove(brick) if len(self.bricks) > 0 and len(self.Balls) > 0: for brick in self.bricks: for self.Ball in self.Balls: if brick.frame.contains_rect(self.Ball.frame): brick.remove_from_parent() self.bricks.remove(brick) if self.Ball.frame.intersects(brick.frame): #self.ball_velocity.y = self.ball_velocity.y * (-1) self.ball_velocity.y = self.ball_velocity.y * (-1)
def setup(self): # this method is called, when user moves to this scene self.score_position = Vector2() self.size_of_screen_x = self.size.x self.size_of_screen_y = self.size.y self.center_of_screen_x = self.size_of_screen_x / 2 self.center_of_screen_y = self.size_of_screen_y / 2 # This allows sound effects to play or to not play # based on whether the play sound effects or no sound effects was pressed (in settings scene) if config.sound_effects_on == True: sound.set_volume(50) elif config.sound_effects_on == False: sound.set_volume(0) # This plays or does not play music # based on whether the music or no music button was pressed (in settings scene) if config.music_on == True: config.main_menu_music.play() elif config.music_on == False: config.main_menu_music.pause() # add blue sky background self.background = SpriteNode( './assets/sprites/main_menu_background.PNG', position=self.size / 2, parent=self, size=self.size) # add bush on right (for background) bush_position = Vector2() bush_position.y = (self.size_of_screen_y - (2 * (self.center_of_screen_y))) + 100 bush_position.x = self.size_of_screen_x - 100 self.bush = SpriteNode('./assets/sprites/bush.PNG', parent=self, position=bush_position, scale=0.45) # add bush on left (for background) bush_2_position = Vector2() bush_2_position.y = (self.size_of_screen_y - (2 * (self.center_of_screen_y))) + 100 bush_2_position.x = (self.size_of_screen_x - (2 * (self.center_of_screen_x))) + 100 self.bush_2 = SpriteNode('./assets/sprites/bush.PNG', parent=self, position=bush_2_position, scale=0.45) # This shows game logo game_logo_position = Vector2() game_logo_position.y = self.center_of_screen_y + 50 game_logo_position.x = self.center_of_screen_x + 100 self.game_logo = SpriteNode('./assets/sprites/game_logo.PNG', parent=self, position=game_logo_position, scale=0.45) # This shows start button start_button_position = Vector2() start_button_position.y = self.center_of_screen_y - 130 start_button_position.x = self.center_of_screen_x - 60 self.start_button = SpriteNode('./assets/sprites/start_button.PNG', parent=self, position=start_button_position, scale=0.23) # This shows settings button settings_button_position = Vector2() settings_button_position.y = self.center_of_screen_y - 200 settings_button_position.x = self.center_of_screen_x - 60 self.settings_button = SpriteNode( './assets/sprites/settings_button.PNG', parent=self, position=settings_button_position, scale=0.23) # This shows credits button credits_button_position = Vector2() credits_button_position.y = self.center_of_screen_y - 270 credits_button_position.x = self.center_of_screen_x - 60 self.credits_button = SpriteNode('./assets/sprites/credits_button.PNG', parent=self, position=credits_button_position, scale=0.23)
def set_volume(self, vol): soundOrig.set_volume(vol)
def setup(self): # this method is called, when user moves to this scene self.score_position = Vector2() self.size_of_screen_x = self.size.x self.size_of_screen_y = self.size.y self.center_of_screen_x = self.size_of_screen_x / 2 self.center_of_screen_y = self.size_of_screen_y / 2 # This allows sound effects to play or to not play # based on whether the play sound effects or no sound effects was pressed (in settings scene) if config.sound_effects_on == True: sound.set_volume(50) elif config.sound_effects_on == False: sound.set_volume(0) # This plays or does not play music # based on whether the music or no music button was pressed (in settings scene) if config.music_on == True: config.main_menu_music.play() elif config.music_on == False: config.main_menu_music.pause() # add blue sky background self.background = SpriteNode( './assets/sprites/main_menu_background.PNG', position=self.size / 2, parent=self, size=self.size) # add bush on right (for background) bush_position = Vector2() bush_position.y = (self.size_of_screen_y - (2 * (self.center_of_screen_y))) + 100 bush_position.x = self.size_of_screen_x - 100 self.bush = SpriteNode('./assets/sprites/bush.PNG', parent=self, position=bush_position, scale=0.45) # add bush on left (for background) bush_2_position = Vector2() bush_2_position.y = (self.size_of_screen_y - (2 * (self.center_of_screen_y))) + 100 bush_2_position.x = (self.size_of_screen_x - (2 * (self.center_of_screen_x))) + 100 self.bush_2 = SpriteNode('./assets/sprites/bush.PNG', parent=self, position=bush_2_position, scale=0.45) # This shows yes button yes_button_position = Vector2() yes_button_position.y = self.size_of_screen_y - 500 yes_button_position.x = self.center_of_screen_x - 250 self.yes_button = SpriteNode('./assets/sprites/yes_button.PNG', parent=self, position=yes_button_position, scale=0.3) # This shows no button no_button_position = Vector2() no_button_position.y = self.size_of_screen_y - 500 no_button_position.x = self.center_of_screen_x + 250 self.no_button = SpriteNode('./assets/sprites/no_button.PNG', parent=self, position=no_button_position, scale=0.3) # This ask user to return to levels scene (if level 3 completed) # or to go to next level (if below level 3) if config.level_difficulty < 5: self.text = 'Would you like to go to the next level?' else: self.text = 'You completed all the levels! Return to levels scene?' self.no_button.remove_from_parent() self.yes_button.remove_from_parent() self.yes_button = SpriteNode('./assets/sprites/yes_button.PNG', parent=self, position=(self.center_of_screen_x, yes_button_position.y), scale=0.3) # This displays the set question from above go_to_next_level_label_position = Vector2() go_to_next_level_label_position.y = self.center_of_screen_y + 100 go_to_next_level_label_position.x = self.center_of_screen_x self.go_to_next_level_label = LabelNode( text=self.text, font=('Marker Felt', 45), color='black', parent=self, position=go_to_next_level_label_position)
# coding: utf-8 # https://forum.omz-software.com/topic/2512/no-sound-when-i-run-a-script-at-all import sound sound.set_honors_silent_switch(False) sound.set_volume(1) sound.play_effect('piano:D3')
def setup(self): # this method is called, when user moves to this scene self.score_position = Vector2() self.size_of_screen_x = self.size.x self.size_of_screen_y = self.size.y self.center_of_screen_x = self.size_of_screen_x / 2 self.center_of_screen_y = self.size_of_screen_y / 2 self.scale_size = 0.4 # This allows sound effects to play or not play # depending on whether sound effects is on or off (controlled in settings scene) if config.sound_effects_on == True: sound.set_volume(50) elif config.sound_effects_on == False: sound.set_volume(0) # This allows music to play or not play # depending on whether music is on or off (controlled in settings scene) if config.music_on == True: config.main_menu_music.play() elif config.music_on == False: config.main_menu_music.pause() # add blue sky background self.background = SpriteNode( './assets/sprites/main_menu_background.PNG', position=self.size / 2, parent=self, size=self.size) # add bush in right (for background) bush_position = Vector2() bush_position.y = (self.size_of_screen_y - (2 * (self.center_of_screen_y))) + 100 bush_position.x = self.size_of_screen_x - 100 self.bush = SpriteNode('./assets/sprites/bush.PNG', parent=self, position=bush_position, scale=0.45) # add bush in left (for background) bush_2_position = Vector2() bush_2_position.y = (self.size_of_screen_y - (2 * (self.center_of_screen_y))) + 100 bush_2_position.x = (self.size_of_screen_x - (2 * (self.center_of_screen_x))) + 100 self.bush_2 = SpriteNode('./assets/sprites/bush.PNG', parent=self, position=bush_2_position, scale=0.45) # This shows credits label credits_title_position = Vector2() credits_title_position.y = self.center_of_screen_y + 270 credits_title_position.x = self.center_of_screen_x self.credits_title = SpriteNode('./assets/sprites/credits_title.PNG', parent=self, position=credits_title_position, scale=0.45) # This shows home button home_button_position = Vector2() home_button_position.y = self.size_of_screen_y - 70 home_button_position.x = (self.size_of_screen_x - (2 * (self.center_of_screen_x))) + 100 self.home_button = SpriteNode('./assets/sprites/home_button.PNG', parent=self, position=home_button_position, scale=0.25) # This shows 'Made by: ' label made_by_label_position = Vector2() made_by_label_position.y = self.center_of_screen_y - -120 made_by_label_position.x = self.center_of_screen_x - 0 self.made_by_label = LabelNode(text='Made by:', font=('Copperplate', 45), color='black', parent=self, position=made_by_label_position) # This shows names names_label_position = Vector2() names_label_position.y = self.center_of_screen_y - -60 names_label_position.x = self.center_of_screen_x - 0 self.names_label = LabelNode(text='Sidney and Shuvaethy', font=('Copperplate', 45), color='black', parent=self, position=names_label_position)
def setup(self): # this method is called, when user moves to this scene self.score_position = Vector2() self.size_of_screen_x = self.size.x self.size_of_screen_y = self.size.y self.center_of_screen_x = self.size_of_screen_x/2 self.center_of_screen_y = self.size_of_screen_y/2 self.down_button_down = False self.left_button_down = False self.up_button_down = False self.right_button_down = False self.distance_between_hearts = 0 self.table_view_button_down = True self.robber_move_speed = 20.0 self.police_attack_speed = 15.0 self.police_attack_rate = 2 self.number_coins_collected = 0 self.stop_missiles = False self.heart_removed = False self.missiles = [] self.bushes = [] self.coins = [] self.hearts = [] self.character_gender = config.gender_type # This allows sound effects to play or to not play # based on whether the play sound effects or no sound effects was pressed (in settings scene) if config.sound_effects_on == True: sound.set_volume(50) elif config.sound_effects_on == False: sound.set_volume(0) # This plays or does not play music # based on whether the music or no music button was pressed (in settings scene) if config.music_on == True: config.main_game_music.number_of_loops = -1 config.main_game_music.play() elif config.music_on == False: config.main_game_music.pause() # add grassy background self.background = SpriteNode('./assets/sprites/main_game_background.PNG', position = self.size / 2, parent = self, size = self.size) # This show table view button table_view_button_position = Vector2() table_view_button_position.y = self.size_of_screen_y - 90 table_view_button_position.x = (self.size_of_screen_x - (2 * (self.center_of_screen_x))) + 80 self.table_view_button = SpriteNode('./assets/sprites/table_view_button.PNG', parent = self, position = table_view_button_position, scale = 0.25) # This shows the bushes and coins self.create_bush_and_coins() # Creates robber sprite self.robber_position = Vector2() self.robber_position.y = self.center_of_screen_y - 250 self.robber_position.x = self.size_of_screen_x - 170 self.robber = SpriteNode(self.character_gender, parent = self, position = self.robber_position, scale = 0.11) # Creates down button down_button_position = Vector2() down_button_position.y = (self.size_of_screen_y - (2 * (self.center_of_screen_y))) + 65 down_button_position.x = (self.size_of_screen_x - (2 * (self.center_of_screen_x))) + 135 self.down_button = SpriteNode('./assets/sprites/down_button.PNG', parent = self, position = down_button_position, alpha = 0.7, scale = 0.15) # Creates left button left_button_position = Vector2() left_button_position.y = (self.size_of_screen_y - (2 * (self.center_of_screen_y))) + 150 left_button_position.x = (self.size_of_screen_x - (2 * (self.center_of_screen_x))) + 70 self.left_button = SpriteNode('./assets/sprites/left_button.PNG', parent = self, position = left_button_position, alpha = 0.7, scale = 0.15) # Creates up button up_button_position = Vector2() up_button_position.y = (self.size_of_screen_y - (2 * (self.center_of_screen_y))) + 233 up_button_position.x = (self.size_of_screen_x - (2 * (self.center_of_screen_x))) + 135 self.up_button = SpriteNode('./assets/sprites/up_button.PNG', parent = self, position = up_button_position, alpha = 0.7, scale = 0.15) # Creates right button right_button_position = Vector2() right_button_position.y = (self.size_of_screen_y - (2 * (self.center_of_screen_y))) + 150 right_button_position.x = (self.size_of_screen_x - (2 * (self.center_of_screen_x))) + 200 self.right_button = SpriteNode('./assets/sprites/right_button.PNG', parent = self, position = right_button_position, alpha = 0.7, scale = 0.15) # This creates the coin counter coin_count_position = Vector2() coin_count_position.y = self.size_of_screen_y - 55 coin_count_position.x = self.center_of_screen_x + 350 self.coin_count = LabelNode(text = 'Coins:' + ' ' + str(self.number_coins_collected) + '/' + str(config.level_difficulty), font = ('Marker Felt', 45), color = 'black', parent = self, position = coin_count_position) # This creates a small coin sprite beside coin counter (for aesthetic) coin_count_sprite_position = Vector2() coin_count_sprite_position.y = self.size_of_screen_y - 55 coin_count_sprite_position.x = self.center_of_screen_x + 370 self.coin_count_sprite = SpriteNode('plf:HudCoin', parent = self, position = coin_count_sprite_position, scale = 1.3) # This shows 'Life: ' label life_span_position = Vector2() life_span_position.y = self.size_of_screen_y - 55 life_span_position.x = self.center_of_screen_x - 270 self.life_span = LabelNode(text = 'Life: ', font = ('Marker Felt', 45), color = 'black', parent = self, position = life_span_position)
def playSound(name,volume): sound.set_volume(volume) sound.play_effect(name)
from sound import set_volume, play import datetime import os x = input("What time do you want to get up") stop = False while stop == False: rn = str(datetime.datetime.now().time()) #print(rn) if rn > x: snz= input("Snooze?") set_volume(-30) play() i = False while i == False: snz= input("Snooze for real?") if snz == "no": print("ok") set_volume(-5) play() break else: snz == "yes" i = True stop = True break
def draw(self): w = self.size.w h = self.size.h if not self.loaded: return if self.state == 'Menu': bc = self.getBackgroundColour(time.time() - self.animationStart) background(*bc) tint(bc[1], bc[1], bc[1]) if time.time() - self.lastSoundTime >= self.animationLength / 2: play_effect(self.sound) self.lastSoundTime += self.animationLength / 2 text('Sonar', self.titleF, self.titleS, w * 0.5, h * 0.8) text('Explore', self.f, self.s, w * 0.5, h * 0.56) text('Broken Sonar', self.f, self.s, w * 0.5, h * 0.44) text('Highscores', self.f, self.s, w * 0.5, h * 0.32) text('Items', self.f, self.s, w * 0.5, h * 0.2) elif self.state.startswith('Starting'): background(0, 0, 0) tint(1, 1, 1) title = 'Explore' if self.state == 'Starting Exploration' else 'Broken Sonar' text(title, self.titleF, self.titleS * 0.75, w * 0.5, h - 5, alignment=2) text('How to play:', self.f, self.s * 0.8, w * 0.5, h * 0.83) text('Move your finger around the screen', self.instrF, self.instrS, w * 0.5, h * 0.77) text('to try to find the hidden item. The', self.instrF, self.instrS, w * 0.5, h * 0.73) text('background, sound and distance', self.instrF, self.instrS, w * 0.5, h * 0.69) text('sensor will tell you how close you', self.instrF, self.instrS, w * 0.5, h * 0.65) text('are to finding it. Good luck!', self.instrF, self.instrS, w * 0.5, h * 0.61) text('Tap a difficulty to start!', self.f, self.s * 0.75, w * 0.5, h * 0.5) for i, mode in enumerate(['Easy', 'Medium', 'Hard', 'Expert']): if self.hasUnlocked(mode): text(mode, self.gameModeF, self.s, w * 0.5, h * 0.4 - (h * 0.1 * i)) else: req = self.requirements[mode] needed = req[1] - self.items[req[0]] message = 'You need %d more %s to unlock %s.' % ( needed, self.plural(req[0], needed), mode) text(message, self.f, self.instrS * 0.8, w * 0.5, h * 0.4 - (h * 0.1 * i)) text('Menu', self.f, self.instrS, w - 5, 5, alignment=7) elif self.state == 'Playing': # Change background colour if not self.isBackgroundBroken and self.distance is not None: c = self.distance / self.diagonal background(1 - c, c, c) else: background(0, 0, 0) # Display distance if not self.isDistanceBroken and self.distance is not None: if self.difficulty == EXPERT: text(str(int(round(self.distance * 0.1) * 10)), self.f, self.s, w * 0.5, 5, alignment=8) else: text(str(int(round(self.distance))), self.f, self.s, w * 0.5, 5, alignment=8) # Make sound if not self.isSoundBroken and self.distance is not None: volume = 1 - (self.distance / self.diagonal) set_volume(volume) if time.time() - self.lastSoundTime >= self.soundInterval: play_effect(self.sound) self.lastSoundTime += self.soundInterval # Display time e = time.time() - self.gameStartTime text(self.formatTime(e), self.f, self.instrS, 5, h - 5, alignment=3) elif self.state == 'Item Give': background(0, 0, 0) text('You got...', self.f, self.s, w * 0.5, h * 0.9) items = self.itemsToGive i1, i2 = items[0], (items[1] if len(items) == 2 else None) if len(items) == 1: a = 'A ' if i1 != 'octopus' else 'An ' text(a + i1 + '!', self.f, self.s, w * 0.5, h * 0.27) image(self.imageName(self.itemsToGive[0]), w * 0.15, h * 0.3, w * 0.7, w * 0.7) elif len(items) == 2 and i1 == i2: text('Two' + self.plural(i1) + '!', self.f, self.s, w * 0.5, h * 0.27) image(self.imageName(i1), w * 0.15, h * 0.3, w * 0.7, w * 0.7) else: a1 = 'A ' if self.itemsToGive[0] != 'octopus' else 'An ' a2 = 'a ' if self.itemsToGive[1] != 'octopus' else 'an ' text(a1 + i1 + ' and ' + a2 + i2 + '!', self.f, self.s * 0.65, w * 0.5, h * 0.37) image(self.imageName(i1), w * 0.05, h * 0.4, w * 0.4, w * 0.4) image(self.imageName(i2), w * 0.55, h * 0.4, w * 0.4, w * 0.4) text('Tap to continue.', 'Futura', self.instrS, w, 0, alignment=7) elif self.state == 'Broken Select': background(0, 0, 0) tint(1, 1, 1) if not self.hasUnlocked('Sound'): text('Sorry, you need a key to unlock', self.instrF, self.instrS, w * 0.5, h * 0.5) text('this mode. Tap to return to the menu.', self.instrF, self.instrS, w * 0.5, h * 0.46) else: text('Broken Sonar', self.titleF, self.titleS * 0.75, w * 0.5, h - 5, alignment=2) text('You get 2 items for winning Broken Sonar.', self.f, self.instrS * 0.8, w * 0.5, h * 0.8) if self.isSoundBroken: tint(1, 0, 0) text('Sound', self.gameModeF, self.s, w * 0.5, h * 0.6) tint(1, 1, 1) if self.isBackgroundBroken: tint(1, 0, 0) text('Colour', self.gameModeF, self.s, w * 0.5, h * 0.5) tint(1, 1, 1) if self.isDistanceBroken: tint(1, 0, 0) text('Distance', self.gameModeF, self.s, w * 0.5, h * 0.4) tint(1, 1, 1) text('Menu', self.f, self.instrS, w - 5, 5, alignment=7) s = self.getBroken() if s and self.hasUnlocked(s): text('Continue', self.f, self.s, w * 0.5, h * 0.25) elif s == '': text('Select the broken sensors!', self.f, self.instrS, w * 0.5, h * 0.25) elif s == 'SoundColourDistance': text("You can't break all the sensors!", self.f, self.instrS, w * 0.5, h * 0.25) else: req = self.requirements[s] needed = req[1] - self.items[req[0]] message = 'You need %d more %s to unlock this mode.' % ( needed, self.plural(req[0], needed)) text(message, self.f, self.instrS * 0.75, w * 0.5, h * 0.25) text('Menu', self.f, self.instrS, w - 5, 5, alignment=7) elif self.state == 'Highscores': background(0, 0, 0) tint(1, 1, 1) text('Highscores', self.titleF, self.titleS * 0.9, w * 0.5, h, alignment=2) text('Easy: ' + self.formatTime(self.highscores[EASY]), self.f, self.s, w * 0.5, h * 0.7) text('Medium: ' + self.formatTime(self.highscores[MEDIUM]), self.f, self.s, w * 0.5, h * 0.6) text('Hard: ' + self.formatTime(self.highscores[HARD]), self.f, self.s, w * 0.5, h * 0.5) text('Expert: ' + self.formatTime(self.highscores[EXPERT]), self.f, self.s, w * 0.5, h * 0.4) text('Menu', self.f, self.instrS, w - 5, 5, alignment=7) elif self.state == 'Items': background(0, 0, 0) tint(1, 1, 1) text('Items', self.titleF, self.s, w * 0.5, h, alignment=2) border = 15 iw = (w - border * 4) / 3 yStart = h * 0.78 for x in range(3): for y in range(5): item = self.itemsList[y * 3 + x] imageX = border * (x + 1) + (iw * x) imageY = yStart - (border * y) - (iw * y) image(self.imageName(item), imageX, imageY, iw * 0.85, iw * 0.85) text(str(self.items[item]), self.f, self.instrS, imageX + iw * 0.85, imageY, alignment=6) text('Menu', self.f, self.instrS, w, 0, alignment=7)