Example #1
0
 def draw(self, window):
     self.feed_surf.fill("BLACK")
     self.feed_surf.set_colorkey("BLACK")
     for i in range(len(self.feed)):
         draw_text2(self.feed_surf, f"+{int(self.feed[i])} pts", GAME_FONT,
                    FONT_SIZE, (4, FONT_SIZE * (i)), "WHITE")
     window.blit(self.feed_surf, (8, 32))
Example #2
0
    def draw(self, surface):
        self.image.fill(self.surface_color)
        self.image.set_colorkey("BLACK")

        # Draw outline / change colors of image and text
        if self.active and not self.selected:
            pygame.draw.rect(self.image, "WHITE",
                             ((0, 0), self.image.get_size()), 4)
        elif self.active and self.selected:
            self.text_color = "BLACK"
            self.surface_color = "WHITE"

        # Draw text
        if self.key_ == None:
            self.text = "UNDEFINED"
            self.text_color = "RED"
        else:
            self.text = pygame.key.name(self.key_).upper()
        draw_text2(self.image,
                   self.text,
                   GAME_FONT,
                   self.font_size,
                   (self.image.get_width() / 2,
                    self.image.get_height() / 2 - self.font_size / 2),
                   self.text_color,
                   align="center")
        surface.blit(self.image, self.position)
Example #3
0
    def draw(self, surface):
        self.image.fill(self.surface_color)
        self.image.set_colorkey("BLACK")

        # Draw text
        draw_text2(self.image,
                   self.text,
                   GAME_FONT,
                   FONT_SIZE, (self.image.get_width() / 2,
                               self.image.get_height() / 2 - FONT_SIZE / 2),
                   self.text_color,
                   align="center")
        surface.blit(self.image, self.position)
Example #4
0
    def draw(self, window):
        self.image.fill("BLACK")
        self.image.set_colorkey("BLACK")

        # Draw Labels
        draw_text2(self.image, "FULLSCREEN", GAME_FONT, FONT_SIZE,
                   (32, self.ts_fullscreen_y + FONT_SIZE / 2), "WHITE")
        draw_text2(self.image, "FRAMELESS", GAME_FONT, FONT_SIZE,
                   (32, self.ts_frameless_y + FONT_SIZE / 2), "WHITE")

        # Draw text selectors
        for option in self.options:
            option.draw(self.image)

        # Draw disclaimer
        if self.settings_changed:
            draw_text2(self.image,
                       "Please restart the game",
                       GAME_FONT,
                       FONT_SIZE, (32, self.image.get_height() * 0.4),
                       "WHITE",
                       align="center")
            draw_text2(self.image,
                       "to apply changes.",
                       GAME_FONT,
                       FONT_SIZE, (32, self.image.get_height() * 0.45),
                       "WHITE",
                       align="center")

        # Draw the widget to the screen
        window.blit(self.image, (0, window.get_height() * 0.3))
Example #5
0
    def draw(self, window):
        self.image.fill("BLACK")
        self.image.set_colorkey("BLACK")

        # Draw Labels
        draw_text2(self.image, "HP BAR STYLE", GAME_FONT, FONT_SIZE, (32, self.ts_hp_y + FONT_SIZE/2), "WHITE")
        draw_text2(self.image, "CAN PAUSE", GAME_FONT, FONT_SIZE, (32, self.ts_canpause_y + FONT_SIZE/2), "WHITE")

        # Draw text selectors
        for option in self.options:
            option.draw(self.image)

        # Draw the widget to the screen
        window.blit(self.image, (0,window.get_height()*0.3))
Example #6
0
    def draw(self, window):
        self.image.fill("BLACK")
        self.image.set_colorkey("BLACK")

        # Draw Labels
        draw_text2(self.image, "SFX", GAME_FONT, FONT_SIZE, (32, self.rs_sfx_y + FONT_SIZE/2), "WHITE")
        draw_text2(self.image, "MUSIC", GAME_FONT, FONT_SIZE, (32, self.rs_ost_y + FONT_SIZE/2), "WHITE")

        # Draw text selectors
        for option in self.options:
            option.draw(self.image)

        # Draw the widget to the screen
        window.blit(self.image, (0,window.get_height()*0.3))
Example #7
0
    def draw(self, window):
        self.table_surf.fill("black")
        self.table_surf.set_colorkey("black")

        if len(self.scores) != 0:
            for i in range(len(self.scores[self.cur_tbl])):
                name = self.scores[self.cur_tbl][i][0].upper()
                score = self.scores[self.cur_tbl][i][1]
                difficulty = DIFFICULTIES[self.scores[self.cur_tbl][i][2]]

                # If difficulty is HARD, then set color to yellow
                difficulty_color = "WHITE"
                if difficulty == DIFFICULTIES[2]:
                    difficulty_color = "YELLOW"

                # Draw text
                draw_text(self.table_surf, f"{(i+1)+(self.cur_tbl*self.splice_n)}.", FONT_SIZE, GAME_FONT, self.table_rect.centerx * 0.35 + len(str(i)), FONT_SIZE*(i+1) + self.spacing*(i+1), "YELLOW")
                draw_text(self.table_surf, f"{name}", FONT_SIZE, GAME_FONT, self.table_rect.centerx * 0.6, FONT_SIZE*(i+1) + self.spacing*(i+1), "WHITE")
                draw_text(self.table_surf, f"{score}", FONT_SIZE, GAME_FONT, self.table_rect.centerx * 1.0, FONT_SIZE*(i+1) + self.spacing*(i+1), "WHITE")
                draw_text2(self.table_surf, f"{difficulty}", GAME_FONT, FONT_SIZE, (self.table_rect.centerx * 1.4, FONT_SIZE*(i+1) + self.spacing*(i+1)), difficulty_color)
                draw_text(window, f"PAGE {self.cur_tbl+1} OF {len(self.scores)}", FONT_SIZE, GAME_FONT, self.table_rect.centerx, self.table_rect.bottom * 1.25, "WHITE", "centered")
        else:
            draw_text2(self.table_surf, "No scores yet...", GAME_FONT, FONT_SIZE, (self.table_rect.centerx, 64), "WHITE", align="center")
            draw_text2(self.table_surf, "Go play the game!", GAME_FONT, FONT_SIZE, (self.table_rect.centerx, 96), "WHITE", align="center")

        window.blit(self.table_surf,(0,WIN_RES["h"]/2 - 128))
Example #8
0
    def draw(self, window):
        self.back_button.fill("BLACK")
        self.back_button.set_colorkey("BLACK")
        self.surface.fill("black")
        self.surface.set_colorkey("black")

        # Change selector size and draw
        if self.options[self.sel_i] != "BACK":
            self.selector = pygame.Surface((WIN_RES["w"], FONT_SIZE + 4))
            self.selector.fill("white")
            self.surface.blit(self.selector, (0,self.sel_y-3))
        else:
            self.selector = pygame.Surface((128,32))
            self.selector.fill("white")
            self.back_button.blit(
                self.selector, 
                (0,0)
            )

        # Draw menu
        for i in range(len(self.options)):
            if self.options[i] != "BACK":
                draw_text(self.surface, self.options[i], FONT_SIZE, GAME_FONT, self.surf_rect.centerx, FONT_SIZE*(i+1) + self.spacing*(i+1), self.colors[self.act_opt[i]], "centered")
            else:
                draw_text2(
                    self.back_button, 
                    "BACK", 
                    GAME_FONT, 
                    FONT_SIZE, 
                    (self.back_button.get_width()/2, self.back_button.get_height()/2 - FONT_SIZE/2), 
                    self.colors[self.act_opt[i]], 
                    align="center"
                )
                window.blit(
                    self.back_button, 
                    (window.get_width()/2 - self.back_button.get_width()/2, window.get_height()*0.8)
                )

        # Draw the menu widget surface
        window.blit(self.surface, (0,window.get_height()*0.3))
Example #9
0
    def draw(self, surface):
        # Automatically resize surface depending on text size
        text_length = len(str(int(self.value)))
        surf_length = (text_length+2) * FONT_SIZE
        self.ts_surf = pygame.Surface((surf_length, 32))

        self.ts_surf.fill("BLACK")
        self.ts_surf.set_colorkey("BLACK")

        if self.active:
            # Draw the arrows.
            if self.value > 0:
                draw_text2(
                    self.ts_surf, 
                    "<", 
                    GAME_FONT, 
                    FONT_SIZE, 
                    (
                        FONT_SIZE/2 - (2*self.jut_m),
                        self.ts_surf.get_height()/2 - FONT_SIZE/2
                    ),
                    "WHITE"
                )

            if self.value < self.max_:
                draw_text2(
                    self.ts_surf, 
                    ">", 
                    GAME_FONT, 
                    FONT_SIZE, 
                    (
                        self.ts_surf.get_width() - FONT_SIZE + (2*self.jut_m),
                        self.ts_surf.get_height()/2 - FONT_SIZE/2
                    ),
                    "WHITE"
                )

        # Draw text
        draw_text2(
            self.ts_surf, 
            str(int(self.value)), 
            GAME_FONT, 
            FONT_SIZE, 
            (0,self.ts_surf.get_height()/2 - FONT_SIZE/2),
            "WHITE",
            align="center"
        )
        
        # Draw selector to surface
        if self.alignment == "CENTER":
            surface.blit(
                self.ts_surf, 
                (surface.get_width()/2 - self.ts_surf.get_width()/2 + self.position[0], self.position[1])
            )
Example #10
0
    def draw(self, surface):
        # Automatically resize surface depending on text size
        text_length = len(self.options[self.index])
        surf_length = (text_length+2) * FONT_SIZE
        self.ts_surf = pygame.Surface((surf_length, 32))

        self.ts_surf.fill("BLACK")
        self.ts_surf.set_colorkey("BLACK")

        if self.active:
            # Draw the arrows. There has to be a better way to do this...
            # But it will work for now (narrator: it will work this way forever)
            draw_text2(
                self.ts_surf, 
                "<", 
                GAME_FONT, 
                FONT_SIZE, 
                (
                    FONT_SIZE/2 - (2*self.jut_m),
                    self.ts_surf.get_height()/2 - FONT_SIZE/2
                ),
                "WHITE"
            )
            draw_text2(
                self.ts_surf, 
                ">", 
                GAME_FONT, 
                FONT_SIZE, 
                (
                    self.ts_surf.get_width() - FONT_SIZE + (2*self.jut_m),
                    self.ts_surf.get_height()/2 - FONT_SIZE/2
                ),
                "WHITE"
            )

        # Draw text
        draw_text2(
            self.ts_surf, 
            self.options[self.index], 
            GAME_FONT, 
            FONT_SIZE, 
            (0,self.ts_surf.get_height()/2 - FONT_SIZE/2),
            "WHITE",
            align="center"
        )
        
        # Draw selector to surface
        if self.alignment == "CENTER":
            surface.blit(
                self.ts_surf, 
                (surface.get_width()/2 - self.ts_surf.get_width()/2 + self.position[0], self.position[1])
            )
Example #11
0
    def draw(self, window):
        self.image.fill("BLACK")
        self.image.set_colorkey("BLACK")

        # Draw labels
        draw_text2(self.image, "FORWARD", GAME_FONT, FONT_SIZE,
                   (32, 0 + FONT_SIZE / 2), "WHITE")
        draw_text2(self.image, "BACKWARD", GAME_FONT, FONT_SIZE,
                   (32, 32 + FONT_SIZE / 2), "WHITE")
        draw_text2(self.image, "LEFT", GAME_FONT, FONT_SIZE,
                   (32, 64 + FONT_SIZE / 2), "WHITE")
        draw_text2(self.image, "RIGHT", GAME_FONT, FONT_SIZE,
                   (32, 96 + FONT_SIZE / 2), "WHITE")
        draw_text2(self.image, "SHOOT/ENTER", GAME_FONT, FONT_SIZE,
                   (32, 128 + FONT_SIZE / 2), "WHITE")
        draw_text2(self.image, "EXIT/BACK", GAME_FONT, FONT_SIZE,
                   (32, 160 + FONT_SIZE / 2), "WHITE")

        # Draw textboxes
        for option in self.options:
            option.draw(self.image)

        # Draw disclaimer if there are duplicate keys
        self.has_undefined = False
        for option in self.options:
            if type(option) == Textbox:
                if option.key_ == None:
                    draw_text2(self.image,
                               "Has undefined keys.",
                               GAME_FONT,
                               FONT_SIZE,
                               (self.image.get_width() / 2 - FONT_SIZE / 2,
                                self.image.get_height() * 0.55),
                               "WHITE",
                               align="center")
                    draw_text2(self.image,
                               "Settings will not be saved.",
                               GAME_FONT,
                               FONT_SIZE,
                               (self.image.get_width() / 2 - FONT_SIZE / 2,
                                self.image.get_height() * 0.6),
                               "WHITE",
                               align="center")
                    self.has_undefined = True

        window.blit(self.image, (0, window.get_height() * 0.3))