How do I do this? In JustBasic I simply read from a text file and coverted the letter it found into an image that it loaded. I want it to load the image I need with this class:
def load_image(name, colorkey=None):
"""When this statement is accessed, coupled with the name and key,
the specified image is imported, and stored"""
fullname = os.path.join('Data\RPG', name)
try:
image = pygame.image.load(fullname)
except pygame.error, message:
print 'Cannot load image:', name
raise SystemExit, message
image = image.convert()
if colorkey is not None:
if colorkey is -1:
colorkey = image.get_at((0,0))
image.set_colorkey(colorkey, RLEACCEL)
return image, image.get_rect()
and read each line of a text file into a list, splitting at the ","s then using the position of the character in the list with the tile size (16) to place them on the background.
y = 0
y = y+1 tilex = (line[i]+1) * 16 tiley = y * 16 TEXT FILE: G,G,G G,G,G G,G,G if line[i] = G then place grass image elif line[i] = ........ repeat for each different tile. As it stands I only have the one tile right now. How would I implement this?[code to read the line]
y = y+1
tilex = (line+1) * 16
tiley = y * 16
TEXT FILE:
G,G,G
G,G,G
G,G,G
if line = G then place grass image
elif line = ........
repeat for each different tile. As it stands I only have the one tile right now. How would I implement this?