OtsoSilver

Untitled

Sep 12th, 2021
985
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.54 KB | None | 0 0
  1. #pgzero
  2. import random
  3. # Игровое окно из клеток
  4. cell = Actor('border')
  5. cell1 = Actor("crack")
  6. cell2 = Actor('floor')
  7. cell3 = Actor('bones')
  8. size_w = 10 # Ширина поля в клетках
  9. size_h = 10 # Высота поля в клетках
  10. WIDTH = cell.width * size_w
  11. HEIGHT = cell.height * size_h
  12.  
  13. TITLE = "Подземелья" # Заголовок окна игры
  14. FPS = 30 # Количество кадров в секунду
  15.  
  16. my_map = [[0]*size_w]*size_h
  17.  
  18. def generate_map():
  19.     global my_map
  20.     for i in range(size_w):
  21.         for j in range(size_h):
  22.             if not i == 0 and not i == (size_w -1):
  23.                 if not j == 0 and not j == (size_w -1):
  24.                     my_map[i][j] = random.randint(1,3)
  25.                    
  26.                    
  27. generate_map()
  28. print(my_map)
  29.  
  30. def draw_map():
  31.     for i in range(size_w):
  32.         for j in range(size_h):
  33.             if my_map[i][j] == 0:
  34.                 cell.left = cell.width*j
  35.                 cell.top = cell.height*i
  36.                 cell.draw()
  37.             if my_map[i][j] == 1:
  38.                 cell1.left = cell1.width*j
  39.                 cell1.top = cell1.height*i
  40.                 cell1.draw()
  41.             if my_map[i][j] == 2:
  42.                 cell2.left = cell2.width*j
  43.                 cell2.top = cell2.height*i
  44.                 cell2.draw()
  45.             if my_map[i][j] == 3:
  46.                 cell3.left = cell3.width*j
  47.                 cell3.top = cell3.height*i
  48.                 cell3.draw()
  49.  
  50.  
  51.  
  52.  
  53. def draw():
  54.     draw_map()
  55.  
  56.  
  57.  
  58.  
Advertisement
Add Comment
Please, Sign In to add comment