Exemplo n.º 1
0
    def __init__(self,
                 width=Settings.SCREEN_WIDTH,
                 height=Settings.SCREEN_HEIGHT):
        pygame.init()
        self.width = width
        self.height = height
        self.screen = pygame.display.set_mode((self.width, self.height))
        self.shooting = False
        self.shoot_ticker = 0  #Can shoot without waiting
        self.MAX_SHOOT_TICKER = 30  #One shot every x frames
        self.spawn_ticker = 1800  #Start spawning 1800 frames in.
        self.MAX_SPAWN_TICKER = 1800  #Max one new enemy every 1800 frames
        self.GAME_OVER = False
        self.END_GAME = False
        self.END_CREDITS = False
        self.RESPAWNING = False
        self.respawn_ticker = 0

        self.SCORE = 0  ##################
        self.HIGHSCORES = []
        self.checkHighscore()

        self.wave1_pass = False
        self.wave2_pass = False
        self.wave3_pass = False
        self.boss_spawned = False
        self.enemies_killed = 0  #Number of enemy01 killed

        self.music = Music("MainLoop")

        self.clock = pygame.time.Clock()
        self.LIVES = 3  #############
Exemplo n.º 2
0
def main():
    """Main function to get information for Bar 3.
    """
    getter_volume = Volume.Volume()
    getter_music = Music.Music()

    getter_volume.show_info()
    sys.stdout.write(" | ")
    getter_music.show_song()
Exemplo n.º 3
0
    def __init__(self, imageDir, imageScreenOne, imageScreenTwo,
                 imageScreenThree, imageSerialPopup):
        # imageDir: directory for image
        # imageScreenOne: background image for the first screen
        # imageScreenTwo: background image for the second screen
        # imageScreenThree: background image for the third screen

        # initialization
        self.imageDir = imageDir
        self.imageScreenOne = imageScreenOne
        self.imageScreenTwo = imageScreenTwo
        self.imageScreenThree = imageScreenThree
        self.imageSerialPopup = imageSerialPopup
        # this are the proportion of us screen and will be used to
        # change dimension of window if the computer of user has different dimension
        self.imageW = 1366
        self.imageH = 766
        self.minRandTime = 10
        self.maxRandTime = 20
        # we initialize variable for mean
        self.minPartialInit = 100000
        self.minPartial = self.minPartialInit
        self.minMeanInit = 100000
        self.minMean = self.minMeanInit
        self.count = 0
        self.tot = 0
        self.meanYPos = 0
        self.flag_off = 0
        self.flag_on = 1
        self.__toggle = 0
        # we initialize user variable
        self.__user = "******"
        # we set a flag that is uset to know if play restart, in this case
        # music mustn't restart
        self.__tryAgainFlagForMusic = 0

        # we initialize rootscreen
        self.window = tk.Tk()
        self.window.title("The reaction game")
        #read the dimensions of the screen
        self.widthScreen, self.heightScreen = self.window.winfo_screenwidth(
        ), self.window.winfo_screenheight()
        #calculate the dimensions of the main window
        self.widthRoot, self.heightRoot = int(self.widthScreen / 2), int(
            self.heightScreen / 2)
        #setup of the window dimensions
        self.window.geometry("%dx%d" % (self.widthRoot, self.heightRoot))
        #block the possibility to resize the dimensions of the window
        self.window.resizable(width=False, height=False)

        # we initialize serial object
        self.serialObj = serialConnection(self.window, self.imageDir,
                                          self.imageSerialPopup)

        # we start music
        self.music = Music(self.window, "Img/", "sound_on.png",
                           "sound_off.png", "Music/", "InstantCrush.wav")
Exemplo n.º 4
0
 def main(self):
     #load panels
     self.music = Music.Music(self)
     self.music.start()
     self.shell = Shell.Shell(self)
     self.shell.start()
     self.toogle(self.PANE_SHELL)
     #start event loop
     self.eventThread = EventThread(self)
     self.eventThread.start()
Exemplo n.º 5
0
 def spawnEnemies(self):
     #Wave 1
     if self.enemies_killed < Settings.WAVE1_PASS and self.wave1_pass == False:
         if self.spawn_ticker > 0:
             self.spawn_ticker -= 1
         elif self.spawn_ticker == 0:
             new_enemy = Enemy01()
             self.enemy_sprites.add(new_enemy)
             self.spawn_ticker = self.MAX_SPAWN_TICKER
     elif self.enemies_killed >= Settings.WAVE1_PASS and self.wave1_pass == False:
         self.enemies_killed = 0
         self.wave1_pass = True
     #Wave 2
     if self.enemies_killed < Settings.WAVE2_PASS and self.wave2_pass == False and self.wave1_pass == True:
         if self.spawn_ticker > 0:
             self.spawn_ticker -= 1
         elif self.spawn_ticker == 0:
             tmp = random.randint(0, 1)
             if tmp == 0:
                 new_enemy1 = Enemy01()
                 self.enemy_sprites.add(new_enemy1)
             new_enemy = Enemy02()
             self.enemy_sprites.add(new_enemy)
             self.spawn_ticker = self.MAX_SPAWN_TICKER
     elif self.enemies_killed >= Settings.WAVE2_PASS and self.wave2_pass == False:
         self.enemies_killed = 0
         self.wave2_pass = True
     #Wave 3
     if self.enemies_killed < Settings.WAVE3_PASS and self.wave3_pass == False and self.wave1_pass == True and self.wave2_pass == True:
         if self.spawn_ticker > 0:
             self.spawn_ticker -= 1
         elif self.spawn_ticker == 0:
             tmp = random.randint(0, 2)
             if tmp == 0:
                 new_enemy1 = Enemy01()
                 self.enemy_sprites.add(new_enemy1)
             tmp = random.randint(0, 3)
             if tmp == 0:
                 new_enemy2 = Enemy02()
                 self.enemy_sprites.add(new_enemy2)
             new_enemy = Enemy03()
             self.enemy_sprites.add(new_enemy)
             self.spawn_ticker = self.MAX_SPAWN_TICKER
     elif self.enemies_killed >= Settings.WAVE3_PASS and self.wave3_pass == False:
         self.enemies_killed = 0
         self.wave3_pass = True
     #Boss
     if self.wave1_pass and self.wave2_pass and self.wave3_pass and self.boss_spawned == False:
         self.enemy_sprites.add(Boss())
         self.music = Music("Blaze")
         self.music.play()
         self.boss_spawned = True
Exemplo n.º 6
0
 def __init__(self, tempo):
     self.volume = 16384
     self.samplerate = 44100
     self.p = pyaudio.PyAudio()
     self.stream = self.p.open(format=8,
                               channels=1,
                               rate=self.samplerate,
                               output=True)
     self.totalsignal = []
     self.m = Music.Music()
     self.tempo = tempo
     self.BPS = 60.0 / tempo
     # self.signalLog = open("signalLog.txt", 'r+')
     self.frameCounter = 0
Exemplo n.º 7
0
    def loadMusic(self):
        self.channel1 = pygame.mixer.Channel(0)
        self.channel2 = pygame.mixer.Channel(1)

        self.instructionMusic = Music.Music(self.channel1, "instruction.wav")
        self.click1Music = Music.Music(self.channel2, "click1.wav")
        self.click2Music = Music.Music(self.channel2, "click2.wav")
        self.startMusic = Music.Music(self.channel1, "start.wav")

        self.game1Music = Music.Music(self.channel1, "game1.wav")
        self.game2Music = Music.Music(self.channel1, "game2.wav")

        self.endMusic = Music.Music(self.channel1, "victory.wav")
Exemplo n.º 8
0
 def searchmusic(self, musicname, pageno):
     url = "http://y.webzcz.cn/api.php"
     para = {
         "types": "search",
         "count": 10,
         "source": "netease",
         "pages": pageno,
         "name": musicname
     }
     musics = requests.post(url, data=para).json()
     musicslist = list()
     for musicDic in musics:
         music = Music(musicDic)
         musicslist.append(music)
     return musicslist
Exemplo n.º 9
0
 def __init__(self, parent):
     wx.Panel.__init__(self, parent)
     
     panel = wx.Panel(self, size=(WINDOW_WIDTH, WINDOW_HEIGHT))
     nb = wx.Notebook(panel)
     
     sd = Sounds(nb)
     mu = Music(nb)
     
     nb.AddPage(sd, "Sounds")
     nb.AddPage(mu, "Music")
     
     sizer = wx.BoxSizer()
     sizer.Add(nb, 1, wx.EXPAND)
     
     self.SetSizer(sizer)
Exemplo n.º 10
0
    def __init__(self, directory):
        self.directory = directory   # Directory of app
        
        # Initialize pygame
        pygame.init()
        pygame.font.init()
        self.fps = 60
        self.background = pygame.image.load(self.directory + \
                                            "/images/background.jpg")
        self.header     = pygame.image.load(self.directory + \
                                            "/images/header.png")
        self.footer     = pygame.image.load(self.directory + \
                                            "/images/footer.png")
        self.border     = pygame.image.load(self.directory + \
                                            "/images/border.png")

        # Read config file
        self.configFile()

        # Initialize song list
        self.songs = SongList(self.directory, self.musicDirectory)
        self.musicDirectory = self.songs.getDirectory()
        self.musicDirectory = self.musicDirectory.rstrip(SLASH) + SLASH
        
        # Initialize music player
        self.musicPlayer = Music(self.musicDirectory)

        # Set up song information
        path = self.songs.getPath(self.currentSong)
        title = self.songs.getTitle(self.currentSong)
        self.musicPlayer.setSongInformation(path, title)
        
        # Call method to set up GUI
        self.setupGUI()

        # Call method to run app
        self.runApp()
Exemplo n.º 11
0
    'info': ['ai03', 'goat', 'kalendar'],
    'films': ['apex', 'ash', 'kebo', 'tx'],
    'firmware': ['qmkgui', 'via'],
    'services': ['ash'],
    'artisans':
    ['alpha', 'jelly', 'kpr', 'kyle', 'mk', 'scraft', 'space', 'summit'],
    'ergo': ['aura', 'mkultra', 'wooting'],
    'springs': ['prime', 'tx'],
    'deskmats':
    ['aura', 'cannon', 'deskhero', 'kono', 'kpr', 'nk', 'prime', 'tkc', 'tx'],
    'groupbuy': [
        'candy', 'cannon', 'dclack', 'deskhero', 'dixie', 'kono', 'krelbit',
        'nk', 'origin', 'tkc', 'tx', 'wei'
    ],
    'cad': ['apex', 'ash', 'aura', 'deskhero', 'kofi', 'zeal']
}

# load pickles
tagDict = load_dict(Constants.TAG_DICT_PATH)
siteDict = load_dict(Constants.SITE_DICT_PATH)
typeDict = load_dict(Constants.TYPE_DICT_PATH)
bDict = load_dict(Constants.B_DICT_PATH)
aDict = load_dict(Constants.A_DICT_PATH)
shareDict = load_dict(Constants.SHARE_DICT_PATH)

# startup
bot.add_cog(Timezone(bot))
bot.add_cog(Music(bot))
bot.add_cog(Currency(bot))
bot.run(Constants.DISCORD_SECRET)
Exemplo n.º 12
0
def play_game(playground, clock, painter, leonardo,
              controller: Control_feedback.Controller, sound):
    objekt = RandomBlock.RandomBlock()
    current_block = objekt.get_random_block()
    next_block = objekt.get_random_block()
    points = Points.Points()
    sounds = Sound.Sound()
    walkman = Music.Music(0.3)
    walkman.start()
    playground.put_block(current_block)
    game_over = False
    in_pause = False
    action_counter = 0
    while not game_over:
        actions = controller.pressed()
        if in_pause is False and "Pause" in actions:
            in_pause = True
        else:
            if "Pause" in actions:
                in_pause = False

        if not in_pause:
            leonardo.draw(str(points.points), next_block)
            for action in actions:
                future_block = get_block_after_action(current_block, action)
                executable = not playground.collieds(future_block)
                if action == "down":
                    if executable:
                        current_block = future_block

                    else:
                        playground.put_block(current_block)
                        full_line_count = handle_full_lines(
                            playground, points, sound)
                        if current_block.y + full_line_count < 0:
                            game_over = True
                            sounds.game_over()
                        else:
                            if current_block.y < 5:
                                sound.warning()
                            else:
                                sound.reached_limit()
                            current_block, next_block = switch_blocks(
                                next_block, points)

                else:
                    if executable:
                        current_block = future_block
            draw(current_block, painter, playground)
            clock.tick((16.5 / 10000) * points.points + 3.5)

            action_counter += 1
            if action_counter == 4:
                controller.add_action("down")
                action_counter = 0
        else:
            leonardo.write_text("Pause...")
            pygame.time.delay(200)

    walkman.stop()

    game_over_screen(playground, leonardo, points, sounds, controller)
Exemplo n.º 13
0
list_of_music = [
    ("Goldroom", "Silhouette"), ("Motörhead", "Ace of Spades")
    #("Dream Theater", "Glass Prison"),
    #("Dream Theater", "Pull Me Under"),
    #("Michael Jackson", "Bad"),
    #("Pink Floyd", "Time"),
    #("Pink Floyd", "Keep Talking"),
    #("Rick Astley", "Never Gonna Give You Up"),
    #("Foster The People", "Pumped Up Kicks"),
    #("Panic at The Disco", "Nine in The Afternoon"),
    #("Tom Jobim", "Chega de Saudade"),
    #("Tom Jobim", "Garota de Ipanema"),
    #("Blind Guardian","Mirror Mirror"),
    #("Zumbis do Espaco", "Satan Chegou"),
    #("Panic! at The Disco", "Hey Look Ma, I made It"),
    #("Pink Floyd", "High Hopes"), ("Panic! at The Disco", "High Hopes"),
    #("Imagine Dragons", "Natural"),
    #("twenty one pilots", "Chlorine"),
    #("The Black Keys","Lo Hi"),
    #("Iron Maiden","Blood Brothers"),
    #("Iron Maiden","The Trooper")
]

for (artist, title) in list_of_music:
    test1 = msc.Music(artist, title)
    for word in load_stop_words():
        test1.remove_word_from_lyric(word)
    gw = msc.GraphicalWriter(test1)
    gw.create_grafical_representation()