mixster

Untitled

Apr 15th, 2010
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.99 KB | None | 0 0
  1. def parseLevel(filename):
  2.     m = walls = tots = []
  3.     fileObj = open(filename)
  4.     st = fileObj.read()
  5.     fileObj.close()
  6.     rez = st.find(".", 0)
  7.     tot = [float(res[0]) / float(st[0: rez]), float(res[1]) / float(st[0:rez])]
  8.     x = st.find(".", rez + 1)
  9.     y = st.find("(", x)
  10.     h = 0
  11.     for i in range(0, int(st[rez + 1:x])):
  12.         walls.append([])
  13.         for e in range(0, int(st[x + 1:y])):
  14.             h, h2 = st.find("(", h) + 1, st.find(")", h)
  15.             for la in range(0, 5):
  16.                 go = st.find(",", h, h2)
  17.                 m.append(int(st[h:go]))
  18.                 h = go + 1
  19.             if m[4] == 2:
  20.                 m[4] = 0
  21.                 player.rect = pygame.Rect(m[0] * tot[0], m[1] * tot[1], m[2] * tot[0], m[3] * tot[1])
  22.             walls[i].append(Wall((m[0] * tot[0], m[1] * tot[1], m[2] * tot[0], m[3] * tot[1], m[4])))
  23.             m = []
  24.     return (tot, walls)
  25.  
  26. this worked when it went
  27.  
  28.  
  29. m = walls = tots = []
  30. def parseLevel(filename):
Add Comment
Please, Sign In to add comment