Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pgzero
- import random
- # Игровое окно из клеток
- cell = Actor('border')
- cell1 = Actor("crack")
- cell2 = Actor('floor')
- cell3 = Actor('bones')
- size_w = 7 # Ширина поля в клетках
- size_h = 7 # Высота поля в клетках
- WIDTH = cell.width * size_w
- HEIGHT = cell.height * size_h
- TITLE = "Подземелья" # Заголовок окна игры
- FPS = 30 # Количество кадров в секунду
- char = Actor('stand')
- char.health = 100
- char.attack = 5
- my_map = [[0, 0, 0, 0, 0, 0, 0],
- [0, 1, 2, 1, 3, 1, 0],
- [0, 1, 1, 2, 1, 1, 0],
- [0, 3, 2, 1, 1, 3, 0],
- [0, 1, 1, 1, 3, 1, 0],
- [0, 1, 3, 1, 1, 2, 0],
- [0, 0, 0, 0, 0, 0, 0]]
- # def generate_map():
- # global my_map
- # for i in range(size_w):
- # stroka = [0]*10
- # for j in range(size_h):
- # if not i == 0 and not i == (size_w -1):
- # if not j == 0 and not j == (size_w -1):
- # stroka[j] = random.randint(0,3)
- # my_map.append(stroka)
- # else:
- # pass
- # generate_map()
- # print(my_map)
- def draw_map():
- for i in range(size_w):
- for j in range(size_h):
- if my_map[i][j] == 0:
- cell.left = cell.width*j
- cell.top = cell.height*i
- cell.draw()
- if my_map[i][j] == 1:
- cell1.left = cell1.width*j
- cell1.top = cell1.height*i
- cell1.draw()
- if my_map[i][j] == 2:
- cell2.left = cell2.width*j
- cell2.top = cell2.height*i
- cell2.draw()
- if my_map[i][j] == 3:
- cell3.left = cell3.width*j
- cell3.top = cell3.height*i
- cell3.draw()
- def draw():
- draw_map()
- char.draw()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement