コード例 #1
0
    def reset_round_timer(self):
        self.revive_time = time.time() + 4
        self.revive_noise = True

        self.round_counter += 1
        self.round_time = time.time() + self.round_limit
        self.timer_beep = 4
        self.colors[self.chosen_defender].value = 1
        self.colors[self.chosen_fighter].value = 2
        print(self.score.items())
        self.set_highest_score_color()
        print(self.get_highest_score())
        print(self.high_score)
        if self.get_highest_score() > self.high_score:
            self.high_score = self.get_highest_score()
            if self.current_winner != self.chosen_defender:
                self.current_winner = self.chosen_defender
                saying = random.randint(0, 2)
                if saying == 0:
                    Audio('audio/Fight_Club/vox/' + self.voice +
                          '/defender_lead.wav').start_effect()
                elif saying == 1:
                    Audio('audio/Fight_Club/vox/' + self.voice +
                          '/defender_winning.wav').start_effect()
                elif saying == 2:
                    Audio('audio/Fight_Club/vox/' + self.voice +
                          '/Defender_high_score.wav').start_effect()
        self.check_end_game()
コード例 #2
0
ファイル: commander.py プロジェクト: aangert/PiParty
 def end_game_sound(self, winning_team):
     # if self.game_mode == common.Games.JoustTeams:
     if winning_team == Team.red.value:
         team_win = Audio("audio/Commander/sounds/red winner.wav")
     if winning_team == Team.blue.value:
         team_win = Audio("audio/Commander/sounds/blue winner.wav")
     team_win.start_effect()
コード例 #3
0
ファイル: bubble.py プロジェクト: aangert/PiParty
    def __init__(self, moves):

        self.move_serials = moves
        self.tracked_moves = {}
        self.dead_moves = {}
        self.scores = {}
        self.music_speed = Value('d', 1.5)
        self.running = True
        self.force_move_colors = {}
        self.teams = {}
        self.win_amount = int(math.ceil((len(moves)/2.0)+2))
        self.team_num = 2

        self.generate_random_teams(self.team_num)

        music = 'audio/Joust/music/' + random.choice(os.listdir('audio/Joust/music'))
        self.start_beep = Audio('audio/Joust/sounds/start.wav')
        self.start_game = Audio('audio/Joust/sounds/start3.wav')
        self.explosion = Audio('audio/Joust/sounds/Explosion34.wav')
        fast_resample = False
        if len(moves) >= 5:
            fast_resample = True
        self.audio = Audio(music, fast_resample)
        #self.change_time = self.get_change_time(speed_up = True)
        self.change_time = time.time() + 8
        self.speed_up = True
        self.currently_changing = False
        self.game_end = False
        self.winning_moves = []
        self.losing_moves = []
        
        
        self.game_loop()
コード例 #4
0
ファイル: commander.py プロジェクト: aangert/PiParty
    def commander_intro_audio(self):
        # print 'BOOOP'
        intro_sound = Audio("audio/Commander/sounds/commander intro.wav")
        intro_sound.start_effect()
        # need while loop here
        play_last_one = True
        commander_select_time = time.time() + 50
        battle_ready_time = time.time() + 40
        while time.time() < commander_select_time:
            self.check_commander_select()
            if self.check_everyone_in():
                break

            if time.time() > battle_ready_time and play_last_one:
                play_last_one = False
                Audio("audio/Commander/sounds/10 seconds begins.wav").start_effect()
        intro_sound.stop_effect()

        if self.current_commander[Team.red.value] == "":
            self.change_random_commander(Team.red.value)
        if self.current_commander[Team.blue.value] == "":
            self.change_random_commander(Team.blue.value)

        Audio("audio/Commander/sounds/commanders chosen.wav").start_effect()
        time.sleep(4)
        self.reset_power(Team.red.value)
        self.reset_power(Team.blue.value)
        self.commander_intro.value = 0
コード例 #5
0
ファイル: fight_club.py プロジェクト: etaiklein/JoustMania
 def check_end_game(self):
     if self.round_counter >= self.round_num:
         self.check_winner()
     if self.round_counter == self.round_num - 5:
         Audio('audio/Fight_Club/5_rounds.wav').start_effect()
     if self.round_counter == self.round_num - 1:
         Audio('audio/Fight_Club/last_round.wav').start_effect()
コード例 #6
0
ファイル: zombie.py プロジェクト: etaiklein/JoustMania
    def __init__(self, cont_alive, command_queue, ns, music, restart,
                 zombie_opts):

        self.command_queue = command_queue
        self.ns = ns

        self.sensitivity = self.ns.settings['sensitivity']
        self.play_audio = self.ns.settings['play_audio']

        self.music = music
        self.restart = restart

        self.update_time = 0
        self.humans = []
        self.alive_zombies = []
        self.dead_zombies = {}
        self.controller_opts = zombie_opts
        self.controllers_alive = cont_alive
        self.win_time = ((len(self.controllers_alive) * 3) / 16) * 60
        if self.win_time <= 0:
            self.win_time = 60
        self.start_time = time.time()
        if self.play_audio:
            self.pickup = Audio('audio/Zombie/sound_effects/pickup.wav')
        self.effect_cue = 0

        self.kill_game = False
        self.Start()
コード例 #7
0
 def check_commander_select(self):
     for move_serial in self.move_opts.keys():
         if self.move_opts[move_serial][Opts.selection.value] == Selections.triangle.value and self.move_opts[move_serial][Opts.holding.value] == Holding.holding.value:
             Audio('audio/Commander/sounds/commanderselect.wav').start_effect()
             self.change_commander(move_serial)
             self.move_opts[move_serial][Opts.selection.value] = Selections.nothing.value
         elif self.move_opts[move_serial][Opts.selection.value] == Selections.a_button.value and self.move_opts[move_serial][Opts.holding.value] == Holding.holding.value:
             Audio('audio/Commander/sounds/buttonselect.wav').start_effect()
             self.move_opts[move_serial][Opts.selection.value] = Selections.nothing.value
コード例 #8
0
ファイル: commander.py プロジェクト: shihyu/JoustMania
 def overdrive(self, team):
     Audio('audio/Commander/sounds/overdrive.wav').start_effect()
     if team == Team.red.value:
         self.red_overdrive.value = 1
         self.activated_overdrive[Team.red.value] = time.time() + 10
         Audio('audio/Commander/sounds/red overdrive.wav').start_effect()
     else:
         self.blue_overdrive.value = 1
         self.activated_overdrive[Team.blue.value] = time.time() + 10
         Audio('audio/Commander/sounds/blue overdrive.wav').start_effect()
コード例 #9
0
 def play_random_instructions(self):
     if self.game_mode == common.Games.JoustFFA:
         Audio('audio/Menu/FFA-instructions.wav').start_effect_and_wait()
     if self.game_mode == common.Games.JoustRandomTeams:
         Audio('audio/Menu/Teams-instructions.wav').start_effect_and_wait()
     if self.game_mode == common.Games.Traitor:
         Audio(
             'audio/Menu/Traitor-instructions.wav').start_effect_and_wait()
     if self.game_mode == common.Games.WereJoust:
         Audio('audio/Menu/werewolf-instructions.wav'
               ).start_effect_and_wait()
     if self.game_mode == common.Games.Zombies:
         Audio('audio/Menu/zombie-instructions.wav').start_effect_and_wait()
     if self.game_mode == common.Games.Commander:
         Audio('audio/Menu/commander-instructions.wav'
               ).start_effect_and_wait()
     if self.game_mode == common.Games.Ninja:
         Audio('audio/Menu/Ninjabomb-instructions.wav'
               ).start_effect_and_wait()
     if self.game_mode == common.Games.Swapper:
         Audio(
             'audio/Menu/Swapper-instructions.wav').start_effect_and_wait()
     if self.game_mode == common.Games.Tournament:
         Audio('audio/Menu/Tournament-instructions.wav'
               ).start_effect_and_wait()
コード例 #10
0
 def play_random_instructions(self):
     if self.game_mode == common.Games.JoustFFA:
         Audio('audio/Menu/FFA-instructions.wav').start_effect_and_wait()
     if self.game_mode == common.Games.JoustRandomTeams:
         Audio('audio/Menu/Teams-instructions.wav').start_effect_and_wait()
     if self.game_mode == common.Games.Traitor:
         Audio(
             'audio/Menu/Traitor-instructions.wav').start_effect_and_wait()
     if self.game_mode == common.Games.WereJoust:
         Audio('audio/Menu/werewolf-instructions.wav'
               ).start_effect_and_wait()
     if self.game_mode == common.Games.Zombies:
         Audio('audio/Menu/zombie-instructions.wav').start_effect_and_wait()
     if self.game_mode == common.Games.Commander:
         Audio('audio/Menu/commander-instructions.wav'
               ).start_effect_and_wait()
     if self.game_mode == common.Games.Ninja:
         Audio('audio/Menu/Ninjabomb-instructions.wav'
               ).start_effect_and_wait()
     if self.game_mode == common.Games.Swapper:
         Audio(
             'audio/Menu/Swapper-instructions.wav').start_effect_and_wait()
     if self.game_mode == common.Games.Tournament:
         Audio('audio/Menu/Tournament-instructions.wav'
               ).start_effect_and_wait()
     if self.game_mode == common.Games.FightClub:
         os.popen(
             'espeak -ven -p 70 -a 200 "Two players fight, the winner must defend thier title, the player with the highest score wins'
         )
         time.sleep(5)
コード例 #11
0
 def play_random_instructions(self):
     if self.game_mode == common.Games.JoustFFA.value:
         Audio('audio/Menu/FFA-instructions.wav').start_effect()
         time.sleep(15)
     if self.game_mode == common.Games.JoustRandomTeams.value:
         Audio('audio/Menu/Teams-instructions.wav').start_effect()
         time.sleep(20)
     if self.game_mode == common.Games.Traitor.value:
         Audio('audio/Menu/Traitor-instructions.wav').start_effect()
         time.sleep(18)
     if self.game_mode == common.Games.WereJoust.value:
         Audio('audio/Menu/werewolf-instructions.wav').start_effect()
         time.sleep(20)
     if self.game_mode == common.Games.Zombies.value:
         Audio('audio/Menu/zombie-instructions.wav').start_effect()
         time.sleep(48)
     if self.game_mode == common.Games.Commander.value:
         Audio('audio/Menu/commander-instructions.wav').start_effect()
         time.sleep(41)
     if self.game_mode == common.Games.Ninja.value:
         Audio('audio/Menu/Ninjabomb-instructions.wav').start_effect()
         time.sleep(32)
     if self.game_mode == common.Games.Swapper.value:
         Audio('audio/Menu/Swapper-instructions.wav').start_effect()
         time.sleep(14)
     if self.game_mode == common.Games.Tournament.value:
         Audio('audio/Menu/Tournament-instructions.wav').start_effect()
         time.sleep(21)
コード例 #12
0
ファイル: commander.py プロジェクト: aangert/PiParty
    def __init__(self, moves):

        self.move_serials = moves
        self.tracked_moves = {}
        self.dead_moves = {}
        self.teams = {}
        self.music_speed = Value("d", 1)
        self.running = True
        self.force_move_colors = {}
        self.team_num = 2
        self.werewolf_timer = 35
        self.start_timer = time.time()
        self.audio_cue = 0

        self.move_opts = {}
        self.current_commander = ["", ""]

        self.time_to_power = [20, 20]
        self.activated_time = [time.time(), time.time()]

        self.activated_overdrive = [time.time(), time.time()]

        self.powers = [Value("d", 0.0), Value("d", 0.0)]
        # self.red_power = Value('d', 0.0)
        # self.blue_power = Value('d', 0.0)

        self.red_overdrive = Value("i", 0)
        self.blue_overdrive = Value("i", 0)

        self.generate_random_teams(self.team_num)
        self.commander_intro = Value("i", 1)

        self.powers_active = [False, False]

        try:
            music = "audio/Commander/music/" + random.choice(os.listdir("audio/Commander/music"))
        except:
            print("no music in audio/Commander/music")
        self.start_beep = Audio("audio/Joust/sounds/start.wav")
        self.start_game = Audio("audio/Joust/sounds/start3.wav")
        self.explosion = Audio("audio/Joust/sounds/Explosion34.wav")
        fast_resample = False
        end = False
        try:
            self.audio = Audio(music, end)
        except:
            print("no audio loaded")
        # self.change_time = self.get_change_time(speed_up = True)
        self.change_time = time.time() + 8
        self.speed_up = True
        self.currently_changing = False
        self.game_end = False
        self.winning_moves = []

        self.game_loop()
コード例 #13
0
 def overdrive(self, team):
     Audio('audio/Commander/sounds/overdrive.wav').start_effect()
     if team == Team.alpha.value:
         self.alpha_overdrive.value = 1
         self.activated_overdrive[Team.alpha.value] = time.time() + 10
         Audio('audio/Commander/vox/' + self.voice +
               '/red overdrive.wav').start_effect()
     else:
         self.bravo_overdrive.value = 1
         self.activated_overdrive[Team.bravo.value] = time.time() + 10
         Audio('audio/Commander/vox/' + self.voice +
               '/blue overdrive.wav').start_effect()
コード例 #14
0
    def check_end_game(self):
        winning_team = -100
        team_win = True
        for move_serial, dead in self.dead_moves.items():
            #if we are alive
            if dead.value == 1:
                if winning_team == -100:
                    winning_team = self.get_real_team(self.teams[move_serial])
                elif self.get_real_team(
                        self.teams[move_serial]) != winning_team:
                    team_win = False
            if dead.value == 0:
                #This is to play the sound effect
                self.num_dead += 1
                dead.value = -1
                self.non_stop_deaths[move_serial] += 1
                if self.play_audio:
                    self.explosion.start_effect()
            if dead.value == 2:
                dead.value = 1
                if self.play_audio:
                    self.revive.start_effect()

        if self.game_mode == common.Games.NonStop:
            if self.audio_cue == 0 and time.time() > self.non_stop_time - 60:
                Audio('audio/Zombie/vox/' + self.voice +
                      '/1 minute.wav').start_effect()
                self.audio_cue += 1
            if self.audio_cue == 1 and time.time() > self.non_stop_time - 30:
                Audio('audio/Zombie/vox/' + self.voice +
                      '/30 seconds.wav').start_effect()
                self.audio_cue += 1
            if time.time() > self.non_stop_time:
                lowest_score = 100000
                for move, score in self.non_stop_deaths.items():
                    self.dead_moves[move].value = 0
                    if score == lowest_score:
                        self.winning_moves.append(move)
                    if score < lowest_score:
                        lowest_score = score
                        self.winning_moves = []
                        self.winning_moves.append(move)
                self.game_end = True

        elif team_win:
            self.update_status('ending', winning_team)
            if self.play_audio:
                self.end_game_sound(winning_team)
            for move_serial in self.teams.keys():
                if self.get_real_team(self.teams[move_serial]) == winning_team:
                    self.winning_moves.append(move_serial)
            self.game_end = True
コード例 #15
0
 def choose_new_music(self):
     self.joust_music = Audio(
         random.choice(glob.glob("audio/Joust/music/*")), False)
     try:
         self.zombie_music = Audio(
             random.choice(glob.glob("audio/Zombie/music/*")), False)
     except Exception:
         self.zombie_music = Audio("", False, False)
     try:
         self.commander_music = Audio(
             random.choice(glob.glob("audio/Commander/music/*")), False)
     except Exception:
         self.commander_music = Audio("", False, False)
コード例 #16
0
 def audio_cue(self):
     if self.win_time - (time.time() - self.start_time) <= 10 and self.effect_cue <= 4:
         Audio('audio/Zombie/sound_effects/10 seconds left.wav').start_effect()
         self.effect_cue = 5
     elif self.win_time - (time.time() - self.start_time) <= 30 and self.effect_cue <= 3:
         Audio('audio/Zombie/sound_effects/30 seconds.wav').start_effect()
         self.effect_cue = 4
     elif self.win_time - (time.time() - self.start_time) <= 1*60 and self.effect_cue <= 2:
         Audio('audio/Zombie/sound_effects/1 minute.wav').start_effect()
         self.effect_cue = 3
     elif self.win_time - (time.time() - self.start_time) <= 3*60 and self.effect_cue <= 1:
         Audio('audio/Zombie/sound_effects/3 minutes.wav').start_effect()
         self.effect_cue = 2
コード例 #17
0
ファイル: joust.py プロジェクト: shihyu/JoustMania
 def werewolf_audio_cue(self):
     if self.game_mode == common.Games.WereJoust.value:
         #print self.werewolf_timer - (time.time() - self.start_timer)
         if self.werewolf_timer - (time.time() - self.start_timer) <= 30 and self.audio_cue == 0:
             Audio('audio/Joust/sounds/30 werewolf.wav').start_effect()
             self.audio_cue = 1
         if self.werewolf_timer - (time.time() - self.start_timer) <= 10 and self.audio_cue == 1:
             Audio('audio/Joust/sounds/10 werewolf.wav').start_effect()
             self.audio_cue = 2
         if self.werewolf_timer - (time.time() - self.start_timer) <= 0 and self.audio_cue == 2:
             Audio('audio/Joust/sounds/werewolf reveal 2.wav').start_effect()
             self.reveal()
             self.audio_cue = 3
コード例 #18
0
 def __init__(self, cont_alive):
     self.humans = []
     self.alive_zombies = []
     self.dead_zombies = {}
     self.controller_opts = {}
     self.controllers_alive = cont_alive
     self.win_time =  ((len(self.controllers_alive) * 3)/16) * 60
     if self.win_time <= 0:
         self.win_time = 60
     self.start_time = time.time()
     self.pickup = Audio('audio/Zombie/sound_effects/pickup.wav')
     self.effect_cue = 0
     self.Start()
コード例 #19
0
ファイル: joust.py プロジェクト: aangert/PiParty
    def __init__(self, game_mode, moves, teams):

        self.move_serials = moves
        self.game_mode = game_mode
        self.tracked_moves = {}
        self.dead_moves = {}
        self.music_speed = Value("d", 1.5)
        self.running = True
        self.force_move_colors = {}
        self.teams = teams
        self.team_num = 6
        self.game_mode = game_mode
        self.werewolf_timer = 35
        self.start_timer = time.time()
        self.audio_cue = 0
        self.num_dead = 0
        self.werewolf_reveal = Value("i", 2)
        if game_mode == common.Games.JoustFFA.value:
            self.team_num = len(moves)
        if game_mode == common.Games.JoustRandomTeams.value:
            # this should be 3 for smaller number of controllers
            self.team_num = 4
        if game_mode == common.Games.WereJoust.value:
            self.werewolf_reveal.value = 0
            self.team_num = 1
        if game_mode != common.Games.JoustTeams.value:
            self.generate_random_teams(self.team_num)

        if game_mode == common.Games.WereJoust.value:
            # were_num = int((len(moves)+2)/4)
            were_num = int((len(moves) * 7) / 16)
            if were_num <= 0:
                were_num = 1
            self.choose_werewolf(were_num)

        music = "audio/Joust/music/" + random.choice(os.listdir("audio/Joust/music"))
        self.start_beep = Audio("audio/Joust/sounds/start.wav")
        self.start_game = Audio("audio/Joust/sounds/start3.wav")
        self.explosion = Audio("audio/Joust/sounds/Explosion34.wav")
        fast_resample = False
        end = False
        self.audio = Audio(music, end)
        # self.change_time = self.get_change_time(speed_up = True)
        self.change_time = time.time() + 8
        self.speed_up = True
        self.currently_changing = False
        self.game_end = False
        self.winning_moves = []

        self.game_loop()
コード例 #20
0
ファイル: piparty.py プロジェクト: MrAbodi/JoustMania
    def check_admin_controls(self):
        show_bat = False
        for move_opt in self.move_opts.values():
            if move_opt[Opts.selection.value] == Selections.show_battery.value and move_opt[Opts.holding.value] == Holding.holding.value:
                show_bat = True
        if show_bat:
            self.show_battery.value = 1
        else:
            self.show_battery.value = 0
        
        if self.admin_move:
            #you can't add custom teams mode to con mode, don't set colors
            admin_opt = self.move_opts[self.admin_move]

            #to play instructions or not
            if admin_opt[Opts.selection.value] == Selections.change_instructions.value:
                admin_opt[Opts.selection.value] = Selections.nothing.value
                self.instructions = not self.instructions
                if self.instructions:
                    Audio('audio/Menu/instructions_on.wav').start_effect()
                else:
                    Audio('audio/Menu/instructions_off.wav').start_effect()

            #change sensitivity
            if admin_opt[Opts.selection.value] == Selections.change_sensitivity.value:
                admin_opt[Opts.selection.value] = Selections.nothing.value
                self.sensitivity = (self.sensitivity + 1) %  SENSITIVITY_MODES
                if self.sensitivity == Sensitivity.slow.value:
                    Audio('audio/Menu/slow_sensitivity.wav').start_effect()
                elif self.sensitivity == Sensitivity.mid.value:
                    Audio('audio/Menu/mid_sensitivity.wav').start_effect()
                elif self.sensitivity == Sensitivity.fast.value:
                    Audio('audio/Menu/fast_sensitivity.wav').start_effect()
                
            #no admin colors in con custom teams mode
            if self.game_mode == common.Games.JoustTeams.value or self.game_mode == common.Games.Random.value:
                self.force_color[self.admin_move][0] = 0
                self.force_color[self.admin_move][1] = 0
                self.force_color[self.admin_move][2] = 0
            else:
                #if game is in con mode, admin is green, otherwise admin is red
                if self.game_mode in self.con_games:
                    self.force_color[self.admin_move][0] = 0
                    self.force_color[self.admin_move][1] = 200

                else:
                    self.force_color[self.admin_move][0] = 200
                    self.force_color[self.admin_move][1] = 0

                #add or remove game from con mode
                if admin_opt[Opts.selection.value] == Selections.add_game.value:
                    admin_opt[Opts.selection.value] = Selections.nothing.value
                    if self.game_mode not in self.con_games:
                        self.con_games.append(self.game_mode)
                        Audio('audio/Menu/game_on.wav').start_effect()
                    elif len(self.con_games) > 1:
                        self.con_games.remove(self.game_mode)
                        Audio('audio/Menu/game_off.wav').start_effect()
                    else:
                        Audio('audio/Menu/game_err.wav').start_effect()
コード例 #21
0
ファイル: bubble.py プロジェクト: shihyu/JoustMania
    def __init__(self, moves):

        self.move_serials = moves
        self.tracked_moves = {}
        self.dead_moves = {}
        self.scores = {}
        self.music_speed = Value('d', 1.5)
        self.running = True
        self.force_move_colors = {}
        self.teams = {}
        self.win_amount = int(math.ceil((len(moves) / 2.0) + 2))
        self.team_num = 2

        self.generate_random_teams(self.team_num)

        music = 'audio/Joust/music/' + random.choice(
            os.listdir('audio/Joust/music'))
        self.start_beep = Audio('audio/Joust/sounds/start.wav')
        self.start_game = Audio('audio/Joust/sounds/start3.wav')
        self.explosion = Audio('audio/Joust/sounds/Explosion34.wav')
        fast_resample = False
        if len(moves) >= 5:
            fast_resample = True
        self.audio = Audio(music, fast_resample)
        #self.change_time = self.get_change_time(speed_up = True)
        self.change_time = time.time() + 8
        self.speed_up = True
        self.currently_changing = False
        self.game_end = False
        self.winning_moves = []
        self.losing_moves = []

        self.game_loop()
コード例 #22
0
ファイル: commander.py プロジェクト: shihyu/JoustMania
    def commander_intro_audio(self):
        #print 'BOOOP'
        intro_sound = Audio('audio/Commander/sounds/commander intro.wav')
        intro_sound.start_effect()
        #need while loop here
        play_last_one = True
        commander_select_time = time.time() + 50
        battle_ready_time = time.time() + 40
        while time.time() < commander_select_time:
            self.check_commander_select()
            if self.check_everyone_in():
                break

            if time.time() > battle_ready_time and play_last_one:
                play_last_one = False
                Audio('audio/Commander/sounds/10 seconds begins.wav'
                      ).start_effect()
        intro_sound.stop_effect()

        if self.current_commander[Team.red.value] == '':
            self.change_random_commander(Team.red.value)
        if self.current_commander[Team.blue.value] == '':
            self.change_random_commander(Team.blue.value)

        Audio('audio/Commander/sounds/commanders chosen.wav').start_effect()
        time.sleep(4)
        self.reset_power(Team.red.value)
        self.reset_power(Team.blue.value)
        self.commander_intro.value = 0
コード例 #23
0
    def commander_intro_audio(self):
        intro_sound = Audio('audio/Commander/vox/' + self.voice +
                            '/commander intro.wav')
        intro_sound.start_effect()
        #need while loop here
        play_last_one = True
        commander_select_time = time.time() + 50
        battle_ready_time = time.time() + 40
        while time.time() < commander_select_time:
            self.check_commander_select()
            if self.check_everyone_in():
                break

            if time.time() > battle_ready_time and play_last_one:
                play_last_one = False
                Audio('audio/Commander/vox/' + self.voice +
                      '/10 seconds begins.wav').start_effect()
        intro_sound.stop_effect()

        if self.current_commander[Team.alpha.value] == '':
            self.change_random_commander(Team.alpha.value)
        if self.current_commander[Team.bravo.value] == '':
            self.change_random_commander(Team.bravo.value)

        Audio('audio/Commander/vox/' + self.voice +
              '/commanders chosen.wav').start_effect_and_wait()
        self.reset_power(Team.alpha.value)
        self.reset_power(Team.bravo.value)
        self.commander_intro.value = 0
コード例 #24
0
def big_update():
    Audio('audio/Menu/update_started.wav').start_effect_and_wait()
    current_hash = run_command(
        "sudo runuser -l pi -c 'cd /home/pi/JoustMania/;git rev-parse HEAD'"
    ).strip()
    run_command(
        "sudo runuser -l pi -c 'cd /home/pi/JoustMania/;git checkout master'")
    run_command("sudo runuser -l pi -c 'cd /home/pi/JoustMania/;git pull'")
    run_command("sudo /home/pi/JoustMania/setup.sh")
    #it failed if it got this far
    time.sleep(3)
    run_command(
        "sudo runuser -l pi -c 'cd /home/pi/JoustMania/;git checkout {}'".
        format(current_hash))
    Audio('audio/Menu/joustmania_failed.wav').start_effect_and_wait()
コード例 #25
0
ファイル: joust.py プロジェクト: MrAbodi/JoustMania
    def game_loop(self):
        self.track_moves()
        if self.game_mode == common.Games.WereJoust.value:
            self.werewolf_intro()
        self.werewolf_reveal.value = 1
        if self.game_mode == common.Games.JoustRandomTeams.value:
            Audio('audio/Joust/sounds/teams_form.wav').start_effect()
            self.show_team_colors.value = 1
            time.sleep(6)
        self.show_team_colors.value = 0
        self.count_down()
        self.change_time = time.time() + 6
        time.sleep(0.02)
        self.audio.start_audio_loop()
        time.sleep(0.8)
        if self.game_mode == common.Games.WereJoust.value:
            self.music_speed.value = SLOW_MUSIC_SPEED
            self.audio.change_ratio(self.music_speed.value)
            self.speed_up = False

        while self.running:
            if self.game_mode != common.Games.WereJoust.value:
                self.check_music_speed()
            self.check_end_game()
            self.werewolf_audio_cue()
            if self.game_end:
                self.end_game()

        self.stop_tracking_moves()
コード例 #26
0
 def play_random_instructions(self):
     if self.game_mode == common.Games.JoustFFA.value:
         Audio('audio/Menu/FFA-instructions.wav').start_effect()
         time.sleep(15)
     if self.game_mode == common.Games.JoustRandomTeams.value:
         Audio('audio/Menu/Teams-instructions.wav').start_effect()
         time.sleep(20)
     if self.game_mode == common.Games.WereJoust.value:
         Audio('audio/Menu/werewolf-instructions.wav').start_effect()
         time.sleep(20)
     if self.game_mode == common.Games.Zombies.value:
         Audio('audio/Menu/zombie-instructions.wav').start_effect()
         time.sleep(48)
     if self.game_mode == common.Games.Commander.value:
         Audio('audio/Menu/commander-instructions.wav').start_effect()
         time.sleep(41)
コード例 #27
0
    def check_start_game(self):
        #if self.game_mode == common.Games.Random:
        self.exclude_out_moves()
        start_game = True
        for serial in self.move_opts.keys():
            #on means off here
            if self.out_moves[serial] == Alive.on.value and self.move_opts[
                    serial][Opts.random_start.value] == Alive.on.value:
                start_game = False
            if self.move_opts[serial][
                    Opts.random_start.
                    value] == Alive.off.value and serial not in self.random_added:
                self.random_added.append(serial)
                if self.ns.settings['play_audio']:
                    Audio('audio/Joust/sounds/start.wav').start_effect()

        if start_game:
            if self.game_mode == common.Games.Random:
                self.start_game(random_mode=True)
            else:
                self.start_game()

    #else:
    #    if self.ns.settings['move_can_be_admin']:
    #        for move_opt in self.move_opts.values():
    #            if move_opt[Opts.selection.value] == Selections.start_game.value:
    #                self.start_game()
        if self.command_from_web == 'startgame':
            self.command_from_web = ''
            self.start_game()
コード例 #28
0
ファイル: commander.py プロジェクト: shihyu/JoustMania
    def __init__(self, moves):

        self.move_serials = moves
        self.tracked_moves = {}
        self.dead_moves = {}
        self.teams = {}
        self.music_speed = Value('d', 1)
        self.running = True
        self.force_move_colors = {}
        self.team_num = 2
        self.werewolf_timer = 35
        self.start_timer = time.time()
        self.audio_cue = 0

        self.move_opts = {}
        self.current_commander = ["", ""]

        self.time_to_power = [20, 20]
        self.activated_time = [time.time(), time.time()]

        self.activated_overdrive = [time.time(), time.time()]

        self.powers = [Value('d', 0.0), Value('d', 0.0)]
        #self.red_power = Value('d', 0.0)
        #self.blue_power = Value('d', 0.0)

        self.red_overdrive = Value('i', 0)
        self.blue_overdrive = Value('i', 0)

        self.generate_random_teams(self.team_num)
        self.commander_intro = Value('i', 1)

        self.powers_active = [False, False]

        try:
            music = 'audio/Commander/music/' + random.choice(
                os.listdir('audio/Commander/music'))
        except:
            print('no music in audio/Commander/music')
        self.start_beep = Audio('audio/Joust/sounds/start.wav')
        self.start_game = Audio('audio/Joust/sounds/start3.wav')
        self.explosion = Audio('audio/Joust/sounds/Explosion34.wav')
        fast_resample = False
        end = False
        try:
            self.audio = Audio(music, end)
        except:
            print('no audio loaded')
        #self.change_time = self.get_change_time(speed_up = True)
        self.change_time = time.time() + 8
        self.speed_up = True
        self.currently_changing = False
        self.game_end = False
        self.winning_moves = []

        self.game_loop()
コード例 #29
0
    def update_team_powers(self):
        self.powers[Team.alpha.value].value = max(min((time.time() - self.activated_time[Team.alpha.value])/(self.time_to_power[Team.alpha.value] * 1.0),1.0), 0.0)
        self.powers[Team.bravo.value].value = max(min((time.time() - self.activated_time[Team.bravo.value])/(self.time_to_power[Team.bravo.value] * 1.0), 1.0), 0.0)

        
        if self.powers_active[Team.alpha.value] == False:
            if self.powers[Team.alpha.value].value >= 1.0:
                self.powers_active[Team.alpha.value] = True
                Audio('audio/Commander/sounds/power ready.wav').start_effect()
                Audio('audio/Commander/sounds/red power ready.wav').start_effect()
                
                
        if self.powers_active[Team.bravo.value] == False:
            if self.powers[Team.bravo.value].value >= 1.0:
                self.powers_active[Team.bravo.value] = True
                Audio('audio/Commander/sounds/power ready.wav').start_effect()
                Audio('audio/Commander/sounds/blue power ready.wav').start_effect()
コード例 #30
0
ファイル: piparty.py プロジェクト: MrAbodi/JoustMania
    def start_game(self, random_mode=False):
        self.enable_bt_scanning(False)
        self.exclude_out_moves()
        self.stop_tracking_moves()
        time.sleep(0.2)
        game_moves = [move.get_serial() for move in self.moves if self.out_moves[move.get_serial()] == Alive.on.value]
        self.teams = {serial: self.move_opts[serial][Opts.team.value] for serial in self.tracked_moves.keys() if self.out_moves[serial] == Alive.on.value}


        if random_mode:
            if len(self.con_games) <= 1:
                selected_game = self.con_games[0]
            else:
                if len(self.rand_game_list) >= len(self.con_games):
                    #empty rand game list, append old game, to not play it twice
                    self.rand_game_list = [self.old_game_mode]

                selected_game = random.choice(self.con_games)
                while selected_game in self.rand_game_list:
                    selected_game = random.choice(self.con_games)

                self.old_game_mode = selected_game
                self.rand_game_list.append(selected_game)

            self.game_mode = selected_game

        if self.instructions:
            self.play_random_instructions()
        
        if self.game_mode == common.Games.Zombies.value:
            zombie.Zombie(game_moves, self.sensitivity)
            self.tracked_moves = {}
        elif self.game_mode == common.Games.Commander.value:
            commander.Commander(game_moves, self.sensitivity)
            self.tracked_moves = {}
        elif self.game_mode == common.Games.Ninja.value:
            speed_bomb.Bomb(game_moves)
            self.tracked_moves = {}
        elif self.game_mode == common.Games.Swapper.value:
            swapper.Swapper(game_moves, self.sensitivity)
            self.tracked_moves = {}
        elif self.game_mode == common.Games.KingoftheHill.value:
            kingofthehill.KingoftheHill(game_moves, self.sensitivity)
            self.tracked_moves = {}
        else:
            #may need to put in moves that have selected to not be in the game
            joust.Joust(self.game_mode, game_moves, self.teams, self.sensitivity)
            self.tracked_moves = {}
        if random_mode:
            self.game_mode = common.Games.Random.value
            if self.instructions:
                Audio('audio/Menu/tradeoff2.wav').start_effect()
                time.sleep(8)
            
        #turn off admin mode so someone can't accidentally press a button    
        self.admin_move = None
        self.random_added = []
コード例 #31
0
ファイル: joust.py プロジェクト: shihyu/JoustMania
 def werewolf_intro(self):
     Audio('audio/Joust/sounds/werewolf intro.wav').start_effect()
     time.sleep(3)
     self.change_all_move_colors(80, 0, 0)
     time.sleep(2)
     self.change_all_move_colors(30, 0, 0)
     time.sleep(18)
     self.change_all_move_colors(20, 20, 20)
     time.sleep(2)
     self.start_timer = time.time()
コード例 #32
0
ファイル: joust.py プロジェクト: estevaofv/JoustMania
 def werewolf_audio_cue(self):
     if self.game_mode == common.Games.WereJoust:
         if self.werewolf_timer - (time.time() - self.start_timer
                                   ) <= 30 and self.audio_cue == 0:
             Audio('audio/Joust/sounds/30 werewolf.wav').start_effect()
             self.audio_cue = 1
         if self.werewolf_timer - (time.time() - self.start_timer
                                   ) <= 10 and self.audio_cue == 1:
             Audio('audio/Joust/sounds/10 werewolf.wav').start_effect()
             self.audio_cue = 2
         if self.werewolf_timer - (time.time() - self.start_timer
                                   ) <= 0 and self.audio_cue == 2:
             Audio(
                 'audio/Joust/sounds/werewolf reveal 2.wav').start_effect()
             self.reveal()
             self.audio_cue = 3
             self.change_time = time.time() - 0.001
         elif self.audio_cue == 3:
             self.check_music_speed()
コード例 #33
0
ファイル: joust.py プロジェクト: NigelThorne/JoustMania
 def werewolf_intro(self):
     #don't wait so colors change during prompts
     Audio('audio/Joust/sounds/werewolf intro.wav').start_effect()
     time.sleep(3)
     self.change_all_move_colors(0, 0, 80)
     time.sleep(2)
     self.change_all_move_colors(0, 0, 30)
     time.sleep(14)
     self.change_all_move_colors(20, 20, 20)
     time.sleep(6)
     self.start_timer = time.time()
コード例 #34
0
def check_for_update():
    process = run_command(
        "sudo runuser -l pi -c 'cd /home/pi/JoustMania/;pwd'")
    process = run_command(
        "sudo runuser -l pi -c 'cd /home/pi/JoustMania/;git fetch'")
    diff_files = run_command(
        "sudo runuser -l pi -c 'cd /home/pi/JoustMania/;git diff origin/master --name-only'"
    ).split()
    print(diff_files)

    if ('setup.sh' in diff_files):
        Audio('audio/Menu/large_update.wav').start_effect_and_wait()
        return True

    elif (len(diff_files) >= 1):
        print("doing small pull")
        pull = run_command(
            "sudo runuser -l pi -c 'cd /home/pi/JoustMania/;git pull'")
        Audio('audio/Menu/joustmania_updated.wav').start_effect_and_wait()
        return False
コード例 #35
0
ファイル: joust.py プロジェクト: shihyu/JoustMania
    def __init__(self, game_mode, moves, teams):

        self.move_serials = moves
        self.game_mode = game_mode
        self.tracked_moves = {}
        self.dead_moves = {}
        self.music_speed = Value('d', 1.5)
        self.running = True
        self.force_move_colors = {}
        self.teams = teams
        self.team_num = 6
        self.game_mode = game_mode
        self.werewolf_timer = 35
        self.start_timer = time.time()
        self.audio_cue = 0
        self.num_dead = 0
        self.werewolf_reveal = Value('i', 2)
        if game_mode == common.Games.JoustFFA.value:
            self.team_num = len(moves)
        if game_mode == common.Games.JoustRandomTeams.value:
            #this should be 3 for smaller number of controllers
            self.team_num = 4
        if game_mode == common.Games.WereJoust.value:
            self.werewolf_reveal.value = 0
            self.team_num = 1
        if game_mode != common.Games.JoustTeams.value:
            self.generate_random_teams(self.team_num)

        if game_mode == common.Games.WereJoust.value:
            #were_num = int((len(moves)+2)/4)
            were_num = int((len(moves)*7)/16)
            if were_num <= 0:
                were_num = 1
            self.choose_werewolf(were_num)

        music = 'audio/Joust/music/' + random.choice(os.listdir('audio/Joust/music'))
        self.start_beep = Audio('audio/Joust/sounds/start.wav')
        self.start_game = Audio('audio/Joust/sounds/start3.wav')
        self.explosion = Audio('audio/Joust/sounds/Explosion34.wav')
        fast_resample = False
        end = False
        self.audio = Audio(music, end)
        #self.change_time = self.get_change_time(speed_up = True)
        self.change_time = time.time() + 8
        self.speed_up = True
        self.currently_changing = False
        self.game_end = False
        self.winning_moves = []
        
        
        self.game_loop()
コード例 #36
0
ファイル: commander.py プロジェクト: aangert/PiParty
class Commander:
    def __init__(self, moves):

        self.move_serials = moves
        self.tracked_moves = {}
        self.dead_moves = {}
        self.teams = {}
        self.music_speed = Value("d", 1)
        self.running = True
        self.force_move_colors = {}
        self.team_num = 2
        self.werewolf_timer = 35
        self.start_timer = time.time()
        self.audio_cue = 0

        self.move_opts = {}
        self.current_commander = ["", ""]

        self.time_to_power = [20, 20]
        self.activated_time = [time.time(), time.time()]

        self.activated_overdrive = [time.time(), time.time()]

        self.powers = [Value("d", 0.0), Value("d", 0.0)]
        # self.red_power = Value('d', 0.0)
        # self.blue_power = Value('d', 0.0)

        self.red_overdrive = Value("i", 0)
        self.blue_overdrive = Value("i", 0)

        self.generate_random_teams(self.team_num)
        self.commander_intro = Value("i", 1)

        self.powers_active = [False, False]

        try:
            music = "audio/Commander/music/" + random.choice(os.listdir("audio/Commander/music"))
        except:
            print("no music in audio/Commander/music")
        self.start_beep = Audio("audio/Joust/sounds/start.wav")
        self.start_game = Audio("audio/Joust/sounds/start3.wav")
        self.explosion = Audio("audio/Joust/sounds/Explosion34.wav")
        fast_resample = False
        end = False
        try:
            self.audio = Audio(music, end)
        except:
            print("no audio loaded")
        # self.change_time = self.get_change_time(speed_up = True)
        self.change_time = time.time() + 8
        self.speed_up = True
        self.currently_changing = False
        self.game_end = False
        self.winning_moves = []

        self.game_loop()

    def generate_random_teams(self, team_num):
        team_pick = list(range(team_num))
        for serial in self.move_serials:
            random_choice = random.choice(team_pick)
            self.teams[serial] = random_choice
            team_pick.remove(random_choice)
            if not team_pick:
                team_pick = list(range(team_num))

    def track_moves(self):
        for move_num, move_serial in enumerate(self.move_serials):
            time.sleep(0.02)
            dead_move = Value("i", 1)
            force_color = Array("i", [1] * 3)
            opts = Array("i", [0] * 5)
            power = self.powers[self.teams[move_serial]]
            # if self.teams[move_serial] == Team.red:
            #    power = self.red_power
            # else:
            #    power = self.blue_power

            if self.teams[move_serial] == Team.red.value:
                overdrive = self.red_overdrive
            else:
                overdrive = self.blue_overdrive
            proc = Process(
                target=track_move,
                args=(
                    move_serial,
                    move_num,
                    self.teams[move_serial],
                    self.team_num,
                    dead_move,
                    force_color,
                    self.music_speed,
                    self.commander_intro,
                    opts,
                    power,
                    overdrive,
                ),
            )
            proc.start()
            self.tracked_moves[move_serial] = proc
            self.dead_moves[move_serial] = dead_move
            self.force_move_colors[move_serial] = force_color
            self.move_opts[move_serial] = opts

    def change_all_move_colors(self, r, g, b):
        for color in self.force_move_colors.values():
            common.change_color(color, r, g, b)

    # need to do the count_down here
    def count_down(self):
        self.change_all_move_colors(80, 0, 0)
        self.start_beep.start_effect()
        time.sleep(0.75)
        self.change_all_move_colors(70, 100, 0)
        self.start_beep.start_effect()
        time.sleep(0.75)
        self.change_all_move_colors(0, 70, 0)
        self.start_beep.start_effect()
        time.sleep(0.75)
        self.change_all_move_colors(0, 0, 0)
        self.start_game.start_effect()

    def get_change_time(self, speed_up):
        if speed_up:
            added_time = random.uniform(MIN_MUSIC_FAST_TIME, MAX_MUSIC_FAST_TIME)
        else:
            added_time = random.uniform(MIN_MUSIC_SLOW_TIME, MAX_MUSIC_SLOW_TIME)
        return time.time() + added_time

    # def change_music_speed(self, fast):
    #    change_percent = numpy.clip((time.time() - self.change_time)/INTERVAL_CHANGE, 0, 1)
    #    if fast:
    #        self.music_speed.value = common.lerp(FAST_MUSIC_SPEED, SLOW_MUSIC_SPEED, change_percent)
    #    elif not fast:
    #        self.music_speed.value = common.lerp(SLOW_MUSIC_SPEED, FAST_MUSIC_SPEED, change_percent)
    #    self.audio.change_ratio(self.music_speed.value)

    # def check_music_speed(self):
    #    if time.time() > self.change_time and time.time() < self.change_time + INTERVAL_CHANGE:
    #        self.change_music_speed(self.speed_up)
    #        self.currently_changing = True
    #        self.audio.change_chunk_size(True)
    #    elif time.time() >= self.change_time + INTERVAL_CHANGE and self.currently_changing:
    #        self.music_speed.value = SLOW_MUSIC_SPEED if self.speed_up else FAST_MUSIC_SPEED
    #        self.speed_up =  not self.speed_up
    #        self.change_time = self.get_change_time(speed_up = self.speed_up)
    #        self.audio.change_ratio(self.music_speed.value)
    #       self.currently_changing = False
    #       self.audio.change_chunk_size(False)

    def get_winning_team_members(self, winning_team):
        self.end_game_sound(winning_team)
        for move_serial in self.teams.keys():
            if self.teams[move_serial] == winning_team:
                self.winning_moves.append(move_serial)

    def check_end_game(self):
        winning_team = -100
        team_win = False
        for commander in self.current_commander:
            if self.dead_moves[commander].value <= 0:
                winning_team = (self.teams[commander] + 1) % 2
                self.get_winning_team_members(winning_team)
                self.game_end = True

        for move_serial, dead in self.dead_moves.items():
            if dead.value == 0:
                dead_team = self.teams[move_serial]
                winning_team = (self.teams[move_serial] + 1) % 2
                if self.time_to_power[winning_team] > 15:
                    self.time_to_power[winning_team] -= 1
                if self.time_to_power[dead_team] < 25:
                    self.time_to_power[dead_team] += 1

                # This is to play the sound effect
                dead.value = -1
                self.explosion.start_effect()

    def stop_tracking_moves(self):
        for proc in self.tracked_moves.values():
            proc.terminate()
            proc.join()
            time.sleep(0.02)

    def end_game(self):
        try:
            self.audio.stop_audio()
        except:
            print("no audio loaded to stop")
        end_time = time.time() + END_GAME_PAUSE
        h_value = 0

        while time.time() < end_time:
            time.sleep(0.01)
            win_color = common.hsv2rgb(h_value, 1, 1)
            for win_move in self.winning_moves:
                win_color_array = self.force_move_colors[win_move]
                common.change_color(win_color_array, *win_color)
            h_value = h_value + 0.01
            if h_value >= 1:
                h_value = 0
        self.running = False

    def end_game_sound(self, winning_team):
        # if self.game_mode == common.Games.JoustTeams:
        if winning_team == Team.red.value:
            team_win = Audio("audio/Commander/sounds/red winner.wav")
        if winning_team == Team.blue.value:
            team_win = Audio("audio/Commander/sounds/blue winner.wav")
        team_win.start_effect()

    def check_commander_select(self):
        for move_serial in self.move_opts.keys():
            if (
                self.move_opts[move_serial][Opts.selection.value] == Selections.triangle.value
                and self.move_opts[move_serial][Opts.holding.value] == Holding.holding.value
            ):
                Audio("audio/Commander/sounds/commanderselect.wav").start_effect()
                self.change_commander(move_serial)
                self.move_opts[move_serial][Opts.selection.value] = Selections.nothing.value
            elif (
                self.move_opts[move_serial][Opts.selection.value] == Selections.a_button.value
                and self.move_opts[move_serial][Opts.holding.value] == Holding.holding.value
            ):
                Audio("audio/Commander/sounds/buttonselect.wav").start_effect()
                self.move_opts[move_serial][Opts.selection.value] = Selections.nothing.value

    def change_commander(self, new_commander):
        # print 'changing commander to ' + str(new_commander)
        commander_team = self.teams[new_commander]
        if self.current_commander[commander_team] != "":
            self.move_opts[self.current_commander[commander_team]][Opts.is_commander.value] = Bool.no.value

        self.move_opts[new_commander][Opts.is_commander.value] = Bool.yes.value
        self.current_commander[commander_team] = new_commander

    def change_random_commander(self, team, exclude_commander=None):
        team_move_serials = [
            move_serial
            for move_serial in self.move_opts.keys()
            if (
                self.teams[move_serial] == team
                and move_serial != exclude_commander
                and self.dead_moves[move_serial].value >= 1
            )
        ]
        print("team move serials is " + str(team_move_serials))
        if len(team_move_serials) > 0:
            new_commander = random.choice(team_move_serials)
            self.change_commander(new_commander)
            return True
        return False

    def update_team_powers(self):
        self.powers[Team.red.value].value = max(
            min((time.time() - self.activated_time[Team.red.value]) / (self.time_to_power[Team.red.value] * 1.0), 1.0),
            0.0,
        )
        self.powers[Team.blue.value].value = max(
            min(
                (time.time() - self.activated_time[Team.blue.value]) / (self.time_to_power[Team.blue.value] * 1.0), 1.0
            ),
            0.0,
        )

        if self.powers_active[Team.red.value] == False:
            if self.powers[Team.red.value].value >= 1.0:
                self.powers_active[Team.red.value] = True
                Audio("audio/Commander/sounds/power ready.wav").start_effect()
                Audio("audio/Commander/sounds/red power ready.wav").start_effect()

        if self.powers_active[Team.blue.value] == False:
            if self.powers[Team.blue.value].value >= 1.0:
                self.powers_active[Team.blue.value] = True
                Audio("audio/Commander/sounds/power ready.wav").start_effect()
                Audio("audio/Commander/sounds/blue power ready.wav").start_effect()

    def overdrive(self, team):
        Audio("audio/Commander/sounds/overdrive.wav").start_effect()
        if team == Team.red.value:
            self.red_overdrive.value = 1
            self.activated_overdrive[Team.red.value] = time.time() + 10
            Audio("audio/Commander/sounds/red overdrive.wav").start_effect()
        else:
            self.blue_overdrive.value = 1
            self.activated_overdrive[Team.blue.value] = time.time() + 10
            Audio("audio/Commander/sounds/blue overdrive.wav").start_effect()

    # def revive(self, team):
    #    print ('dadooda')
    #    dead_team_moves = [ move_serial for move_serial in self.move_opts.keys() if (self.teams[move_serial] == team and self.dead_moves[move_serial].value <= 0) ]
    # print 'dead_team_moves is ' + str(dead_team_moves)
    #    for move in dead_team_moves:
    #        self.dead_moves[move].value = 3
    #    Audio('audio/Commander/sounds/revive.wav').start_effect()
    #    if team == Team.red.value:
    #        Audio('audio/Commander/sounds/red revive.wav').start_effect()
    #    if team == Team.blue.value:
    #       Audio('audio/Commander/sounds/blue revive.wav').start_effect()

    # def shift(self, team, commander):
    #   print ('shifty')
    #    did_shift = self.change_random_commander(team, exclude_commander = commander)
    #     if did_shift:
    #         Audio('audio/Commander/sounds/shift.wav').start_effect()
    #         if team == Team.red.value:
    #            Audio('audio/Commander/sounds/red shift.wav').start_effect()
    #        if team == Team.blue.value:
    #            Audio('audio/Commander/sounds/blue shift.wav').start_effect()
    #    return did_shift

    def check_end_of_overdrive(self):
        if self.red_overdrive.value == 1:

            if time.time() >= self.activated_overdrive[Team.red.value]:
                # print 'its over'
                self.red_overdrive.value = 0
        if self.blue_overdrive.value == 1:

            if time.time() >= self.activated_overdrive[Team.blue.value]:
                # print 'itsa over'
                self.blue_overdrive.value = 0

    def reset_power(self, team):
        self.powers[team].value == 0.0
        self.activated_time[team] = time.time()
        self.powers_active[team] = False

    def check_commander_power(self):
        # print str(self.powers[0].value)
        # print str(self.powers[1].value)
        for commander in self.current_commander:
            # print self.move_opts[commander][Opts.selection]
            if self.move_opts[commander][Opts.selection.value] == Selections.trigger.value:
                self.overdrive(self.teams[commander])
                self.reset_power(self.teams[commander])
                self.move_opts[commander][Opts.selection.value] = Selections.nothing.value

            # if self.move_opts[commander][Opts.selection.value] == Selections.a_button.value:
            #    self.revive(self.teams[commander])
            #    self.reset_power(self.teams[commander])
            #    self.move_opts[commander][Opts.selection.value] = Selections.nothing.value

            # if self.move_opts[commander][Opts.selection.value] == Selections.triangle.value:
            #    if self.shift(self.teams[commander], commander):
            #       self.reset_power(self.teams[commander])
            #    self.move_opts[commander][Opts.selection.value] = Selections.nothing.value

    def check_everyone_in(self):
        for move_serial in self.move_opts.keys():
            if self.move_opts[move_serial][Opts.holding.value] == Holding.not_holding.value:
                return False
        return True

    def commander_intro_audio(self):
        # print 'BOOOP'
        intro_sound = Audio("audio/Commander/sounds/commander intro.wav")
        intro_sound.start_effect()
        # need while loop here
        play_last_one = True
        commander_select_time = time.time() + 50
        battle_ready_time = time.time() + 40
        while time.time() < commander_select_time:
            self.check_commander_select()
            if self.check_everyone_in():
                break

            if time.time() > battle_ready_time and play_last_one:
                play_last_one = False
                Audio("audio/Commander/sounds/10 seconds begins.wav").start_effect()
        intro_sound.stop_effect()

        if self.current_commander[Team.red.value] == "":
            self.change_random_commander(Team.red.value)
        if self.current_commander[Team.blue.value] == "":
            self.change_random_commander(Team.blue.value)

        Audio("audio/Commander/sounds/commanders chosen.wav").start_effect()
        time.sleep(4)
        self.reset_power(Team.red.value)
        self.reset_power(Team.blue.value)
        self.commander_intro.value = 0

    def game_loop(self):
        self.track_moves()
        self.commander_intro_audio()

        self.count_down()
        time.sleep(0.02)
        try:
            self.audio.start_audio_loop()
        except:
            print("no audio loaded to start")
        time.sleep(0.8)

        while self.running:

            # self.check_music_speed()

            self.update_team_powers()
            self.check_commander_power()
            self.check_end_of_overdrive()
            self.check_end_game()
            if self.game_end:
                self.end_game()

        self.stop_tracking_moves()
コード例 #37
0
ファイル: joust.py プロジェクト: aangert/PiParty
class Joust:
    def __init__(self, game_mode, moves, teams):

        self.move_serials = moves
        self.game_mode = game_mode
        self.tracked_moves = {}
        self.dead_moves = {}
        self.music_speed = Value("d", 1.5)
        self.running = True
        self.force_move_colors = {}
        self.teams = teams
        self.team_num = 6
        self.game_mode = game_mode
        self.werewolf_timer = 35
        self.start_timer = time.time()
        self.audio_cue = 0
        self.num_dead = 0
        self.werewolf_reveal = Value("i", 2)
        if game_mode == common.Games.JoustFFA.value:
            self.team_num = len(moves)
        if game_mode == common.Games.JoustRandomTeams.value:
            # this should be 3 for smaller number of controllers
            self.team_num = 4
        if game_mode == common.Games.WereJoust.value:
            self.werewolf_reveal.value = 0
            self.team_num = 1
        if game_mode != common.Games.JoustTeams.value:
            self.generate_random_teams(self.team_num)

        if game_mode == common.Games.WereJoust.value:
            # were_num = int((len(moves)+2)/4)
            were_num = int((len(moves) * 7) / 16)
            if were_num <= 0:
                were_num = 1
            self.choose_werewolf(were_num)

        music = "audio/Joust/music/" + random.choice(os.listdir("audio/Joust/music"))
        self.start_beep = Audio("audio/Joust/sounds/start.wav")
        self.start_game = Audio("audio/Joust/sounds/start3.wav")
        self.explosion = Audio("audio/Joust/sounds/Explosion34.wav")
        fast_resample = False
        end = False
        self.audio = Audio(music, end)
        # self.change_time = self.get_change_time(speed_up = True)
        self.change_time = time.time() + 8
        self.speed_up = True
        self.currently_changing = False
        self.game_end = False
        self.winning_moves = []

        self.game_loop()

    def choose_werewolf(self, were_num):
        for were in range(were_num):
            werewolf = random.choice(self.move_serials)
            while self.teams[werewolf] < 0:
                werewolf = random.choice(self.move_serials)
            self.teams[werewolf] = (self.teams[werewolf] * -1) - 1

    def generate_random_teams(self, team_num):
        team_pick = list(range(team_num))
        print(str(team_pick))
        for serial in self.move_serials:
            random_choice = random.choice(team_pick)
            self.teams[serial] = random_choice
            team_pick.remove(random_choice)
            if not team_pick:
                team_pick = list(range(team_num))

    def track_moves(self):
        for move_num, move_serial in enumerate(self.move_serials):

            time.sleep(0.02)
            dead_move = Value("i", 1)
            force_color = Array("i", [1] * 3)
            proc = Process(
                target=track_move,
                args=(
                    move_serial,
                    move_num,
                    self.game_mode,
                    self.teams[move_serial],
                    self.team_num,
                    dead_move,
                    force_color,
                    self.music_speed,
                    self.werewolf_reveal,
                ),
            )
            proc.start()
            self.tracked_moves[move_serial] = proc
            self.dead_moves[move_serial] = dead_move
            self.force_move_colors[move_serial] = force_color

    def change_all_move_colors(self, r, g, b):
        for color in self.force_move_colors.values():
            common.change_color(color, r, g, b)

    # need to do the count_down here
    def count_down(self):
        self.change_all_move_colors(80, 0, 0)
        self.start_beep.start_effect()
        time.sleep(0.75)
        self.change_all_move_colors(70, 100, 0)
        self.start_beep.start_effect()
        time.sleep(0.75)
        self.change_all_move_colors(0, 70, 0)
        self.start_beep.start_effect()
        time.sleep(0.75)
        self.change_all_move_colors(0, 0, 0)
        self.start_game.start_effect()

    def get_change_time(self, speed_up):
        min_moves = len(self.move_serials) - 2
        if min_moves <= 0:
            min_moves = 1

        game_percent = self.num_dead / min_moves
        if game_percent > 1.0:
            game_percent = 1.0
        min_music_fast = common.lerp(MIN_MUSIC_FAST_TIME, END_MIN_MUSIC_FAST_TIME, game_percent)
        max_music_fast = common.lerp(MAX_MUSIC_FAST_TIME, END_MAX_MUSIC_FAST_TIME, game_percent)

        min_music_slow = common.lerp(MIN_MUSIC_SLOW_TIME, END_MIN_MUSIC_SLOW_TIME, game_percent)
        max_music_slow = common.lerp(MAX_MUSIC_SLOW_TIME, END_MAX_MUSIC_SLOW_TIME, game_percent)
        if speed_up:
            added_time = random.uniform(min_music_fast, max_music_fast)
        else:
            added_time = random.uniform(min_music_slow, max_music_slow)
        return time.time() + added_time

    def change_music_speed(self, fast):
        change_percent = numpy.clip((time.time() - self.change_time) / INTERVAL_CHANGE, 0, 1)
        if fast:
            self.music_speed.value = common.lerp(FAST_MUSIC_SPEED, SLOW_MUSIC_SPEED, change_percent)
        elif not fast:
            self.music_speed.value = common.lerp(SLOW_MUSIC_SPEED, FAST_MUSIC_SPEED, change_percent)
        self.audio.change_ratio(self.music_speed.value)

    def check_music_speed(self):
        if time.time() > self.change_time and time.time() < self.change_time + INTERVAL_CHANGE:
            self.change_music_speed(self.speed_up)
            self.currently_changing = True
            self.audio.change_chunk_size(True)
        elif time.time() >= self.change_time + INTERVAL_CHANGE and self.currently_changing:
            self.music_speed.value = SLOW_MUSIC_SPEED if self.speed_up else FAST_MUSIC_SPEED
            self.speed_up = not self.speed_up
            self.change_time = self.get_change_time(speed_up=self.speed_up)
            self.audio.change_ratio(self.music_speed.value)
            self.currently_changing = False
            self.audio.change_chunk_size(False)

    def get_real_team(self, team):
        if team < 0:
            return -1
        else:
            return team

    def reveal(self):
        self.werewolf_reveal.value = 2

    def werewolf_audio_cue(self):
        if self.game_mode == common.Games.WereJoust.value:
            # print self.werewolf_timer - (time.time() - self.start_timer)
            if self.werewolf_timer - (time.time() - self.start_timer) <= 30 and self.audio_cue == 0:
                Audio("audio/Joust/sounds/30 werewolf.wav").start_effect()
                self.audio_cue = 1
            if self.werewolf_timer - (time.time() - self.start_timer) <= 10 and self.audio_cue == 1:
                Audio("audio/Joust/sounds/10 werewolf.wav").start_effect()
                self.audio_cue = 2
            if self.werewolf_timer - (time.time() - self.start_timer) <= 0 and self.audio_cue == 2:
                Audio("audio/Joust/sounds/werewolf reveal 2.wav").start_effect()
                self.reveal()
                self.audio_cue = 3

    def check_end_game(self):
        winning_team = -100
        team_win = True
        for move_serial, dead in self.dead_moves.items():
            # if we are alive
            if dead.value == 1:
                if winning_team == -100:
                    winning_team = self.get_real_team(self.teams[move_serial])
                elif self.get_real_team(self.teams[move_serial]) != winning_team:
                    team_win = False
            if dead.value == 0:
                # This is to play the sound effect
                self.num_dead += 1
                dead.value = -1
                self.explosion.start_effect()

        if team_win:
            self.end_game_sound(winning_team)
            for move_serial in self.teams.keys():
                if self.get_real_team(self.teams[move_serial]) == winning_team:
                    self.winning_moves.append(move_serial)
            self.game_end = True

    def stop_tracking_moves(self):
        for proc in self.tracked_moves.values():
            proc.terminate()
            proc.join()
            time.sleep(0.02)

    def end_game(self):
        self.audio.stop_audio()
        end_time = time.time() + END_GAME_PAUSE
        h_value = 0

        while time.time() < end_time:
            time.sleep(0.01)
            win_color = common.hsv2rgb(h_value, 1, 1)
            for win_move in self.winning_moves:
                win_color_array = self.force_move_colors[win_move]
                common.change_color(win_color_array, *win_color)
            h_value = h_value + 0.01
            if h_value >= 1:
                h_value = 0
        self.running = False

    def end_game_sound(self, winning_team):
        if self.game_mode == common.Games.JoustTeams.value:
            if winning_team == 0:
                team_win = Audio("audio/Joust/sounds/yellow team win.wav")
            if winning_team == 1:
                team_win = Audio("audio/Joust/sounds/green team win.wav")
            if winning_team == 2:
                team_win = Audio("audio/Joust/sounds/cyan team win.wav")
            if winning_team == 3:
                team_win = Audio("audio/Joust/sounds/blue team win.wav")
            if winning_team == 4:
                team_win = Audio("audio/Joust/sounds/magenta team win.wav")
            if winning_team == 5:
                team_win = Audio("audio/Joust/sounds/red team win.wav")
            team_win.start_effect()
        if self.game_mode == common.Games.JoustRandomTeams.value:
            if winning_team == 0:
                team_win = Audio("audio/Joust/sounds/yellow team win.wav")
            if winning_team == 1:
                team_win = Audio("audio/Joust/sounds/cyan team win.wav")
            if winning_team == 2:
                team_win = Audio("audio/Joust/sounds/magenta team win.wav")
            if winning_team == 3:
                team_win = Audio("audio/Joust/sounds/red team win.wav")
            team_win.start_effect()
        if self.game_mode == common.Games.WereJoust.value:
            if winning_team == -1:
                team_win = Audio("audio/Joust/sounds/werewolf win.wav")
            else:
                team_win = Audio("audio/Joust/sounds/human win.wav")
            team_win.start_effect()
        # self.explosion = Audio('audio/Joust/sounds/Explosion34.wav')

    def werewolf_intro(self):
        Audio("audio/Joust/sounds/werewolf intro.wav").start_effect()
        time.sleep(3)
        self.change_all_move_colors(80, 0, 0)
        time.sleep(2)
        self.change_all_move_colors(30, 0, 0)
        time.sleep(18)
        self.change_all_move_colors(20, 20, 20)
        time.sleep(2)
        self.start_timer = time.time()

    def game_loop(self):
        self.track_moves()
        if self.game_mode == common.Games.WereJoust.value:
            self.werewolf_intro()
        self.werewolf_reveal.value = 1
        self.count_down()
        time.sleep(0.02)
        self.audio.start_audio_loop()
        time.sleep(0.8)

        while self.running:
            self.check_music_speed()
            self.check_end_game()
            self.werewolf_audio_cue()
            if self.game_end:
                self.end_game()

        self.stop_tracking_moves()
コード例 #38
0
ファイル: joust.py プロジェクト: aangert/PiParty
 def end_game_sound(self, winning_team):
     if self.game_mode == common.Games.JoustTeams.value:
         if winning_team == 0:
             team_win = Audio("audio/Joust/sounds/yellow team win.wav")
         if winning_team == 1:
             team_win = Audio("audio/Joust/sounds/green team win.wav")
         if winning_team == 2:
             team_win = Audio("audio/Joust/sounds/cyan team win.wav")
         if winning_team == 3:
             team_win = Audio("audio/Joust/sounds/blue team win.wav")
         if winning_team == 4:
             team_win = Audio("audio/Joust/sounds/magenta team win.wav")
         if winning_team == 5:
             team_win = Audio("audio/Joust/sounds/red team win.wav")
         team_win.start_effect()
     if self.game_mode == common.Games.JoustRandomTeams.value:
         if winning_team == 0:
             team_win = Audio("audio/Joust/sounds/yellow team win.wav")
         if winning_team == 1:
             team_win = Audio("audio/Joust/sounds/cyan team win.wav")
         if winning_team == 2:
             team_win = Audio("audio/Joust/sounds/magenta team win.wav")
         if winning_team == 3:
             team_win = Audio("audio/Joust/sounds/red team win.wav")
         team_win.start_effect()
     if self.game_mode == common.Games.WereJoust.value:
         if winning_team == -1:
             team_win = Audio("audio/Joust/sounds/werewolf win.wav")
         else:
             team_win = Audio("audio/Joust/sounds/human win.wav")
         team_win.start_effect()
コード例 #39
0
ファイル: bubble.py プロジェクト: aangert/PiParty
class Bubble():
    def __init__(self, moves):

        self.move_serials = moves
        self.tracked_moves = {}
        self.dead_moves = {}
        self.scores = {}
        self.music_speed = Value('d', 1.5)
        self.running = True
        self.force_move_colors = {}
        self.teams = {}
        self.win_amount = int(math.ceil((len(moves)/2.0)+2))
        self.team_num = 2

        self.generate_random_teams(self.team_num)

        music = 'audio/Joust/music/' + random.choice(os.listdir('audio/Joust/music'))
        self.start_beep = Audio('audio/Joust/sounds/start.wav')
        self.start_game = Audio('audio/Joust/sounds/start3.wav')
        self.explosion = Audio('audio/Joust/sounds/Explosion34.wav')
        fast_resample = False
        if len(moves) >= 5:
            fast_resample = True
        self.audio = Audio(music, fast_resample)
        #self.change_time = self.get_change_time(speed_up = True)
        self.change_time = time.time() + 8
        self.speed_up = True
        self.currently_changing = False
        self.game_end = False
        self.winning_moves = []
        self.losing_moves = []
        
        
        self.game_loop()


    def generate_random_teams(self, team_num):
        team_pick = range(team_num)
        for serial in self.move_serials:
            random_choice = random.choice(team_pick)
            self.teams[serial] = random_choice
            team_pick.remove(random_choice)
            if not team_pick:
                team_pick = range(team_num)

    def track_moves(self):
        for move_num, move_serial in enumerate(self.move_serials):
            dead_move = Value('i', 1)
            score = Value('i', 0)
            
            force_color = Array('i', [1] * 3)
            proc = Process(target=track_move, args=(move_serial,
                                                    move_num,
                                                    self.teams[move_serial],
                                                    self.team_num,
                                                    score,
                                                    self.win_amount,
                                                    dead_move,
                                                    force_color,
                                                    self.music_speed))
            proc.start()
            self.scores[move_serial] = score
            self.tracked_moves[move_serial] = proc
            self.dead_moves[move_serial] = dead_move
            self.force_move_colors[move_serial] = force_color
            
    def change_all_move_colors(self, r, g, b):
        for color in self.force_move_colors.itervalues():
            common.change_color(color, r, g, b)

    #need to do the count_down here
    def count_down(self):
        self.change_all_move_colors(70, 0, 0)
        self.start_beep.start_effect()
        time.sleep(0.75)
        self.change_all_move_colors(70, 100, 0)
        self.start_beep.start_effect()
        time.sleep(0.75)
        self.change_all_move_colors(0, 70, 0)
        self.start_beep.start_effect()
        time.sleep(0.75)
        self.change_all_move_colors(0, 0, 0)
        self.start_game.start_effect()
        
    def get_change_time(self, speed_up):
        if speed_up:
            added_time = random.uniform(MIN_MUSIC_FAST_TIME, MAX_MUSIC_FAST_TIME)
        else:
            added_time = random.uniform(MIN_MUSIC_SLOW_TIME, MAX_MUSIC_SLOW_TIME)
        return time.time() + added_time

    def change_music_speed(self, fast):
        change_percent = numpy.clip((time.time() - self.change_time)/INTERVAL_CHANGE, 0, 1)
        if fast:
            self.music_speed.value = common.lerp(FAST_MUSIC_SPEED, SLOW_MUSIC_SPEED, change_percent)
        elif not fast:
            self.music_speed.value = common.lerp(SLOW_MUSIC_SPEED, FAST_MUSIC_SPEED, change_percent)
        self.audio.change_ratio(self.music_speed.value)

    def check_music_speed(self):
        if time.time() > self.change_time and time.time() < self.change_time + INTERVAL_CHANGE:
            self.change_music_speed(self.speed_up)
            self.currently_changing = True
            self.audio.change_chunk_size(True)
        elif time.time() >= self.change_time + INTERVAL_CHANGE and self.currently_changing:
            self.music_speed.value = SLOW_MUSIC_SPEED if self.speed_up else FAST_MUSIC_SPEED
            self.speed_up =  not self.speed_up
            self.change_time = self.get_change_time(speed_up = self.speed_up)
            self.audio.change_ratio(self.music_speed.value)
            self.currently_changing = False
            self.audio.change_chunk_size(False)

    def get_real_team(self, team):
        if team < 0:
            return -1
        else:
            return team

    def check_end_game(self):
        team_win = False
        for move_serial, score in self.scores.iteritems():
            #if we are alive
            if score.value >= self.win_amount:
                winning_team = self.teams[move_serial]
                team_win = True
                
        if team_win:
            for move_serial in self.teams.iterkeys():
                if self.teams[move_serial] == winning_team:
                    self.winning_moves.append(move_serial)
                else:
                    self.losing_moves.append(move_serial)
            self.game_end = True

    def check_for_points(self):
        for move_serial, score in self.scores.iteritems():
            if score.value == -1:
                score.value = 0
                self.explosion.start_effect()
                team_increase = self.teams[move_serial]
                for move_serial_increase, score_increase in self.scores.iteritems():
                    if self.teams[move_serial_increase] != team_increase:
                        score_increase.value += 1
            

    def stop_tracking_moves(self):
        for proc in self.tracked_moves.itervalues():
            proc.terminate()
            proc.join()

    def end_game(self):
        self.audio.stop_audio()
        end_time = time.time() + END_GAME_PAUSE
        h_value = 0
        while (time.time() < end_time):
            time.sleep(0.01)
            win_color = common.hsv2rgb(h_value, 1, 1)
            for win_move in self.winning_moves:
                win_color_array = self.force_move_colors[win_move]
                common.change_color(win_color_array, *win_color)
            for lose_move in self.losing_moves:
                lose_color_array = self.force_move_colors[lose_move]
                common.change_color(lose_color_array, 1,0,0)
            h_value = (h_value + 0.01)
            if h_value >= 1:
                h_value = 0
        self.running = False

    def game_loop(self):
        self.track_moves()
        self.count_down()
        self.audio.start_audio_loop()
        
        while self.running:

            self.check_music_speed()
            self.check_for_points()
            self.check_end_game()
            if self.game_end:
                self.end_game()

        self.stop_tracking_moves()