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.
17 lines
466 B
17 lines
466 B
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
|
|
|
|
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]
|
|
|