Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pygame, FWC
- pygame.init()
- #create images
- walls = pygame.image.load('images/map/wall.png')
- floors = pygame.image.load('images/map/floor.png')
- ceilings = pygame.image.load('images/map/ceiling.png')
- class World:
- def __init__(self):
- self.obstacle_list = []
- self.processed = False
- with open('world.txt') as w:
- self.data = w.read()
- w.close()
- def process_world(self):
- if self.processed == False:
- for y, row in enumerate(self.data):
- for x, tile in enumerate(row):
- if tile != '0':
- if tile == '1':
- wall = FWC.FWC(x * 32, y * 32, walls)
- FWC.wall_group.add(wall)
- if tile == '2':
- floor = FWC.FWC(x * 32, y * 32, floors)
- FWC.floor_group.add(floor)
- if tile == '3':
- ceiling = FWC.FWC(x * 32, y * 32, ceilings)
- FWC.ceiling_group.add(ceiling)
- self.obstacle_list.append(pygame.Rect(x * 32, y * 32, 32, 32))
- self.processed = True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement