Advertisement
OtsoSilver

Untitled

Sep 12th, 2021
992
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.93 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 = 7 # Ширина поля в клетках
  9. size_h = 7 # Высота поля в клетках
  10. WIDTH = cell.width * size_w
  11. HEIGHT = cell.height * size_h
  12.  
  13. TITLE = "Подземелья" # Заголовок окна игры
  14. FPS = 30 # Количество кадров в секунду
  15.  
  16. char = Actor('stand')
  17. char.health = 100
  18. char.attack = 5
  19.  
  20. my_map = [[0, 0, 0, 0, 0, 0, 0],
  21.           [0, 1, 2, 1, 3, 1, 0],
  22.           [0, 1, 1, 2, 1, 1, 0],
  23.           [0, 3, 2, 1, 1, 3, 0],
  24.           [0, 1, 1, 1, 3, 1, 0],
  25.           [0, 1, 3, 1, 1, 2, 0],
  26.           [0, 0, 0, 0, 0, 0, 0]]
  27.  
  28. # def generate_map():
  29. #     global my_map
  30. #     for i in range(size_w):
  31. #         stroka = [0]*10
  32. #         for j in range(size_h):
  33. #             if not i == 0 and not i == (size_w -1):
  34. #                 if not j == 0 and not j == (size_w -1):
  35. #                     stroka[j] = random.randint(0,3)
  36. #                     my_map.append(stroka)
  37. #             else:
  38. #                 pass
  39.                    
  40. # generate_map()
  41. # print(my_map)
  42.  
  43. def draw_map():
  44.     for i in range(size_w):
  45.         for j in range(size_h):
  46.             if my_map[i][j] == 0:
  47.                 cell.left = cell.width*j
  48.                 cell.top = cell.height*i
  49.                 cell.draw()
  50.             if my_map[i][j] == 1:
  51.                 cell1.left = cell1.width*j
  52.                 cell1.top = cell1.height*i
  53.                 cell1.draw()
  54.             if my_map[i][j] == 2:
  55.                 cell2.left = cell2.width*j
  56.                 cell2.top = cell2.height*i
  57.                 cell2.draw()
  58.             if my_map[i][j] == 3:
  59.                 cell3.left = cell3.width*j
  60.                 cell3.top = cell3.height*i
  61.                 cell3.draw()
  62.  
  63.  
  64.  
  65.  
  66. def draw():
  67.     draw_map()
  68.     char.draw()
  69.  
  70.  
  71.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement