added coords to background

This commit is contained in:
s452635 2021-05-02 21:04:41 +02:00
parent a4bc74d5f2
commit d47e46313c
12 changed files with 36 additions and 32 deletions

View File

@ -7,8 +7,8 @@ import project_constants as const
def calculate_screen_position(row, column):
coords = (
const.V_SCREEN_PADDING + const.V_TILE_SIZE * column,
const.V_SCREEN_PADDING + const.V_TILE_SIZE * row,
const.V_NUMBER_PADDING + const.V_SCREEN_PADDING + const.V_TILE_SIZE * column,
const.V_NUMBER_PADDING + const.V_SCREEN_PADDING + const.V_TILE_SIZE * row,
)
return coords

View File

@ -25,8 +25,10 @@ def main():
# create an instance of Minefield, pass necessary data
minefield = mf.Minefield(const.MAP_RANDOM_10x10)
# get sequence of actions found by BFS algorythm
action_sequence = bfs.graphsearch(initial_state=bfs.State(row=minefield.agent.position[0],
# get sequence of actions found by BFS algorithm
action_sequence = bfs.graphsearch(
initial_state=bfs.State(
row=minefield.agent.position[0],
column=minefield.agent.position[1],
direction=const.Direction.UP),
minefield=minefield)

View File

@ -59,8 +59,8 @@ class Minefield:
@staticmethod
def calculate_screen_position(row, column):
coords = (
const.V_SCREEN_PADDING + const.V_TILE_SIZE * column,
const.V_SCREEN_PADDING + const.V_TILE_SIZE * row,
const.V_NUMBER_PADDING + const.V_SCREEN_PADDING + const.V_TILE_SIZE * column,
const.V_NUMBER_PADDING + const.V_SCREEN_PADDING + const.V_TILE_SIZE * row,
)
return coords

View File

@ -14,21 +14,23 @@ from enum import Enum
# ================= #
V_NAME_OF_WINDOW = "MineFusion TM"
ASSETS_DIR = os.path.join("resources", "assets")
DIR_ASSETS = os.path.join("resources", "assets")
V_FPS = 60
ACTION_INTERVAL = 1 # interval between two actions in seconds
V_TILE_SIZE = 60
V_GRID_VER_TILES = V_GRID_HOR_TILES = 10 # vertical (number of rows), horizontal (number of columns)
V_GRID_VER_TILES = 10 # vertical (number of rows)
V_GRID_HOR_TILES = 10 # horizontal (number of columns)
V_SCREEN_PADDING = 10
V_WINDOW_HEIGHT = V_TILE_SIZE * V_GRID_VER_TILES
V_WINDOW_WIDTH = V_TILE_SIZE * V_GRID_HOR_TILES
V_NUMBER_PADDING = 50
V_TILE_AREA_HEIGHT = V_TILE_SIZE * V_GRID_VER_TILES
V_TILE_AREA_WIDTH = V_TILE_SIZE * V_GRID_HOR_TILES
SCREEN = pygame.display.set_mode(
(
V_TILE_SIZE * V_GRID_HOR_TILES + 2 * V_SCREEN_PADDING, # screen width
V_TILE_SIZE * V_GRID_HOR_TILES + 2 * V_SCREEN_PADDING # screen height
V_TILE_AREA_WIDTH + 2 * V_SCREEN_PADDING + V_NUMBER_PADDING, # screen width
V_TILE_AREA_HEIGHT + 2 * V_SCREEN_PADDING + V_NUMBER_PADDING # screen height
)
)
@ -113,71 +115,71 @@ MAP_RANDOM_10x10 = os.path.join("resources", "minefields", "secondmap.json")
# ============== #
ASSET_BACKGROUND = pygame.transform.scale(
pygame.image.load(os.path.join(ASSETS_DIR, "new_grid.png")),
(V_WINDOW_WIDTH, V_WINDOW_WIDTH)
pygame.image.load(os.path.join(DIR_ASSETS, "numbered_grid.png")),
(650, 650)
)
ASSET_SAPPER = pygame.transform.scale(
pygame.image.load(os.path.join(ASSETS_DIR, "robot_sapper.png")),
pygame.image.load(os.path.join(DIR_ASSETS, "robot_sapper.png")),
(V_TILE_SIZE, V_TILE_SIZE)
)
ASSET_WALL = pygame.transform.scale(
pygame.image.load(os.path.join(ASSETS_DIR, "brick_wall.png")),
pygame.image.load(os.path.join(DIR_ASSETS, "brick_wall.png")),
(V_TILE_SIZE, V_TILE_SIZE)
)
ASSET_MINE_A = pygame.transform.scale(
pygame.image.load(os.path.join(ASSETS_DIR, "mine_a.png")),
pygame.image.load(os.path.join(DIR_ASSETS, "simple assets/mine_a.png")),
(V_TILE_SIZE, V_TILE_SIZE)
)
ASSET_MINE_B = pygame.transform.scale(
pygame.image.load(os.path.join(ASSETS_DIR, "mine_b.png")),
pygame.image.load(os.path.join(DIR_ASSETS, "simple assets/mine_b.png")),
(V_TILE_SIZE, V_TILE_SIZE)
)
ASSET_MINE_F = pygame.transform.scale(
pygame.image.load(os.path.join(ASSETS_DIR, "mine_f.png")),
pygame.image.load(os.path.join(DIR_ASSETS, "simple assets/mine_f.png")),
(V_TILE_SIZE, V_TILE_SIZE)
)
ASSET_MINE_K = pygame.transform.scale(
pygame.image.load(os.path.join(ASSETS_DIR, "mine_k.png")),
pygame.image.load(os.path.join(DIR_ASSETS, "simple assets/mine_k.png")),
(V_TILE_SIZE, V_TILE_SIZE)
)
ASSET_TILE_ORANGE = pygame.transform.scale(
pygame.image.load(os.path.join(ASSETS_DIR, "tile_orange.png")),
pygame.image.load(os.path.join(DIR_ASSETS, "tile_orange.png")),
(V_TILE_SIZE, V_TILE_SIZE)
)
ASSET_TILE_RED = pygame.transform.scale(
pygame.image.load(os.path.join(ASSETS_DIR, "tile_red.png")),
pygame.image.load(os.path.join(DIR_ASSETS, "tile_red.png")),
(V_TILE_SIZE, V_TILE_SIZE)
)
ASSET_TILE_BLUE = pygame.transform.scale(
pygame.image.load(os.path.join(ASSETS_DIR, "tile_blue.png")),
pygame.image.load(os.path.join(DIR_ASSETS, "tile_blue.png")),
(V_TILE_SIZE, V_TILE_SIZE)
)
ASSET_TILE_PURPLE = pygame.transform.scale(
pygame.image.load(os.path.join(ASSETS_DIR, "tile_purple.png")),
pygame.image.load(os.path.join(DIR_ASSETS, "tile_purple.png")),
(V_TILE_SIZE, V_TILE_SIZE)
)
ASSET_TILE_GREEN = pygame.transform.scale(
pygame.image.load(os.path.join(ASSETS_DIR, "tile_green.png")),
pygame.image.load(os.path.join(DIR_ASSETS, "tile_green.png")),
(V_TILE_SIZE, V_TILE_SIZE)
)
ASSET_TILE_YELLOW = pygame.transform.scale(
pygame.image.load(os.path.join(ASSETS_DIR, "tile_yellow.png")),
pygame.image.load(os.path.join(DIR_ASSETS, "tile_yellow.png")),
(V_TILE_SIZE, V_TILE_SIZE)
)
ASSET_TILE_WHITE = pygame.transform.scale(
pygame.image.load(os.path.join(ASSETS_DIR, "tile_white.png")),
pygame.image.load(os.path.join(DIR_ASSETS, "tile_white.png")),
(V_TILE_SIZE, V_TILE_SIZE)
)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 406 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 903 B

View File

Before

Width:  |  Height:  |  Size: 109 B

After

Width:  |  Height:  |  Size: 109 B

View File

Before

Width:  |  Height:  |  Size: 110 B

After

Width:  |  Height:  |  Size: 110 B

View File

Before

Width:  |  Height:  |  Size: 108 B

After

Width:  |  Height:  |  Size: 108 B

View File

Before

Width:  |  Height:  |  Size: 116 B

After

Width:  |  Height:  |  Size: 116 B

View File

Before

Width:  |  Height:  |  Size: 153 B

After

Width:  |  Height:  |  Size: 153 B

View File

@ -6,7 +6,7 @@ from project_constants import Direction, Action
from minefield import Minefield
# temporary goal for testing
GOAL = (13, 9)
GOAL = (9, 9)
class State: