-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmap.py
45 lines (33 loc) · 1.3 KB
/
map.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import random
import pygame as pg
# Genrate arrays from 1 and _
# array = [[random.choice([1, _]) for j in range(12)] for i in range(5)]
# print(array)
_ = False
# One element corresponds to 100px
minimap = [
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
[1, _, 1, _, _, _, _, _, 1, _, _, _, _, _, _, 1],
[1, _, _, _, _, _, _, 1, _, _, _, _, _, _, _, 1],
[1, _, _, _, 1, _, _, 1, _, _, _, _, 1, _, _, 1],
[1, _, _, 1, _, _, _, _, _, _, 1, _, _, _, _, 1],
[1, _, _, 1, _, _, _, _, _, _, 1, _, _, _, _, 1],
[1, _, _, _, _, _, 1, 1, _, _, _, 1, _, _, _, 1],
[1, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 1],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
]
class Map:
def __init__(self, game):
self.game = game
self.minimap = minimap
self.worldmap = {}
self.get_map()
# draw map tiles. 1 is wall and _ is free tile
def get_map(self):
for i, row in enumerate(self.minimap):
for j, value in enumerate(row):
if value:
self.worldmap[(j, i)] = value
def draw(self):
[pg.draw.rect(self.game.screen, 'darkgray', (pos[0] * 100, pos[1] * 100, 100, 100), 2)
for pos in self.worldmap]