Exemplo n.º 1
0
    def draw(self):
        self.screen.fill(Color.DARK_GRAY)

        text_line = GetFont(32).render("Debugging Options", 1,
                                       Color.MOSTLY_WHITE)
        text_line_rect = text_line.get_rect(centerx=game_constants.w / 2,
                                            top=20)

        options_texts = []
        for i, option_str in enumerate(self.options_order):
            color = Color.MOSTLY_WHITE
            if (i == self.selected_option):
                color = Color.YELLOW
            options_texts.append(
                GetFont(24).render(option_str.upper(), 1, color))

        draw_h = game_constants.h / 2
        for option in options_texts:
            rect = option.get_rect(centerx=game_constants.w / 2, top=draw_h)
            self.screen.blit(option, rect)
            draw_h += rect.height

        self.screen.blit(text_line, text_line_rect)

        pygame.display.update()
        self.dirty = False
Exemplo n.º 2
0
    def draw(self):
        self.screen.fill((0, 0, 0))
        message = GetFont(72).render("Loading...", 1, Color.MOSTLY_WHITE)
        self.screen.blit(
            message,
            message.get_rect(centerx=self.screen.get_width() / 2,
                             centery=self.screen.get_height() * .25))
        pygame.display.update()

        self.dirty = False
Exemplo n.º 3
0
    def draw(self):
        self.screen.fill((0, 0, 0))
        message = GetFont(72).render("Loading...", 1, Color.MOSTLY_WHITE)
        self.screen.blit(
            message,
            message.get_rect(
                centerx = self.screen.get_width() / 2,
                centery = self.screen.get_height() * .25))
        pygame.display.update()

        self.dirty = False
Exemplo n.º 4
0
    def __init__(self, x, y, w, h):
        super(Platform, self).__init__(x, y, w, h)

        self.word = None
        self.reachable = False
        self.selected = False
        self.font = GetFont(16)
Exemplo n.º 5
0
    def draw(self):
        self.screen.fill(Color.DARK_GRAY)

        text_line = GetFont(32).render("INTENSE OPTIONS SCREEN", 1, Color.MOSTLY_WHITE)
        text_line_rect = text_line.get_rect(centerx = game_constants.w / 2, top = 20)

        self.screen.blit(text_line, text_line_rect)

        [group.draw() for group in self.option_groups]

        text_line = GetFont(16).render("(Space to select, return to continue)", 1, Color.MOSTLY_WHITE)
        text_line_rect = text_line.get_rect(centerx = game_constants.w / 2, bottom = game_constants.h - 20)
        self.screen.blit(text_line, text_line_rect)

        pygame.display.update()
        self.dirty = False
Exemplo n.º 6
0
    def draw(self):
        self.screen.fill(Color.BLACK)
        message = GetFont(72).render("GAME OVER", 1, Color.MOSTLY_WHITE)
        instr = GetFont(32).render("Return to restart, Esc to quit.", 1, Color.MOSTLY_WHITE)
        self.screen.blit(
            message,
            message.get_rect(
                centerx = self.screen.get_width() / 2,
                centery = self.screen.get_height() * .25))
        self.screen.blit(
            instr,
            instr.get_rect(
                centerx = self.screen.get_width() / 2,
                centery = self.screen.get_height() * .75))
        pygame.display.update()

        self.dirty = False
Exemplo n.º 7
0
    def __init__(self, screen, sentence):
        self.screen = screen
        self.font = GetFont(40)
        self.challenge_message = self.font.render("TYPING CHALLENGE!", 0,
                                                  Color.MOSTLY_WHITE)
        self.rect = None
        self.screen.fill(Color.BLACK_YELLOW)
        self.frames = 0

        pygame.draw.rect(screen, (100, 30, 200),
                         (-10000, game_constants.h - 80, 20000, 10), 0)
        player = Player((0, 0))
        player.idleright.draw(
            screen, (game_constants.w / 8, game_constants.h - 80 - 38))
        from opponents import Commando
        commando = Commando("buttes", (0, 0))
        commando.idleleft.draw(screen, (game_constants.w *
                                        (7 / 8.0), game_constants.h - 80 - 35))

        sentence.draw(screen, (game_constants.w / 2, game_constants.h / 2))
Exemplo n.º 8
0
    def draw(self):
        self.screen.fill(Color.DARK_GRAY)
        title = GetFont(50).render("TYPER COMBAT", 1, Color.MOSTLY_WHITE)
        title_rect = title.get_rect(centerx = game_constants.w / 2, top = 0)
        self.screen.blit(title, title_rect)

        options_texts = []
        for i, option_str in enumerate(self.options_order):
            color = Color.MOSTLY_WHITE
            if (i == self.selected_option):
                color = Color.YELLOW
            options_texts.append(GetFont(24).render(option_str.upper(), 1, color))

        draw_h = game_constants.h / 2
        for option in options_texts:
            rect = option.get_rect(centerx = game_constants.w / 2, top = draw_h)
            self.screen.blit(option, rect)
            draw_h += rect.height

        pygame.display.update()
        self.dirty = False
Exemplo n.º 9
0
    def draw(self):
        self.screen.fill(Color.DARK_GRAY)

        enemies = [
            (self.soldier, "SOLDIERS are constrained by the laws of gravity."),
            (self.chopper, "COPTERS can fly, but won't go through platforms."),
            (self.ghost, "GHOSTS can float anywhere they like."),
        ]

        instructions_text = """Type the words that appear over enemies to defeat them.
Type the character that appears on a platform to jump to it.
Press CTRL to deselect a word.
Press space to turn around.
Press return to continue."""

        last_y = game_constants.h
        for text in reversed(instructions_text.split("\n")):
            rendered_text = GetFont(16).render(text, 1, Color.MOSTLY_WHITE)

            cur_y = last_y - rendered_text.get_height()
            self.screen.blit(
                rendered_text,
                rendered_text.get_rect(centerx=game_constants.w / 2,
                                       centery=cur_y))
            last_y = cur_y

        for image, text in reversed(enemies):
            rendered_text = GetFont(16).render(text, 1, Color.MOSTLY_WHITE)

            cur_y = last_y - rendered_text.get_height() - 20
            rect = rendered_text.get_rect(centerx=game_constants.w / 2,
                                          centery=cur_y)
            self.screen.blit(rendered_text, rect)
            self.screen.blit(
                image,
                image.get_rect(centerx=rect.left - image.get_width() - 10,
                               centery=cur_y))
            last_y = cur_y

        gunstar_top = last_y / 2 - self.image.get_height() / 2
        self.screen.blit(
            self.image,
            self.image.get_rect(centerx=game_constants.w / 2, top=gunstar_top))

        pygame.display.update()
        self.dirty = False
Exemplo n.º 10
0
    def __init__(self, screen, sentence):
        self.screen = screen
        self.font = GetFont(40)
        self.challenge_message = self.font.render("TYPING CHALLENGE!", 0, Color.MOSTLY_WHITE)
        self.rect = None
        self.screen.fill(Color.BLACK_YELLOW)
        self.frames = 0

        pygame.draw.rect(screen, (100, 30, 200), (-10000, game_constants.h - 80, 20000, 10), 0)
        player = Player((0, 0))
        player.idleright.draw(screen, (game_constants.w / 8, game_constants.h - 80 - 38))
        from opponents import Commando
        commando = Commando("buttes", (0, 0))
        commando.idleleft.draw(screen, (game_constants.w * (7 / 8.0), game_constants.h - 80 - 35))

        sentence.draw(screen, (game_constants.w / 2, game_constants.h / 2))
Exemplo n.º 11
0
class ChallengeScene(BaseScene):
    def __init__(self, screen, sentence):
        self.screen = screen
        self.font = GetFont(40)
        self.challenge_message = self.font.render("TYPING CHALLENGE!", 0,
                                                  Color.MOSTLY_WHITE)
        self.rect = None
        self.screen.fill(Color.BLACK_YELLOW)
        self.frames = 0

        pygame.draw.rect(screen, (100, 30, 200),
                         (-10000, game_constants.h - 80, 20000, 10), 0)
        player = Player((0, 0))
        player.idleright.draw(
            screen, (game_constants.w / 8, game_constants.h - 80 - 38))
        from opponents import Commando
        commando = Commando("buttes", (0, 0))
        commando.idleleft.draw(screen, (game_constants.w *
                                        (7 / 8.0), game_constants.h - 80 - 35))

        sentence.draw(screen, (game_constants.w / 2, game_constants.h / 2))

    def draw(self):
        self.frames += 1

        if self.frames < 100:
            percent = self.frames / 100.0
            xpos = percent * game_constants.w / 2
        elif self.frames > 355:
            percent = (self.frames - 355) / 100.0
            xpos = game_constants.w / 2 + percent * game_constants.w / 2
        else:
            xpos = game_constants.w / 2

        message_rectangle = self.challenge_message.get_rect(
            centerx=xpos, centery=game_constants.h / 4)

        if 200 < self.frames < 455:  # Transparent fadeout of text
            self.challenge_message.set_alpha(255 - (self.frames - 200))

        if self.rect:
            self.screen.fill(Color.BLACK_YELLOW, self.rect)
        self.screen.blit(self.challenge_message, message_rectangle)

        self.rect = message_rectangle
Exemplo n.º 12
0
class Option:
    def __init__(self, screen, value, checked=False, active=False):
        self.screen = screen
        self.checked = checked
        self.active = active
        self.value = value

    def toggle(self):
        self.checked = not self.checked

    def is_checked(self):
        return self.checked

    def activate(self):
        self.active = True

    def deactivate(self):
        self.active = False

    def draw(self, (x, y)):
        text_line = GetFont(16).render(self.value, 1, Color.MOSTLY_WHITE)
        text_line_rect = text_line.get_rect(left=x + 30, top=y)
        self.screen.blit(text_line, text_line_rect)

        outer_rect = Rect(x, y, 25, 25)
        inner_rect = outer_rect.inflate(-8, -8)

        if self.checked:
            if self.active:
                # Selected with cursor: box with box in it
                pygame.draw.rect(self.screen, Color.LIGHT_GRAY, outer_rect, 0)
                pygame.draw.rect(self.screen, Color.GRAY, inner_rect, 0)
            else:
                # Selected without cursor: tiny box
                pygame.draw.rect(self.screen, Color.BLACK, outer_rect, 0)
                pygame.draw.rect(self.screen, Color.GRAY, inner_rect, 0)
        else:
            if self.active:
                # Unselected with cursor: empty box
                pygame.draw.rect(self.screen, Color.LIGHT_GRAY, outer_rect, 0)
                pygame.draw.rect(self.screen, Color.BLACK, inner_rect, 0)
            else:
                # Unselected without cursor: blank
                pygame.draw.rect(self.screen, Color.DARK_GRAY, outer_rect, 0)
Exemplo n.º 13
0
class ChallengeScene(BaseScene):
    def __init__(self, screen, sentence):
        self.screen = screen
        self.font = GetFont(40)
        self.challenge_message = self.font.render("TYPING CHALLENGE!", 0, Color.MOSTLY_WHITE)
        self.rect = None
        self.screen.fill(Color.BLACK_YELLOW)
        self.frames = 0

        pygame.draw.rect(screen, (100, 30, 200), (-10000, game_constants.h - 80, 20000, 10), 0)
        player = Player((0, 0))
        player.idleright.draw(screen, (game_constants.w / 8, game_constants.h - 80 - 38))
        from opponents import Commando
        commando = Commando("buttes", (0, 0))
        commando.idleleft.draw(screen, (game_constants.w * (7 / 8.0), game_constants.h - 80 - 35))

        sentence.draw(screen, (game_constants.w / 2, game_constants.h / 2))

    def draw(self):
        self.frames += 1

        if self.frames < 100:
            percent = self.frames / 100.0
            xpos = percent * game_constants.w / 2
        elif self.frames > 355:
            percent = (self.frames - 355) / 100.0
            xpos = game_constants.w / 2 + percent * game_constants.w / 2
        else:
            xpos = game_constants.w / 2

        message_rectangle = self.challenge_message.get_rect(
            centerx = xpos, centery = game_constants.h / 4)

        if 200 < self.frames < 455: # Transparent fadeout of text
            self.challenge_message.set_alpha(255 - (self.frames - 200))

        if self.rect:
            self.screen.fill(Color.BLACK_YELLOW, self.rect)
        self.screen.blit(self.challenge_message, message_rectangle)

        self.rect = message_rectangle
Exemplo n.º 14
0
    def draw(self):
        self.screen.fill(Color.BLACK)
        message = GetFont(72).render("GAME OVER", 1, Color.MOSTLY_WHITE)
        instr = GetFont(32).render("Return to restart, Esc to quit.", 1,
                                   Color.MOSTLY_WHITE)
        self.screen.blit(
            message,
            message.get_rect(centerx=self.screen.get_width() / 2,
                             centery=self.screen.get_height() * .25))
        self.screen.blit(
            instr,
            instr.get_rect(centerx=self.screen.get_width() / 2,
                           centery=self.screen.get_height() * .75))
        pygame.display.update()

        self.dirty = False
Exemplo n.º 15
0
    def draw(self):
        self.screen.fill(Color.DARK_GRAY)

        enemies = [
            (self.soldier, "SOLDIERS are constrained by the laws of gravity."),
            (self.chopper, "COPTERS can fly, but won't go through platforms."),
            (self.ghost,   "GHOSTS can float anywhere they like."),
        ]

        instructions_text = """Type the words that appear over enemies to defeat them.
Type the character that appears on a platform to jump to it.
Press CTRL to deselect a word.
Press space to turn around.
Press return to continue."""

        last_y = game_constants.h
        for text in reversed(instructions_text.split("\n")):
            rendered_text = GetFont(16).render(text, 1, Color.MOSTLY_WHITE)

            cur_y = last_y - rendered_text.get_height()
            self.screen.blit(
                rendered_text,
                rendered_text.get_rect(centerx = game_constants.w / 2, centery = cur_y))
            last_y = cur_y

        for image, text in reversed(enemies):
            rendered_text = GetFont(16).render(text, 1, Color.MOSTLY_WHITE)

            cur_y = last_y - rendered_text.get_height() - 20
            rect = rendered_text.get_rect(centerx = game_constants.w / 2, centery = cur_y)
            self.screen.blit(rendered_text, rect)
            self.screen.blit(
                image,
                image.get_rect(centerx = rect.left - image.get_width() - 10, centery = cur_y))
            last_y = cur_y

        gunstar_top = last_y / 2 - self.image.get_height() / 2
        self.screen.blit(
            self.image,
            self.image.get_rect(centerx = game_constants.w / 2, top = gunstar_top))

        pygame.display.update()
        self.dirty = False
Exemplo n.º 16
0
    def draw(self):
        self.screen.fill(Color.DARK_GRAY)

        text_line = GetFont(32).render("INTENSE OPTIONS SCREEN", 1,
                                       Color.MOSTLY_WHITE)
        text_line_rect = text_line.get_rect(centerx=game_constants.w / 2,
                                            top=20)

        self.screen.blit(text_line, text_line_rect)

        [group.draw() for group in self.option_groups]

        text_line = GetFont(16).render("(Space to select, return to continue)",
                                       1, Color.MOSTLY_WHITE)
        text_line_rect = text_line.get_rect(centerx=game_constants.w / 2,
                                            bottom=game_constants.h - 20)
        self.screen.blit(text_line, text_line_rect)

        pygame.display.update()
        self.dirty = False