コード例 #1
0
ファイル: plot.py プロジェクト: j-a-c/avengers
    def update(self):

        evman = eventmanager.get()

        if evman.MOUSE1CLICK != False:
            event = evman.MOUSE1CLICK
            clickpoint = event.pos
            #clickpoint = (camera.window.left+clickpoint[0],camera.window.top+clickpoint[1])

            if self.volume_button.get_rect().collidepoint(clickpoint):
                self.vol = not self.vol
                if self.vol:
                    sound.set_bgm_vol(self.bgm_vol)
                    sound.set_sfx_vol(self.sfx_vol)
                else:
                    #update the volume before muting
                    self.bgm_vol = sound.get_bgm_vol()
                    self.sfx_vol = sound.get_sfx_vol()
                    sound.set_bgm_vol(0)
                    sound.set_sfx_vol(0)

#            else
#                self.playing = True
                  
            if self.plot_skip_button.get_rect().collidepoint(clickpoint):
                self.plotOver = True
            elif self.plot_next_button.get_rect().collidepoint(clickpoint) and self.currentPlot < self.maxPlot:
                self.currentPlot = self.currentPlot + 1
            elif self.plot_back_button.get_rect().collidepoint(clickpoint) and self.currentPlot > 1:
                self.currentPlot = self.currentPlot - 1
            elif self.plot_back_button.get_rect().collidepoint(clickpoint) and self.currentPlot == 1:
                pass
            elif self.plot_next_button.get_rect().collidepoint(clickpoint) and self.currentPlot == self.maxPlot:
                self.plotOver = True
コード例 #2
0
ファイル: hud.py プロジェクト: j-a-c/avengers
    def update(self):
        evman = eventmanager.get()
        if evman.MOUSE1CLICK != False:
            event = evman.MOUSE1CLICK
            clickpoint = event.pos

            if self.volume_button.get_rect().collidepoint(clickpoint):
                self.vol = not self.vol
                if self.vol:
                    sound.set_bgm_vol(self.bgm_vol)
                    sound.set_sfx_vol(self.sfx_vol)
                else:
                    #update the volume before muting
                    self.bgm_vol = sound.get_bgm_vol()
                    self.sfx_vol = sound.get_sfx_vol()
                    sound.set_bgm_vol(0)
                    sound.set_sfx_vol(0)
コード例 #3
0
    def update(self):
        evman = eventmanager.get()
        if evman.MOUSE1CLICK != False:
            event = evman.MOUSE1CLICK
            clickpoint = event.pos

            if self.volume_button.get_rect().collidepoint(clickpoint):
                self.vol = not self.vol
                if self.vol:
                    sound.set_bgm_vol(self.bgm_vol)
                    sound.set_sfx_vol(self.sfx_vol)
                else:
                    #update the volume before muting
                    self.bgm_vol = sound.get_bgm_vol()
                    self.sfx_vol = sound.get_sfx_vol()
                    sound.set_bgm_vol(0)
                    sound.set_sfx_vol(0)
コード例 #4
0
    def __init__(self):
        #center screen
        os.environ['SDL_VIDEO_CENTERED'] = '1'

        #initialize pygame lib
        pygame.init()

        #creates window
        self.screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
        pygame.display.set_caption('The Avengers - Six Guys')
        logger.get().setScreen(self.screen)

        #Make a camera (this might need to go inside the level object, but that's ok)
        self.camera = camera.Camera(self.screen)
        logger.get().setCamera(self.camera)

        #number of the current level
        self.levelNumber = 0  #default 1, change for debugging
        self.currLevel = self.getCurrentLevel()
        logger.get().setLevel(self.levelNumber)

        #player starts with 3 lives
        self.player_lives = constants.PLAYER_LIVES
        self.invincible = False

        #menus
        self.startMenu = startmenu.StartMenu()
        self.pauseMenu = pausemenu.PauseMenu()
        logger.get().setMenu(self.startMenu)
        logger.get().setAvengersObj(self)

        #the hud
        self.hud = hud.HUD()

        #I wanna listen to my music while I develop dammit!
        if "-m" in sys.argv:
            sound.set_bgm_vol(0)
            sound.set_sfx_vol(0)
            self.hud.vol = False

        #Skip all that clicking, ain't nobody got time for that
        if "-p" in sys.argv:
            self.startMenu.playing = True
コード例 #5
0
ファイル: avengers.py プロジェクト: j-a-c/avengers
    def __init__(self):
        #center screen
        os.environ['SDL_VIDEO_CENTERED'] = '1'

        #initialize pygame lib
        pygame.init()

        #creates window
        self.screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
        pygame.display.set_caption('The Avengers - Six Guys')
        logger.get().setScreen(self.screen)

        #Make a camera (this might need to go inside the level object, but that's ok)
        self.camera = camera.Camera(self.screen)
        logger.get().setCamera(self.camera)

        #number of the current level
        self.levelNumber = 0    #default 1, change for debugging
        self.currLevel = self.getCurrentLevel()
        logger.get().setLevel(self.levelNumber)

        #player starts with 3 lives
        self.player_lives = constants.PLAYER_LIVES
        self.invincible = False

        #menus
        self.startMenu = startmenu.StartMenu()
        self.pauseMenu = pausemenu.PauseMenu()
        logger.get().setMenu(self.startMenu)
        logger.get().setAvengersObj(self)

        #the hud
        self.hud = hud.HUD()

        #I wanna listen to my music while I develop dammit!
        if "-m" in sys.argv:
            sound.set_bgm_vol(0)
            sound.set_sfx_vol(0)
            self.hud.vol = False

        #Skip all that clicking, ain't nobody got time for that
        if "-p" in sys.argv:
            self.startMenu.playing = True
コード例 #6
0
ファイル: startmenu.py プロジェクト: j-a-c/avengers
    def update(self):

        evman = eventmanager.get()

        if evman.MOUSE1CLICK != False:
            event = evman.MOUSE1CLICK
            clickpoint = event.pos

            #StartMenu
            if not self.show_instructions and not self.show_options and not self.show_level:
                #new game
                if self.newgame_button.get_rect().collidepoint(clickpoint):
                    #self.currentLevel = 0
                    self.show_level = True
                #load game
                elif self.loadgame_button.get_rect().collidepoint(clickpoint):
                    if os.path.isfile('save'):
                        self.loadLevel = True

                #options
                elif self.options_button.get_rect().collidepoint(clickpoint):
                    self.show_instructions = False
                    self.show_options = True
                #exit
                elif self.quit_button.get_rect().collidepoint(clickpoint):
                    print("Exiting....")
                    sys.exit(0)

                #isntructions
                elif self.instructions_button.get_rect().collidepoint(clickpoint):
                    self.show_options = False
                    self.show_instructions = True

            #Options Menu
            elif self.show_options:
                if self.volup_button.get_rect().collidepoint(clickpoint):
                    #clicked bgm vol up
                    sound.set_bgm_vol(sound.get_bgm_vol() + 10)
                    sys.stdout.write('BGM vol: %s\n' % (sound.get_bgm_vol()))
                elif self.voldown_button.get_rect().collidepoint(clickpoint):
                    #clicked bgm vol down
                    sound.set_bgm_vol(sound.get_bgm_vol() - 10)
                    sys.stdout.write('BGM vol: %s\n' % (sound.get_bgm_vol()))
                elif self.volupFX_button.get_rect().collidepoint(clickpoint):
                    #clicked sfx vol up
                    sound.set_sfx_vol(sound.get_sfx_vol() + 10)
                    sound.play_sfx('sounds/sfx/punch.wav')
                    sys.stdout.write('SFX vol: %s\n' % (sound.get_sfx_vol()))
                elif self.voldownFX_button.get_rect().collidepoint(clickpoint):
                    #clicked sfx vol down
                    sound.set_sfx_vol(sound.get_sfx_vol() - 10)
                    sound.play_sfx('sounds/sfx/punch.wav')
                    sys.stdout.write('SFX vol: %s\n' % (sound.get_sfx_vol()))
                elif self.gammaUp_button.get_rect().collidepoint(clickpoint):
                    #clicked gamma up
                    if self.gamma < 2.5:
                        self.gamma = self.gamma + .1
                    pygame.display.set_gamma(self.gamma)
                    sys.stdout.write('Gamma: %s\n' % (self.gamma))
                elif self.gammaDown_button.get_rect().collidepoint(clickpoint):
                    #clicked gamma down
                    if self.gamma > 0.2:
                        self.gamma = self.gamma - .1
                    pygame.display.set_gamma(self.gamma)
                    sys.stdout.write('Gamma: %s\n' % (self.gamma))
                elif self.options_back_button.get_rect().collidepoint(clickpoint):
                    #clicked back
                    self.show_options = False
            #Options Menu
            elif self.show_level:
                if self.lvltut.get_rect().collidepoint(clickpoint):
                    self.setLevel(0)
                elif self.lvl1.get_rect().collidepoint(clickpoint):
                    self.setLevel(1)
                elif self.lvl2.get_rect().collidepoint(clickpoint):
                    self.setLevel(2)
                elif self.lvl3.get_rect().collidepoint(clickpoint):
                    self.setLevel(3)
                elif self.lvl4.get_rect().collidepoint(clickpoint):
                    self.setLevel(4)
                elif self.lvl5.get_rect().collidepoint(clickpoint):
                    self.setLevel(5)
                
            #if on instructions go back to StartMenu
            else:
                if self.back_button.get_rect().collidepoint(clickpoint):
                    if self.show_instructions:
                        self.show_instructions = False
                    elif self.show_options:
                        self.show_options = False
コード例 #7
0
ファイル: startmenu.py プロジェクト: j-a-c/avengers
    def update(self):

        evman = eventmanager.get()

        if evman.MOUSE1CLICK != False:
            event = evman.MOUSE1CLICK
            clickpoint = event.pos

            #StartMenu
            if not self.show_instructions and not self.show_options and not self.show_level:
                #new game
                if self.newgame_button.get_rect().collidepoint(clickpoint):
                    #self.currentLevel = 0
                    self.show_level = True
                #load game
                elif self.loadgame_button.get_rect().collidepoint(clickpoint):
                    if os.path.isfile('save'):
                        self.loadLevel = True

                #options
                elif self.options_button.get_rect().collidepoint(clickpoint):
                    self.show_instructions = False
                    self.show_options = True
                #exit
                elif self.quit_button.get_rect().collidepoint(clickpoint):
                    print("Exiting....")
                    sys.exit(0)

                #isntructions
                elif self.instructions_button.get_rect().collidepoint(
                        clickpoint):
                    self.show_options = False
                    self.show_instructions = True

            #Options Menu
            elif self.show_options:
                if self.volup_button.get_rect().collidepoint(clickpoint):
                    #clicked bgm vol up
                    sound.set_bgm_vol(sound.get_bgm_vol() + 10)
                    sys.stdout.write('BGM vol: %s\n' % (sound.get_bgm_vol()))
                elif self.voldown_button.get_rect().collidepoint(clickpoint):
                    #clicked bgm vol down
                    sound.set_bgm_vol(sound.get_bgm_vol() - 10)
                    sys.stdout.write('BGM vol: %s\n' % (sound.get_bgm_vol()))
                elif self.volupFX_button.get_rect().collidepoint(clickpoint):
                    #clicked sfx vol up
                    sound.set_sfx_vol(sound.get_sfx_vol() + 10)
                    sound.play_sfx('sounds/sfx/punch.wav')
                    sys.stdout.write('SFX vol: %s\n' % (sound.get_sfx_vol()))
                elif self.voldownFX_button.get_rect().collidepoint(clickpoint):
                    #clicked sfx vol down
                    sound.set_sfx_vol(sound.get_sfx_vol() - 10)
                    sound.play_sfx('sounds/sfx/punch.wav')
                    sys.stdout.write('SFX vol: %s\n' % (sound.get_sfx_vol()))
                elif self.gammaUp_button.get_rect().collidepoint(clickpoint):
                    #clicked gamma up
                    if self.gamma < 2.5:
                        self.gamma = self.gamma + .1
                    pygame.display.set_gamma(self.gamma)
                    sys.stdout.write('Gamma: %s\n' % (self.gamma))
                elif self.gammaDown_button.get_rect().collidepoint(clickpoint):
                    #clicked gamma down
                    if self.gamma > 0.2:
                        self.gamma = self.gamma - .1
                    pygame.display.set_gamma(self.gamma)
                    sys.stdout.write('Gamma: %s\n' % (self.gamma))
                elif self.options_back_button.get_rect().collidepoint(
                        clickpoint):
                    #clicked back
                    self.show_options = False
            #Options Menu
            elif self.show_level:
                if self.lvltut.get_rect().collidepoint(clickpoint):
                    self.setLevel(0)
                elif self.lvl1.get_rect().collidepoint(clickpoint):
                    self.setLevel(1)
                elif self.lvl2.get_rect().collidepoint(clickpoint):
                    self.setLevel(2)
                elif self.lvl3.get_rect().collidepoint(clickpoint):
                    self.setLevel(3)
                elif self.lvl4.get_rect().collidepoint(clickpoint):
                    self.setLevel(4)
                elif self.lvl5.get_rect().collidepoint(clickpoint):
                    self.setLevel(5)

            #if on instructions go back to StartMenu
            else:
                if self.back_button.get_rect().collidepoint(clickpoint):
                    if self.show_instructions:
                        self.show_instructions = False
                    elif self.show_options:
                        self.show_options = False