bardziej inteligentny robot?

This commit is contained in:
s464859 2022-03-24 17:45:52 +01:00
parent 531fa42e75
commit f4da3bc9fa
5 changed files with 32 additions and 24 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@ -26,6 +26,7 @@ class AI:
return
self.chaos_controls()
#TU pisać resztę
def minesweeper_controls(self):

View File

@ -18,7 +18,7 @@ class Mine:
self.position_x=position_x
self.position_y=position_y
self.size=size
self.image = pygame.image.load("assets/sprites/mine.png")
self.image = pygame.image.load("assets/sprites/mine_fun_sized.png")
self.image = pygame.transform.scale(self.image, (self.size, self.size))
def draw(self, window):
@ -192,7 +192,7 @@ class NPC:
offset_y:int=0
current_map:Map
type:int
type:str
value:int
weight:float
@ -220,7 +220,7 @@ class Minesweeper:
self.position_x=position_x
self.position_y=position_y
self.size = size
self.image = pygame.image.load("assets/sprites/saper.png")
self.image = pygame.image.load("assets/sprites/saper_fun_sized.png")
self.image = pygame.transform.scale(self.image, (self.size, self.size))
self.rotated_image = self.image
@ -270,35 +270,42 @@ class Minesweeper:
move_legal=True
cliff_jump=False
next_x=self.position_x
next_y=self.position_y
if dir==0:
if self.position_y+1 == self.current_map.tiles_y:
move_legal=False
elif self.current_map.terrain_matrix[self.position_y+1][self.position_x]>9:
move_legal=False
next_y=self.position_y+1
elif dir==180:
if self.position_y-1 == -1:
move_legal=False
elif self.current_map.terrain_matrix[self.position_y-1][self.position_x]>9:
move_legal=False
next_y=self.position_y-1
elif dir==270:
if self.position_x-1 == -1:
move_legal=False
elif self.current_map.terrain_matrix[self.position_y][self.position_x-1]>9:
move_legal=False
next_x=self.position_x-1
elif dir==90:
if self.position_x+1 == self.current_map.tiles_x:
move_legal=False
elif self.current_map.terrain_matrix[self.position_y][self.position_x+1]>9:
move_legal=False
next_x=self.position_x+1
if next_x == self.current_map.tiles_x or next_x == -1:
move_legal=False
if next_y == self.current_map.tiles_y or next_y == -1:
move_legal=False
if self.current_map.terrain_matrix[next_y][next_x]>9:
move_legal=False
if self.current_map.terrain_matrix[next_y][next_x]>9:
move_legal=False
for cliff in self.current_map.cliffs:
if (next_x, next_y) == (cliff.position_x, cliff.position_y):
if dir==0 and cliff.rotation==0:
cliff_jump=True
else:
move_legal=False
if move_legal:
if cliff_jump:
pass
pygame.mixer.Channel(1).set_volume(0.3)
pygame.mixer.Channel(1).play(pygame.mixer.Sound("assets/sounds/moving.wav"))
if dir==0:
self.position_y+=1
self.offset_y=-self.size
if cliff_jump:
self.position_y+=1
self.offset_y=-2*self.size
elif dir==180:
self.position_y-=1
self.offset_y=self.size

View File

@ -7,11 +7,11 @@ from classes import system, minesweeper, ai
#ustalenie wielkości pojedyńczych kawałków mapy, oraz wielkości mapy
TILE_SIZE = 64
TILES_X = 16
TILES_Y = 10
TILES_X = int(12)
TILES_Y = int(10)
#wł/wył muzyki
MUSIC=False
MUSIC=True
#ustalenie FPS
FPS = 60