Example #1
0
def input(screen):
    pygame.draw.rect(screen, (0,0,0),
           ((screen.get_width() / 2) - 100,
            (screen.get_height() / 2) - 10,
            200,20), 0)
    screen.blit(FONT.render("Write your name", 1, (0, 0, 0)),
                ((screen.get_width() / 2) - 90, (screen.get_height() / 2) - 50))
    pygame.display.flip()
    done = False
    s = ""
    while done==False:
        event = pygame.event.wait()
        #pygame.event.clear()
        if event.type == pygame.QUIT:
            done=True
        if event.type == pygame.KEYDOWN:
            inkey = event.key
            if inkey == K_BACKSPACE:
                s = s[0:-1]
                draw_box(screen,s)
            elif inkey == pygame.K_RETURN or inkey == pygame.K_KP_ENTER:
                done=True
                draw_box(screen,s)
            elif inkey <= 127:
                s += chr(inkey)
                draw_box(screen,s)
        #screen.fill(settings.white)
    return s
Example #2
0
def draw_message(screen, message):
    screen.fill(white)
    font = pygame.font.SysFont('Arial', 30)
    text = FONT.render(message, 1, (0, 0, 0))
    textpos = text.get_rect(centerx=screen.get_width() / 2,
                            centery=screen.get_height() /2)

    screen.blit(text, textpos)
    pygame.display.flip()
Example #3
0
def draw_box(screen, message):
    pygame.draw.rect(screen, (0,0,0),
           ((screen.get_width() / 2) - 100,
            (screen.get_height() / 2) - 10,
            200,20), 0)
    if len(message) != 0:
        screen.blit(FONT.render(message, 1, (255, 255, 255)),
                ((screen.get_width() / 2) - 100, (screen.get_height() / 2) - 10))
    pygame.display.flip()
Example #4
0
 def draw_log(self):
     lines = self._log.splitlines()
     while len(lines) > 8:
         lines.pop(0)
     self._log = '\n'.join(lines)
     self._log += '\n'
     for i, l in enumerate(reversed(lines)):
         text = FONT.render(l,  True, (10, 10, 10))
         x, y = self.msg_coords
         y += i*28
         if self._centerx:
             textpos = text.get_rect(centerx=x, centery=y)
         else:
             textpos = text.get_rect(x=x, centery=y)
         self.screen.blit(text, textpos)