예제 #1
0
    def __init__(self, game, name, index, config=None):
        super(GameOverScene, self).__init__(game, name, index, config)

        gameovermessage = config['message'] if 'message' in config else 'Game Over'
        gameovermusic = config['music'] if 'music' in config else 'gameover.ogg'

        self.gameovertxt = data.render_text(data.FONT_TITLE, 30, gameovermessage, (255, 255, 255))
        self.gameovertxtRect = self.gameovertxt.get_rect()
        self.background = data.load_image('gameover.png')

        self.music_bg = data.load_sound(gameovermusic)

        self.teaserText = data.render_text(data.FONT_MAIN, 17, 'Who\'s the rockstar with '+str(self.game.points)+' points ?', (255, 255, 255))
        self.teaserTextrect = self.teaserText.get_rect()

        #temp
        self.teaserTextInputRect = self.teaserTextrect
        self.blinkInputCounter = 0
        self.blinkInputTime = 400
        self.userFilledStr = []
        self.usernickText = None
        self.usernickTextRect = None
        self.userFillingTextField = True
        self.showUnderscore = True
        self.lScoreFile = None
        self.userscores = None
        self.orderedTabScore = []
        self.buildTabScore()
예제 #2
0
    def __init__(self, game, name, index, config=None):
        super(HowtoScene, self).__init__(game, name, index, config)

        self.bg_text = data.load_image('howtoplay.png')
        self.bg_text = pygame.transform.scale(self.bg_text, (534, 400))
        self.bg_textrect = self.bg_text.get_rect()
        
        fontText = data.load_font(data.FONT_MAIN, 20)
        fontText.set_bold(True)
        
        texts = [
            {'text':'1) The boss generates 1 to 9 sounds', 'top':30, 'left':50},
            {'text':'2) You must copy the generated sequence', 'top':250, 'left':20}
        ]
        
        for phrase in texts:
            text = fontText.render(phrase['text'], True, (255, 255, 255))
            textrect = text.get_rect()
            textrect.top = phrase['top']
            textrect.left = phrase['left']
            self.bg_text.blit(text, textrect)
        
        self.text = data.render_text(data.FONT_MAIN, 37, 'Push the button !', (255, 255, 255))
        self.textrect = self.text.get_rect()
        
#        bg_text.blit(self.text, self.textrect)

        self.background = data.load_image('credits.png')
        self.music_bg = data.load_sound('credits.ogg')
예제 #3
0
    def __init__(self, game, name, index, config=None):
        super(HowtoScene, self).__init__(game, name, index, config)

        self.bg_text = data.load_image('howtoplay.png')
        self.bg_text = pygame.transform.scale(self.bg_text, (534, 400))
        self.bg_textrect = self.bg_text.get_rect()

        fontText = data.load_font(data.FONT_MAIN, 20)
        fontText.set_bold(True)

        texts = [{
            'text': '1) The boss generates 1 to 9 sounds',
            'top': 30,
            'left': 50
        }, {
            'text': '2) You must copy the generated sequence',
            'top': 250,
            'left': 20
        }]

        for phrase in texts:
            text = fontText.render(phrase['text'], True, (255, 255, 255))
            textrect = text.get_rect()
            textrect.top = phrase['top']
            textrect.left = phrase['left']
            self.bg_text.blit(text, textrect)

        self.text = data.render_text(data.FONT_MAIN, 37, 'Push the button !',
                                     (255, 255, 255))
        self.textrect = self.text.get_rect()

        #        bg_text.blit(self.text, self.textrect)

        self.background = data.load_image('credits.png')
        self.music_bg = data.load_sound('credits.ogg')
예제 #4
0
 def start(self):
     #Blink text
     self.blinkText = data.render_text(data.FONT_MAIN, 15, '(Press SPACE to skip)', (51, 204, 0))
     self.blinkTextRect = self.blinkText.get_rect()
     self.blinkTextRect.center = (320, 30)
     self.blinkTextRect.top = 430
     
     #music
     self.game.channel = self.game.music.play(-1, fade_ms=4000)
     
     #which intro
     self.currentIntroIdx = 0
     self.endTime = pygame.time.get_ticks() + self.intros[0].duration
예제 #5
0
    def __init__(self, duration, canPass, text, textsize = 25):
        pygame.surface.Surface.__init__(self, (550, 380), flags=pygame.SRCALPHA)
        self.duration = duration
        self.canPass = canPass

        # Include texts into content
        tmpContent = None
        top = 0
        for partText in text:
            tmpContent = data.render_text(data.FONT_MAIN, textsize, partText, (255, 255, 255))
            tmpSize = tmpContent.get_rect()
            tmpSize.centerx = self.get_rect().centerx
            tmpSize.top = top
            self.blit(tmpContent, tmpSize)
            top = top + tmpSize.height * 1.5
예제 #6
0
    def draw(self, screen):
        screen.blit(self.background, (0, 0))
        screen.blit(self.gameovertxt, self.gameovertxtRect)

        if self.userFillingTextField :
            screen.blit(self.teaserText, self.teaserTextrect)
            screen.blit(self.usernickText, self.usernickTextRect)
        
        y = 70
        for userPts, username in self.orderedTabScore:
                y+=20
                tabScoreName = data.render_text(data.FONT_TITLE, 17, str(userPts)+"-"+username, (255, 255, 255))
                rect = tabScoreName.get_rect()
                rect.center = (320, y)
                screen.blit(tabScoreName,rect)
예제 #7
0
    def update(self):
        if self.userFillingTextField :
            llen = len(self.userFilledStr)
    
            if self.showUnderscore and (llen==0 or self.userFilledStr[llen-1] !=  '_'):
                self.userFilledStr.append('_')
            elif llen>0  and self.showUnderscore == False:
                if self.userFilledStr[llen-1] == '_':
                    self.userFilledStr.pop()
                        
        self.gameovertxtRect.center = (320, 20)
        self.usernickText = data.render_text(data.FONT_TITLE, 17, "".join(self.userFilledStr), (255, 255, 255))
        self.usernickTextRect = self.usernickText.get_rect()
        self.teaserTextrect.center = (320, 50)
        self.usernickTextRect.center = (320, 70)

        if pygame.time.get_ticks() > self.blinkInputCounter :
            self.blinkInputCounter = pygame.time.get_ticks()+self.blinkInputTime
            self.showUnderscore = not self.showUnderscore 
예제 #8
0
    def __init__(self, game, name, index, config=None):
        super(CreditsScene, self).__init__(game, name, index, config)

        self.text = data.render_text(data.FONT_TITLE, 37, 'Thanks for Playing',
                                     (255, 255, 255))
        self.textrect = self.text.get_rect()

        font = data.load_font(data.FONT_MAIN, 17)
        names = ('cyqui', 'gleuh', 'greg0ire', 'joksnet')

        self.designLabel = data.render_text(data.FONT_TITLE, 23, 'Design:',
                                            (255, 255, 127))
        self.designLabelRect = self.designLabel.get_rect()
        self.design = data.render_text(data.FONT_MAIN, 21, 'tocab',
                                       (255, 255, 255))
        self.designRect = self.design.get_rect()

        self.musicLabel = data.render_text(data.FONT_TITLE, 23, 'Music:',
                                           (255, 255, 127))
        self.musicLabelRect = self.musicLabel.get_rect()
        self.music = data.render_text(data.FONT_MAIN, 21, 'TOTOleHero',
                                      (255, 255, 255))
        self.musicRect = self.music.get_rect()

        self.namesLabel = data.render_text(data.FONT_TITLE, 23, 'Developers',
                                           (255, 255, 127))
        self.namesLabelRect = self.namesLabel.get_rect()

        self.names = []

        for name in names:
            rend = font.render(name, True, (255, 255, 255))
            rect = rend.get_rect()

            self.names.append((rend, rect))

        self.team = data.render_text(data.FONT_TITLE, 37, 'The Bouba Team',
                                     (60, 255, 60))
        self.teamRect = self.team.get_rect()

        self.background = data.load_image('credits.png')
        self.music_bg = data.load_sound('credits.ogg')
예제 #9
0
    def update(self):
        self.sequence.update()
        self.buttons.update()
        self.pointsText = self.font.render('%d' % (self.game.points, ), False,
                                           (255, 255, 255))

        if self.stepCountElapsingTime and not self.oneButtonALaFois():
            if pygame.time.get_ticks() > self.stepElapsedTimeCounter:
                self.currentCounterStep -= 1
                self.stepElapsedTimeCounter = pygame.time.get_ticks(
                ) + self.stepElapsingInTime
            if self.currentCounterStep < 0:
                self.game.director.change('gameover')

        if not self.playing and not self.sequencing:
            if pygame.time.get_ticks() > self.animBossTime:
                self.animBossTime += 150

                if self.animBossAction == 'scale':
                    self.animBossActionCount += 1

                    self.animBossImage = pygame.transform.scale(
                        self.animBossImage,
                        (self.animBossRect.w - 9, self.animBossRect.h - 9))

                    bottom = self.animBossRect.bottom
                    left = self.animBossRect.left

                    self.animBossRect = self.animBossImage.get_rect()
                    self.animBossRect.bottom = bottom - 2
                    self.animBossRect.left = left - 4

                    if self.animBossActionCount == 15:
                        self.animBossActionCount = 0
                        self.animBossAction = 'moveup'
                        self.animBossShowRaw = True

                    self.bottomTextRect.center = (320, 360)

                elif self.animBossAction == 'moveup':

                    self.animBossRect = self.animMiniBossImage.get_rect()
                    self.bottomText = data.render_text(
                        data.FONT_MAIN, 30,
                        str(4 - (self.animBossActionCount / 4)), (255, 0, 0))
                    self.bottomTextRect = self.bottomText.get_rect()
                    self.bottomTextRect.center = (320, 360)

                    self.animBossActionCount += 1

                    if self.animBossActionCount <= 10:
                        self.animMiniBossRect.top -= 5
                    elif self.animBossActionCount > 10 and self.animBossActionCount < 20:
                        rect = pygame.Rect(
                            0,
                            5,
                            self.animMiniBossRect.w,
                            self.animMiniBossRect.h - 5,
                        )
                        self.animMiniBossImage = self.animMiniBossImage.subsurface(
                            rect)
                        self.animMiniBossRect.h -= 5
                    elif self.animBossActionCount == 20:
                        self.animBossActionCount = 0
                        self.animBossAction = None
                        self.animBossShowRaw = False
                        self.background = data.load_image(
                            'background.png', self.name)
                else:
                    self.seqStart()
예제 #10
0
    def __init__(self, game, name, index, config=None):
        super(LevelScene, self).__init__(game, name, index, config)

        self.font = data.load_font(data.FONT_FIX, 23)

        self.count = config['count'] if 'count' in config else 9
        self.delta = config['delta'] if 'delta' in config else 1000

        self.points = config['points'] if 'points' in config else 500
        self.volume = config['volume'] if 'volume' in config else 0.3
        self.pointsMulti = config[
            'pointsMulti'] if 'pointsMulti' in config else 1
        self.pointsText = None

        self.sequence = button.SequenceButtonGroup((20, 20), (210, 100), 15, 5,
                                                   self.count, self.delta)
        self.buttons = button.PlayableButtonGroup((50, 150), (35, 300), 20, 15,
                                                  self.count, 750)

        self.seqindex = 0
        self.sequencing = False

        self.play = []
        self.playing = False

        self.background = data.load_image('background.png')
        self.ray = data.load_image('ray.png')
        self.piano = data.load_image('piano.png')

        self.music_bg = data.load_sound('background.ogg', self.name)
        self.music_bg.set_volume(self.volume)
        self.music_pre_bg = data.load_sound('pre-background.ogg', self.name)
        self.music_pre_bg.set_volume(0.3)

        self.sequence.associateTheme(self.name)
        self.buttons.associateTheme(self.name)

        self.pre_bg_channel = None
        self.bg_channel = None

        # step counter management
        self.stepElapsingInTime = 1
        self.stepElapsedTimeCounter = 0
        self.counterStepPerClick = config[
            'timetoclick'] if 'timetoclick' in config else 200
        self.currentCounterStep = self.counterStepPerClick

        # counting only when button animation is over
        self.stepCountElapsingTime = False
        self.stepCounterText = None
        self.rectWidth = 0

        boss = data.load_image('boss.png', self.name)
        boss.set_colorkey((255, 0, 255))

        miniboss = data.load_image('boss_mini.png', self.name)
        miniboss.set_colorkey((255, 0, 255))

        self.animMiniBossImage = miniboss  # pygame.transform.scale(boss, (170, 170))
        self.animMiniBossRect = self.animMiniBossImage.get_rect()
        self.animMiniBossRect.left = 302
        self.animMiniBossRect.bottom = 243

        self.animBossAction = 'scale'
        self.animBossActionCount = 0
        self.animBossImage = boss  # pygame.transform.scale(boss, (170, 170))
        self.animBossRect = self.animBossImage.get_rect()
        self.animBossRect.left = 350
        self.animBossRect.bottom = 280
        self.animBossTime = 0
        self.animBossShowRaw = False

        self.counterRect = [266, 250, 110, 8]
        self.counterRectDecSizePerStep = 110.0 / self.counterStepPerClick

        self.incrRedColorUnit = 255.0 / self.counterStepPerClick
        self.decrBlueColorUnit = 255.0 / self.counterStepPerClick

        self.bottomPanel = pygame.Surface((640, 240))
        self.bottomPanel.fill((100, 100, 100))
        self.bottomPanel.set_alpha(200)

        self.bottomText = data.render_text(
            data.FONT_MAIN, 30,
            self.name.replace('-', ' ') + " starting in...", (255, 0, 0))
        self.bottomTextRect = self.bottomText.get_rect()
        self.bottomTextRect.center = (320, 360)
예제 #11
0
    def update(self):
        self.sequence.update()
        self.buttons.update()
        self.pointsText = self.font.render('%d' % (self.game.points, ), False, (255, 255, 255))

        if self.stepCountElapsingTime and not self.oneButtonALaFois():
            if pygame.time.get_ticks() > self.stepElapsedTimeCounter:
                self.currentCounterStep -= 1
                self.stepElapsedTimeCounter = pygame.time.get_ticks() + self.stepElapsingInTime
            if self.currentCounterStep < 0:
                self.game.director.change('gameover')

        if not self.playing and not self.sequencing:
            if pygame.time.get_ticks() > self.animBossTime:
                self.animBossTime += 150

                if self.animBossAction == 'scale':
                    self.animBossActionCount += 1

                    self.animBossImage = pygame.transform.scale(self.animBossImage,
                        (self.animBossRect.w - 9, self.animBossRect.h - 9))

                    bottom = self.animBossRect.bottom
                    left = self.animBossRect.left

                    self.animBossRect = self.animBossImage.get_rect()
                    self.animBossRect.bottom = bottom - 2
                    self.animBossRect.left = left - 4

                    if self.animBossActionCount == 15:
                        self.animBossActionCount = 0
                        self.animBossAction = 'moveup'
                        self.animBossShowRaw = True

                    self.bottomTextRect.center = (320, 360)

                elif self.animBossAction == 'moveup':
                    
                    self.animBossRect = self.animMiniBossImage.get_rect()
                    self.bottomText = data.render_text(data.FONT_MAIN, 30, str(4 - (self.animBossActionCount / 4)), (255, 0, 0))
                    self.bottomTextRect = self.bottomText.get_rect()
                    self.bottomTextRect.center = (320, 360)

                    self.animBossActionCount += 1

                    if self.animBossActionCount <= 10:
                        self.animMiniBossRect.top -= 5
                    elif self.animBossActionCount > 10 and self.animBossActionCount < 20:
                        rect = pygame.Rect(0, 5,
                                           self.animMiniBossRect.w,
                                           self.animMiniBossRect.h - 5,
                                           )
                        self.animMiniBossImage = self.animMiniBossImage.subsurface(rect)
                        self.animMiniBossRect.h -= 5
                    elif self.animBossActionCount == 20:
                        self.animBossActionCount = 0
                        self.animBossAction = None
                        self.animBossShowRaw = False
                        self.background = data.load_image('background.png', self.name)
                else:
                    self.seqStart()
예제 #12
0
    def __init__(self, game, name, index, config=None):
        super(LevelScene, self).__init__(game, name, index, config)

        self.font = data.load_font(data.FONT_FIX, 23)

        self.count = config['count'] if 'count' in config else 9
        self.delta = config['delta'] if 'delta' in config else 1000

        self.points = config['points'] if 'points' in config else 500
        self.volume = config['volume'] if 'volume' in config else 0.3
        self.pointsMulti = config['pointsMulti'] if 'pointsMulti' in config else 1
        self.pointsText = None

        self.sequence = button.SequenceButtonGroup((20, 20), (210, 100), 15, 5, self.count, self.delta)
        self.buttons = button.PlayableButtonGroup((50, 150), (35, 300), 20, 15, self.count, 750)

        self.seqindex = 0
        self.sequencing = False

        self.play = []
        self.playing = False

        self.background = data.load_image('background.png')
        self.ray = data.load_image('ray.png')
        self.piano = data.load_image('piano.png')

        self.music_bg = data.load_sound('background.ogg', self.name)
        self.music_bg.set_volume(self.volume)
        self.music_pre_bg = data.load_sound('pre-background.ogg', self.name)
        self.music_pre_bg.set_volume(0.3)

        self.sequence.associateTheme(self.name) 
        self.buttons.associateTheme(self.name)

        self.pre_bg_channel = None
        self.bg_channel = None

        # step counter management
        self.stepElapsingInTime = 1
        self.stepElapsedTimeCounter = 0
        self.counterStepPerClick = config['timetoclick'] if 'timetoclick' in config else 200
        self.currentCounterStep = self.counterStepPerClick

        # counting only when button animation is over
        self.stepCountElapsingTime = False
        self.stepCounterText = None
        self.rectWidth = 0

        boss = data.load_image('boss.png', self.name)
        boss.set_colorkey((255, 0, 255))
        
        miniboss = data.load_image('boss_mini.png', self.name)
        miniboss.set_colorkey((255, 0, 255))    
            
        self.animMiniBossImage = miniboss # pygame.transform.scale(boss, (170, 170))
        self.animMiniBossRect = self.animMiniBossImage.get_rect()
        self.animMiniBossRect.left = 302
        self.animMiniBossRect.bottom = 243
        
        self.animBossAction = 'scale'
        self.animBossActionCount = 0
        self.animBossImage = boss # pygame.transform.scale(boss, (170, 170))
        self.animBossRect = self.animBossImage.get_rect()
        self.animBossRect.left = 350
        self.animBossRect.bottom = 280
        self.animBossTime = 0
        self.animBossShowRaw = False

        self.counterRect = [266,250,110,8]
        self.counterRectDecSizePerStep = 110.0/self.counterStepPerClick

        self.incrRedColorUnit = 255.0/self.counterStepPerClick
        self.decrBlueColorUnit = 255.0/self.counterStepPerClick

        self.bottomPanel = pygame.Surface((640,240))
        self.bottomPanel.fill((100, 100, 100))
        self.bottomPanel.set_alpha(200)

        self.bottomText     = data.render_text(data.FONT_MAIN, 30, self.name.replace('-', ' ') + " starting in...", (255, 0, 0))
        self.bottomTextRect = self.bottomText.get_rect()
        self.bottomTextRect.center = (320, 360)