Initial commit from tutorial by Coder Space

This commit is contained in:
Michał Gdula 2023-01-27 23:39:49 +00:00
parent 1a55189db7
commit ccb5394b00
16 changed files with 377 additions and 0 deletions

55
map.py Normal file
View file

@ -0,0 +1,55 @@
import pygame as pg
_ = False
mini_map = [
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
[1, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 1],
[1, _, _, 3, 3, 3, 3, _, _, _, 2, 2, 2, _, _, 1],
[1, _, _, _, _, _, 4, _, _, _, _, _, 2, _, _, 1],
[1, _, _, _, _, _, 4, _, _, _, _, _, 2, _, _, 1],
[1, _, _, 3, 3, 3, 3, _, _, _, _, _, _, _, _, 1],
[1, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 1],
[1, _, _, _, 4, _, _, _, 4, _, _, _, _, _, _, 1],
[1, 1, 1, 3, 1, 3, 1, 1, 1, 3, _, _, 3, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 3, _, _, 3, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 3, _, _, 3, 1, 1, 1],
[1, 1, 3, 1, 1, 1, 1, 1, 1, 3, _, _, 3, 1, 1, 1],
[1, 4, _, _, _, _, _, _, _, _, _, _, _, _, _, 1],
[3, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 1],
[1, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 1],
[1, _, _, 2, _, _, _, _, _, 3, 4, _, 4, 3, _, 1],
[1, _, _, 5, _, _, _, _, _, _, 3, _, 3, _, _, 1],
[1, _, _, 2, _, _, _, _, _, _, _, _, _, _, _, 1],
[1, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 1],
[3, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 1],
[1, 4, _, _, _, _, _, _, 4, _, _, 4, _, _, _, 1],
[1, 1, 3, 3, _, _, 3, 3, 1, 3, 3, 1, 3, 1, 1, 1],
[1, 1, 1, 3, _, _, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1],
[1, 3, 3, 4, _, _, 4, 3, 3, 3, 3, 3, 3, 3, 3, 1],
[3, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 3],
[3, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 3],
[3, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 3],
[3, _, _, 5, _, _, _, 5, _, _, _, 5, _, _, _, 3],
[3, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 3],
[3, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 3],
[3, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 3],
[3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],
]
class Map:
def __init__(self, game):
self.game = game
self.mini_map = mini_map
self.world_map = {}
self.get_map()
def get_map(self):
for i, row in enumerate(self.mini_map):
for j, tile in enumerate(row):
if tile:
self.world_map[(j, i)] = tile
def draw(self):
[pg.draw.rect(self.game.screen, 'darkgray', (pos[0] * 100, pos[1] * 100, 100, 100), 1)
for pos in self.world_map]