Пример #1
0
    def __init__(self,screensize,gametype,title_prefix):
        self.name = "highscore"
        self.hasclicked = False
        self.width = screensize[0]
        self.background = pygame.Surface(screensize).convert()
        self.background.fill(HIGHSCORE['bgcolor'])
        self.changed = True
        highscores = get_highscores(HIGHSCORE['show-n-scores'],gametype=gametype)

        title = Textbox(
            name="highscore_title",
            size=HIGHSCORE['title-size'],
            location=(0,0),
            text_color=HIGHSCORE['title-text-color'],
            surface_color=HIGHSCORE['title-bgcolor'],
            text_size=HIGHSCORE['title-text-size'],
            bold=HIGHSCORE['title-bold'])
        title.update(title_prefix + HIGHSCORE['title-text'])

        score_boxes = []
        placement = 0

        for i in highscores:
            placement += 1
            highscore = Textbox(
                name="highscore_title",
                size=HIGHSCORE['score-size'],
                location=(0,0),
                text_color=HIGHSCORE['score-text-color'],
                surface_color=HIGHSCORE['score-bgcolor'],
                text_size=HIGHSCORE['score-text-size'],
                bold=HIGHSCORE['score-bold'],
                font=HIGHSCORE['score-font'])
            highscore.update(
                '{0:<2}'.format(str(placement))+HIGHSCORE['score-separator']+
                '{0:>15}'.format(str(i))
                )

            self.background.blit(highscore.surface,
                                 highscore.surface.get_rect(
                    centery=75+40*placement,
                    centerx=self.width/2
                    ))
            
        self.background.blit(title.surface,
                             title.surface.get_rect(
                centery=50,
                centerx=self.width/2
                ))
Пример #2
0
    def __init__(self, screensize, gametype, title_prefix):
        self.name = "highscore"
        self.hasclicked = False
        self.width = screensize[0]
        self.background = pygame.Surface(screensize).convert()
        self.background.fill(HIGHSCORE['bgcolor'])
        self.changed = True
        highscores = get_highscores(HIGHSCORE['show-n-scores'],
                                    gametype=gametype)

        title = Textbox(name="highscore_title",
                        size=HIGHSCORE['title-size'],
                        location=(0, 0),
                        text_color=HIGHSCORE['title-text-color'],
                        surface_color=HIGHSCORE['title-bgcolor'],
                        text_size=HIGHSCORE['title-text-size'],
                        bold=HIGHSCORE['title-bold'])
        title.update(title_prefix + HIGHSCORE['title-text'])

        score_boxes = []
        placement = 0

        for i in highscores:
            placement += 1
            highscore = Textbox(name="highscore_title",
                                size=HIGHSCORE['score-size'],
                                location=(0, 0),
                                text_color=HIGHSCORE['score-text-color'],
                                surface_color=HIGHSCORE['score-bgcolor'],
                                text_size=HIGHSCORE['score-text-size'],
                                bold=HIGHSCORE['score-bold'],
                                font=HIGHSCORE['score-font'])
            highscore.update('{0:<2}'.format(str(placement)) +
                             HIGHSCORE['score-separator'] +
                             '{0:>15}'.format(str(i)))

            self.background.blit(
                highscore.surface,
                highscore.surface.get_rect(centery=75 + 40 * placement,
                                           centerx=self.width / 2))

        self.background.blit(
            title.surface,
            title.surface.get_rect(centery=50, centerx=self.width / 2))
Пример #3
0
    def done(self):
        if self.board.game_over():
            timebonus = ((self.timeleft)*(self.level*self.level)*self.base_score)/20/1000

            next_round_time= self.timeleft/1000+TIMESAVEMODE['level-time']+.99
            next_round = ("timesavemode",self.level+1,self.score+timebonus,next_round_time)

            close_call = {True: "   (good luck..)", False: ""}[self.timeleft < 2000]
            messages = [
                (25,TIMESAVEMODE['message-color'],"Level score: " + str(int(self.score-self.prev_score))),
                (25,TIMESAVEMODE['message-color'],"Time saved for next round: " + "{0:.1f}".format(self.timeleft/1000) + " seconds"+close_call),
                (25,TIMESAVEMODE['message-color'],"Timebonus: " + str(int(timebonus))),
                (45,TIMESAVEMODE['message-important-color'],"Total time next round: " + "{0:.1f}".format(next_round_time)),
                (45,TIMESAVEMODE['message-important-color'],"Total score: " + str(int(self.score+timebonus))),
                (20,TIMESAVEMODE['message-color'],"Click to continue to level {0}...".format(self.level+1))]

            return ("clicktocontinue",next_round,messages)
        elif self.timeleft < 100:
            hs = get_highscores(10,"timesave-game")
            if not hs:
                max_hs = 0
                min_hs = 0
            else:
                max_hs = max(hs)
                min_hs = min(hs)

            if self.score > max_hs:
                highscore_message = (30,TIMESAVEMODE['message-important-color'],"Congratulations! You broke the #1 highscore!")
            elif self.score > min_hs or len(hs) < 10:
                highscore_message = (30,TIMESAVEMODE['message-color'],"Your score is in the top 10 highscores!")
            else:
                highscore_message = (30,TIMESAVEMODE['message-color'],"You didn't get on the top 10 highscores.")

            nice_print(["Writing score to file..."])
            submit_score(int(self.score),"timesave-game")
            next_round = ("timesavemode",1,0,TIMESAVEMODE['level-time']+.99)
            messages = [(30,TIMESAVEMODE['message-color'],"Game over!"),
                        (40,TIMESAVEMODE['message-important-color'],"Final score: " + str(int(self.score))),
                        highscore_message,
                        (20,TIMESAVEMODE['message-color'],"Click to start new game...")]

            return ("clicktocontinue_scoremode_loss",next_round,messages)
        else:
            return False
Пример #4
0
    def done(self):
        if self.board.game_over():
            timebonus = ((self.timeleft)*(self.level*self.level)*self.base_score)/20/1000
            next_round = ("scoremode",self.level+1,self.score+timebonus)

            close_call = {True: " ...Close call!", False: ""}[self.timeleft < 2000]

            messages = [
                (30,SCOREMODE['message-color'],"Level score: " + str(int(self.score-self.prev_score))),
                (30,SCOREMODE['message-color'],"Time left: " + "{0:.1f}".format(self.timeleft/1000) + " seconds"+close_call),
                (30,SCOREMODE['message-color'],"Timebonus: " + str(int(timebonus))),
                (45,SCOREMODE['message-important-color'],"Total score: " + str(int(self.score+timebonus))),
                (20,SCOREMODE['message-color'],"Click to continue to level {0}...".format(self.level+1))]

            return ("clicktocontinue",next_round,messages)
        elif self.timeleft < 100:
            nice_print(["Writing score to file..."])

            hs = get_highscores(10)
            if not hs:
                max_hs = 0
                min_hs = 0
            else:
                max_hs = max(hs)
                min_hs = min(hs)

            if self.score > max_hs:
                highscore_message = (30,SCOREMODE['message-important-color'],"Congratulations! You broke the #1 highscore!")
            elif self.score > min_hs or len(hs) < 10:
                highscore_message = (30,SCOREMODE['message-color'],"Your score is in the top 10 highscores!")
            else:
                highscore_message = (30,SCOREMODE['message-color'],"You didn't get on the top 10 highscores.")

            submit_score(int(self.score))
            next_round = ("scoremode",1,0)
            messages = [(30,SCOREMODE['message-color'],"Game over!"),
                        (40,SCOREMODE['message-important-color'],"Final score: " + str(int(self.score))),
                        highscore_message,
                        (20,SCOREMODE['message-color'],"Click to start new game...")
                        ]
            return ("clicktocontinue_scoremode_loss",next_round,messages)
        else:
            return False