all repos — Legends-RPG @ a3e1bf1ee058ec36f664e80bc761968e1084d468

A fantasy mini-RPG built with Python and Pygame.

data/components/textbox.py (view raw)

 1__author__ = 'justinarmstrong'
 2import pygame as pg
 3from .. import setup
 4
 5class Dialogue(pg.sprite.Sprite):
 6    """Text box used for dialogue"""
 7    def __init__(self, x):
 8        super(Dialogue, self).__init__()
 9        self.image = setup.GFX['dialoguebox']
10        self.rect = self.image.get_rect(centerx=x)
11        self.timer = 0.0
12
13    def update(self, current_time):
14        """Updates scrolling text"""
15        if self.timer == 0.0:
16            self.timer = current_time
17        elif (current_time - self.timer) > 2000:
18            self.kill()
19
20
21