def __init__(self, x, y, text, font=None, color=(0,0,0)):
     super(Text, self).__init__(x, y)
     self.interactive = False
     if font is None:
         font = assets.getFont(None, 19)
     self.font = font
     self.setText(text, color)
    def debug_draw(self, surface, camera_x, camera_y):
        import pygame

        if not hasattr(self, "debug_nametag"):
            import assets
            self.debug_nametag = assets.getFont(None, 10).render(type(self).__name__ + ": " + self.name, False, (255,255,255), (0,0,0))

        pygame.draw.circle(surface, (255,0,0), (int(self.x + camera_x), int(self.y + camera_y)), 3)
        surface.blit(self.debug_nametag, (int(self.x + camera_x), int(self.y + camera_y + 18)))
示例#3
0
 def __init__(self, x, y, width, height, text, scroll_speed, font=None):
     super(ScrollText, self).__init__(x,y)
     self.width = width
     self.height = height
     self.scroll_speed = scroll_speed
     self.scroll_pos = 0
     self.scroll_stop = 0
     if font is None:
         font = assets.getFont(None, 10)
     self.font = font
     self.atTop = True
     self.atBottom = False
     self.setText(text)
 def __init__(self, x, y, width, height, text, scroll_speed, font=None):
     super(ScrollText, self).__init__(x,y)
     self.width = width
     self.height = height
     self.scroll_speed = scroll_speed
     self.scroll_pos = 0
     self.scroll_stop = 0
     if font is None:
         font = assets.getFont(None, 19)
     self.font = font
     self.line_height = self.font.render("X", True, (0,0,0)).get_height()
     self.height = (self.height / self.line_height) * self.line_height
     self.atTop = True
     self.atBottom = False
     self.setText(text)
import assets
import animation
import metrics

pygame.init()

disp = pygame.display.set_mode((metrics.SCREEN_WIDTH, metrics.SCREEN_HEIGHT))
clock = pygame.time.Clock()

anim = assets.getSpriteAnim(sys.argv[1])
sequences = anim.sequences.keys()
current = 0
cursor = animation.SimpleCursor()
cursor.play(anim.getSequence(sequences[current]))

font = assets.getFont(None, 10)
anim_text = font.render(str(current) + ": " + sequences[current], False, (0,0,0))

keep_going = True
while keep_going:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            keep_going = False

        if event.type == pygame.KEYDOWN:
            current = (current+1) % len(sequences)
            anim_text = font.render(str(current) + ": " + sequences[current], False, (0,0,0))
            cursor.play(anim.getSequence(sequences[current]))

    td = clock.tick(metrics.FPS)
    cursor.update(td)
 def debug_draw(self, surface, camera_x, camera_y):
     import pygame
     import assets
     img = assets.getFont(None, 10).render("Health: %i / %i" % (self.health, self.max_health), False, (255,255,255), (0,0,0))
     surface.blit(img, (int(self.gameobject.x + camera_x), int(self.gameobject.y + camera_y + 40)))
 def updateCoins(self):
     """Change display for how many coins have been collected"""
     self.coin_txt = assets.getFont(None, 10).render(str(self.coins)+" / "+str(self.max_coins), False, (255,255,255))