A simple pygame-based text scroller.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
751 B

# Character Sheet object for holding the sprite sheet image file and additional
# data such as character width and height.
# This, of course, only takes into account fixed-width bitmap fonts.
from pygame import image
class CharSheet:
def __init__(self, filename, characters, char_width, char_height):
self.sheet = image.load(filename)
self.characters = characters
self.char_width = char_width
self.char_height = char_height
# Retrieves the top-left x and y co-ordinates of a character on the sprite
# sheet.
def get_sheet(self, character):
index = self.characters.index(character.char)
y = index // self.char_height
x = index - (self.char_height * y)
return [x, y]