Example #1
0
File: main.py Project: johnfn/ld21
  def show_dialog(screen):
    my_font = pygame.font.Font("freesansbold.ttf", 10)

    speaker, dialog = Dialog.all_dialog[Dialog.speaker][Dialog.position]

    my_rect = pygame.Rect((60, ABS_MAP_SIZE - 140, 300, 120))
    rendered_text = render_textrect(dialog, my_font, my_rect, (10, 10, 10), (210, 255, 255), True, 0)

    screen.blit(rendered_text, my_rect.topleft)
    return True
Example #2
0
File: main.py Project: johnfn/ld21
  def render(self, screen):
    my_width = 100

    my_font = pygame.font.Font("freesansbold.ttf", 10)

    my_rect = pygame.Rect((self.follow.x - my_width / 2, self.follow.y - len(self.text) - 30, my_width, 70))
    if my_rect.x < 0:
      my_rect.x = 0
    rendered_text = render_textrect(self.text, my_font, my_rect, (10, 10, 10), (255, 255, 255), False, 1)

    screen.blit(rendered_text, my_rect.topleft)
Example #3
0
File: main.py Project: johnfn/ld22
  def render(self, screen, is_long=False):
    self.vis_text = self.contents[:self.seen]
    my_width = 300
    my_font = pygame.font.Font("nokiafc22.ttf", 12)

    my_rect = pygame.Rect((self.follow.x - my_width / 2, self.follow.y - 30, my_width, 70))

    if my_rect.x < 0:
      my_rect.x = 0
    rendered_text = render_textrect(self.vis_text, my_font, my_rect, (10, 10, 10), (255, 255, 255), False, 1)

    screen.blit(rendered_text, my_rect.topleft)
Example #4
0
File: main.py Project: johnfn/ld22
    def render(self, screen, is_long=False):
        self.vis_text = self.contents[:self.seen]
        my_width = 300
        my_font = pygame.font.Font("nokiafc22.ttf", 12)

        my_rect = pygame.Rect(
            (self.follow.x - my_width / 2, self.follow.y - 30, my_width, 70))

        if my_rect.x < 0:
            my_rect.x = 0
        rendered_text = render_textrect(self.vis_text, my_font, my_rect,
                                        (10, 10, 10), (255, 255, 255), False,
                                        1)

        screen.blit(rendered_text, my_rect.topleft)
Example #5
0
File: main.py Project: johnfn/ld23
  def render(self, screen, dx, dy):
    if not self.visible: return

    my_width = 300
    my_font = pygame.font.Font("nokiafc22.ttf", 12)
    vis_text = self.contents[:self.shown_chars] + "\n(press z)"

    my_rect = pygame.Rect((self.follow.x + dx - my_width / 2, self.follow.y + dy - len(vis_text) - 30, my_width, 150))
    my_rect.x = 0
    my_rect.y = 50

    color = (255,0,0) if self.colored else (10,10,10)
    rendered_text = render_textrect(vis_text, my_font, my_rect, color, (255, 255, 255), False, 1)

    screen.blit(rendered_text, my_rect.topleft)
Example #6
0
File: main.py Project: johnfn/ld23
def youwin():
  while True:
    screen.fill((255, 255, 255))

    win_msg = """
    You successfully found the tiny planet you call home.

    YOU WIN!
    """

    pygame.font.init()
    my_font = pygame.font.Font("nokiafc22.ttf", 12)
    my_rect = pygame.Rect((0, 0, 300, 300))
    my_rect.x = 0
    my_rect.y = 50

    color = (10,10,10)
    rendered_text = render_textrect(win_msg, my_font, my_rect, color, (255, 255, 255), False, 1)

    screen.blit(rendered_text, my_rect.topleft)

    pygame.display.flip()
Example #7
0
File: main.py Project: johnfn/ld21
  def loop(self):
    # self.set_state(States.GameOver)

    while 1:
      for event in pygame.event.get():
        if event.type == pygame.QUIT: 
          pygame.display.quit()
          exit(0)
        if event.type == pygame.KEYUP:
          UpKeys.add_key(event.key)

      global background
      background.render(self.buff)
      self.map.render(self.buff)

      global GAME_SIZE
      if UpKeys.key_up(pygame.K_s):
        if GAME_SIZE == 2:
          GAME_SIZE = 1
        else: 
          GAME_SIZE = 2

      if self.state == States.Dialog:
        Updater.render_all(self.buff)
        self.char.render(self.buff)
        if not Dialog.update(self.buff):
          self.state = States.Normal
      elif self.state == States.Normal:
        # self.partgen.update()
        Updater.update_all()
        Updater.render_all(self.buff)
        self.char.render(self.buff)
        self.char.update(pygame.key.get_pressed(), self.map, self)
      elif self.state == States.Blurry:
        Updater.render_all(self.buff)
        self.char.render(self.buff)

        self.buff = blur_surf(self.buff, self.blurriness)
        self.blurriness += self.dblurry
        if self.blurriness >= 10:
          self.dblurry *= -1
        if self.blurriness <= 0:
          self.dblurry = 0
          self.set_state(States.Normal)
      elif self.state == States.Death:
        Updater.render_all(self.buff)
        self.char.render(self.buff)

        blackness = pygame.Surface((ABS_MAP_SIZE * 2, ABS_MAP_SIZE * 2))
        blackness.set_alpha(self.death)
        self.buff.blit(blackness, blackness.get_rect())

        self.death += self.ddeath
        if self.death >= 240:
          self.ddeath *= -1
        if self.death <= 0:
          self.ddeath = 0
          self.set_state(States.Normal)
      elif self.state == States.GameOver:

        my_font = pygame.font.Font("freesansbold.ttf", 10)
        elapsed = "%d minutes, %d seconds." % (int((self.finished_time - START_TIME)/60), int(self.finished_time - START_TIME) % 60)
        gameover = """
        Hooray! You win!

        Afterwards:

        Even though you beat their boss, killed all their personel, and stole their gold, MegaCorp has come to the conclusion that you must be dead, because they found thousands of your dead bodies littering their dungeons. 

        Not a bad way for things to end up.

        elapsed time: %s

        deaths: %d

        percentage complete (gold): %d%%""" % (elapsed, DEATH_COUNT, int(100 * self.char.gold / 7))

        my_rect = self.buff.get_rect()
        self.buff = render_textrect(gameover, my_font, my_rect, (10, 10, 10), (210, 255, 255), True, 0)

      blackness2 = pygame.Surface((ABS_MAP_SIZE * 2, ABS_MAP_SIZE * 2))
      blackness2.set_alpha(255)
      self.screen.blit(blackness2, blackness2.get_rect())


      self.screen.blit(pygame.transform.scale(self.buff, (ABS_MAP_SIZE * GAME_SIZE, ABS_MAP_SIZE * GAME_SIZE)), self.buff.get_rect())
      UpKeys.flush()
      time.sleep(.02)
      pygame.display.flip()