Advertisement
Karp_xD

world.py

Jul 7th, 2022
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.25 KB | None | 0 0
  1. import pygame, FWC
  2. pygame.init()
  3.  
  4. #create images
  5. walls = pygame.image.load('images/map/wall.png')
  6. floors = pygame.image.load('images/map/floor.png')
  7. ceilings = pygame.image.load('images/map/ceiling.png')
  8. class World:
  9.     def __init__(self):
  10.         self.obstacle_list = []
  11.         self.processed = False
  12.         with open('world.txt') as w:
  13.             self.data = w.read()
  14.             w.close()
  15.     def process_world(self):
  16.         if self.processed == False:
  17.             for y, row in enumerate(self.data):
  18.                 for x, tile in enumerate(row):
  19.                         if tile != '0':
  20.                             if tile == '1':
  21.                                 wall = FWC.FWC(x * 32, y * 32, walls)
  22.                                 FWC.wall_group.add(wall)
  23.                             if tile == '2':
  24.                                 floor = FWC.FWC(x * 32, y * 32, floors)
  25.                                 FWC.floor_group.add(floor)
  26.                             if tile == '3':
  27.                                 ceiling = FWC.FWC(x * 32, y * 32, ceilings)
  28.                                 FWC.ceiling_group.add(ceiling)
  29.                             self.obstacle_list.append(pygame.Rect(x * 32, y * 32, 32, 32))
  30.             self.processed = True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement