niedziałające klify

This commit is contained in:
s464859 2022-03-10 18:40:11 +01:00
parent d095fe469e
commit c4a623ae6d
2 changed files with 33 additions and 2 deletions

BIN
assets/sprites/cliff.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View File

@ -24,6 +24,29 @@ class Mine:
position_on_screen = (self.size*self.position_x, self.size*self.position_y)
window.blit(self.image, position_on_screen)
class Cliff:
position_x:int
position_y:int
size:int
image:pygame.surface.Surface
rotation:int
def __init__(self,position_x, position_y, size, rotation):
self.position_x=position_x
self.position_y=position_y
self.size=size
self.rotation = rotation
self.image = pygame.image.load("assets/sprites/cliff.png")
self.image = pygame.transform.scale(self.image, (self.size, self.size))
self.image = pygame.transform.rotate(self.image, self.rotation)
def draw(self, window):
position_on_screen = (self.size*self.position_x, self.size*self.position_y)
window.blit(self.image, position_on_screen)
#mapa
class Map:
@ -35,6 +58,7 @@ class Map:
tile_palette:list
terrain_matrix:list
cliffs=[]
mines=[]
def __init__(self, window:system.Window, tile_size:int=64, tiles_x:int=8, tiles_y:int=8):
@ -61,8 +85,13 @@ class Map:
matrix.append([])
for j in range(self.tiles_x):
#od liczby zależy jaki teren, np. 0 - piasek
if randrange(10)==0:
rng = randrange(10)
if rng==0:
matrix[i].append(10)
elif rng<2:
matrix[i].append(0)
cliff = Cliff(j,i,self.tile_size, randrange(4)*90)
#self.cliffs.append(cliff)
else:
matrix[i].append(0)
self.terrain_matrix = matrix
@ -83,6 +112,8 @@ class Map:
def draw_objects(self):
for mine in self.mines:
mine.draw(self.window.window)
for cliff in self.cliffs:
cliff.draw(self.window.window)
#saper
@ -181,7 +212,7 @@ class Minesweeper:
move_legal=False
elif map.terrain_matrix[self.position_y][self.position_x+1]>9:
move_legal=False
if move_legal:
pygame.mixer.Channel(1).set_volume(0.3)
pygame.mixer.Channel(1).play(pygame.mixer.Sound("assets/sounds/moving.wav"))