created package for assets, minor changes to mine assets
This commit is contained in:
parent
dd024fa404
commit
07934fb15c
5
agent.py
5
agent.py
@ -1,4 +1,5 @@
|
|||||||
import project_constants as const
|
import project_constants as const
|
||||||
|
from assets import asset_constants as asset
|
||||||
import json
|
import json
|
||||||
from pygame import transform
|
from pygame import transform
|
||||||
|
|
||||||
@ -33,10 +34,10 @@ class Agent:
|
|||||||
coord_x, coord_y = self.on_screen_coordinates[0], self.on_screen_coordinates[1]
|
coord_x, coord_y = self.on_screen_coordinates[0], self.on_screen_coordinates[1]
|
||||||
tl_dimension = const.V_TILE_SIZE / 2
|
tl_dimension = const.V_TILE_SIZE / 2
|
||||||
|
|
||||||
rotating_rect = transform.rotate(const.ASSET_SAPPER, self.rotation_angle).get_rect()
|
rotating_rect = transform.rotate(asset.ASSET_SAPPER, self.rotation_angle).get_rect()
|
||||||
rotating_rect.center = (coord_x + tl_dimension, coord_y + tl_dimension)
|
rotating_rect.center = (coord_x + tl_dimension, coord_y + tl_dimension)
|
||||||
|
|
||||||
window.blit(transform.rotate(const.ASSET_SAPPER, self.rotation_angle), rotating_rect)
|
window.blit(transform.rotate(asset.ASSET_SAPPER, self.rotation_angle), rotating_rect)
|
||||||
|
|
||||||
def update(self, delta_time, minefield):
|
def update(self, delta_time, minefield):
|
||||||
self.new_action = self.going_forward + self.rotating_left * 2 + self.rotating_right * 4
|
self.new_action = self.going_forward + self.rotating_left * 2 + self.rotating_right * 4
|
||||||
|
0
assets/__init__.py
Normal file
0
assets/__init__.py
Normal file
262
assets/asset_constants.py
Normal file
262
assets/asset_constants.py
Normal file
@ -0,0 +1,262 @@
|
|||||||
|
|
||||||
|
import pygame
|
||||||
|
import os
|
||||||
|
|
||||||
|
import project_constants as c
|
||||||
|
DIR_ASSETS = c.DIR_ASSETS
|
||||||
|
V_TILE_SIZE = c.V_TILE_SIZE
|
||||||
|
|
||||||
|
|
||||||
|
# ============== #
|
||||||
|
# === ASSETS === #
|
||||||
|
# ============== #
|
||||||
|
|
||||||
|
ASSET_BACKGROUND = pygame.transform.scale(
|
||||||
|
pygame.image.load(os.path.join(DIR_ASSETS, "numbered_grid.png")),
|
||||||
|
(650, 650)
|
||||||
|
)
|
||||||
|
|
||||||
|
ASSET_SAPPER = pygame.transform.scale(
|
||||||
|
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(DIR_ASSETS, "brick_wall.png")),
|
||||||
|
(V_TILE_SIZE, V_TILE_SIZE)
|
||||||
|
)
|
||||||
|
|
||||||
|
ASSET_CONCRETE = pygame.transform.scale(
|
||||||
|
pygame.image.load(os.path.join(DIR_ASSETS, "concrete.png")),
|
||||||
|
(V_TILE_SIZE, V_TILE_SIZE)
|
||||||
|
)
|
||||||
|
|
||||||
|
ASSET_MUD = pygame.transform.scale(
|
||||||
|
pygame.image.load(os.path.join(DIR_ASSETS, "mud.png")),
|
||||||
|
(V_TILE_SIZE, V_TILE_SIZE)
|
||||||
|
)
|
||||||
|
|
||||||
|
ASSET_GRASS = pygame.transform.scale(
|
||||||
|
pygame.image.load(os.path.join(DIR_ASSETS, "grass.png")),
|
||||||
|
(V_TILE_SIZE, V_TILE_SIZE)
|
||||||
|
)
|
||||||
|
|
||||||
|
ASSET_MINE = pygame.transform.scale(
|
||||||
|
pygame.image.load(os.path.join(DIR_ASSETS, "mine.png")),
|
||||||
|
(V_TILE_SIZE, V_TILE_SIZE)
|
||||||
|
)
|
||||||
|
|
||||||
|
ASSET_CHAINS = pygame.transform.scale(
|
||||||
|
pygame.image.load(os.path.join(DIR_ASSETS, "chains.png")),
|
||||||
|
(V_TILE_SIZE, V_TILE_SIZE)
|
||||||
|
)
|
||||||
|
|
||||||
|
ASSET_CHAIN_COUNTER = pygame.transform.scale(
|
||||||
|
pygame.image.load(os.path.join(DIR_ASSETS, "chain_counter.png")),
|
||||||
|
(V_TILE_SIZE, V_TILE_SIZE)
|
||||||
|
)
|
||||||
|
|
||||||
|
ASSET_TIME_MINE = pygame.transform.scale(
|
||||||
|
pygame.image.load(os.path.join(DIR_ASSETS, "time_mine.png")),
|
||||||
|
(V_TILE_SIZE, V_TILE_SIZE)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# ==================== #
|
||||||
|
# === TIME NUMBERS === #
|
||||||
|
# ==================== #
|
||||||
|
|
||||||
|
ASSET_NUMBER_TIME_0 = pygame.transform.scale(
|
||||||
|
pygame.image.load(os.path.join(DIR_ASSETS, "time_numbers/time_number_0.png")),
|
||||||
|
(6, 16)
|
||||||
|
)
|
||||||
|
|
||||||
|
ASSET_NUMBER_TIME_1 = pygame.transform.scale(
|
||||||
|
pygame.image.load(os.path.join(DIR_ASSETS, "time_numbers/time_number_1.png")),
|
||||||
|
(6, 16)
|
||||||
|
)
|
||||||
|
|
||||||
|
ASSET_NUMBER_TIME_2 = pygame.transform.scale(
|
||||||
|
pygame.image.load(os.path.join(DIR_ASSETS, "time_numbers/time_number_2.png")),
|
||||||
|
(6, 16)
|
||||||
|
)
|
||||||
|
|
||||||
|
ASSET_NUMBER_TIME_3 = pygame.transform.scale(
|
||||||
|
pygame.image.load(os.path.join(DIR_ASSETS, "time_numbers/time_number_3.png")),
|
||||||
|
(6, 16)
|
||||||
|
)
|
||||||
|
|
||||||
|
ASSET_NUMBER_TIME_4 = pygame.transform.scale(
|
||||||
|
pygame.image.load(os.path.join(DIR_ASSETS, "time_numbers/time_number_4.png")),
|
||||||
|
(6, 16)
|
||||||
|
)
|
||||||
|
|
||||||
|
ASSET_NUMBER_TIME_5 = pygame.transform.scale(
|
||||||
|
pygame.image.load(os.path.join(DIR_ASSETS, "time_numbers/time_number_5.png")),
|
||||||
|
(6, 16)
|
||||||
|
)
|
||||||
|
|
||||||
|
ASSET_NUMBER_TIME_6 = pygame.transform.scale(
|
||||||
|
pygame.image.load(os.path.join(DIR_ASSETS, "time_numbers/time_number_6.png")),
|
||||||
|
(6, 16)
|
||||||
|
)
|
||||||
|
|
||||||
|
ASSET_NUMBER_TIME_7 = pygame.transform.scale(
|
||||||
|
pygame.image.load(os.path.join(DIR_ASSETS, "time_numbers/time_number_7.png")),
|
||||||
|
(6, 16)
|
||||||
|
)
|
||||||
|
|
||||||
|
ASSET_NUMBER_TIME_8 = pygame.transform.scale(
|
||||||
|
pygame.image.load(os.path.join(DIR_ASSETS, "time_numbers/time_number_8.png")),
|
||||||
|
(6, 16)
|
||||||
|
)
|
||||||
|
|
||||||
|
ASSET_NUMBER_TIME_9 = pygame.transform.scale(
|
||||||
|
pygame.image.load(os.path.join(DIR_ASSETS, "time_numbers/time_number_9.png")),
|
||||||
|
(6, 16)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# ====================== #
|
||||||
|
# === CHAINS NUMBERS === #
|
||||||
|
# ====================== #
|
||||||
|
|
||||||
|
ASSET_NUMBER_CHAINS_0 = pygame.transform.scale(
|
||||||
|
pygame.image.load(os.path.join(DIR_ASSETS, "chain_numbers/chain_number_0.png")),
|
||||||
|
(6, 12)
|
||||||
|
)
|
||||||
|
|
||||||
|
ASSET_NUMBER_CHAINS_1 = pygame.transform.scale(
|
||||||
|
pygame.image.load(os.path.join(DIR_ASSETS, "chain_numbers/chain_number_1.png")),
|
||||||
|
(6, 12)
|
||||||
|
)
|
||||||
|
|
||||||
|
ASSET_NUMBER_CHAINS_2 = pygame.transform.scale(
|
||||||
|
pygame.image.load(os.path.join(DIR_ASSETS, "chain_numbers/chain_number_2.png")),
|
||||||
|
(6, 12)
|
||||||
|
)
|
||||||
|
|
||||||
|
ASSET_NUMBER_CHAINS_3 = pygame.transform.scale(
|
||||||
|
pygame.image.load(os.path.join(DIR_ASSETS, "chain_numbers/chain_number_3.png")),
|
||||||
|
(6, 12)
|
||||||
|
)
|
||||||
|
|
||||||
|
ASSET_NUMBER_CHAINS_4 = pygame.transform.scale(
|
||||||
|
pygame.image.load(os.path.join(DIR_ASSETS, "chain_numbers/chain_number_4.png")),
|
||||||
|
(6, 12)
|
||||||
|
)
|
||||||
|
|
||||||
|
ASSET_NUMBER_CHAINS_5 = pygame.transform.scale(
|
||||||
|
pygame.image.load(os.path.join(DIR_ASSETS, "chain_numbers/chain_number_5.png")),
|
||||||
|
(6, 12)
|
||||||
|
)
|
||||||
|
|
||||||
|
ASSET_NUMBER_CHAINS_6 = pygame.transform.scale(
|
||||||
|
pygame.image.load(os.path.join(DIR_ASSETS, "chain_numbers/chain_number_6.png")),
|
||||||
|
(6, 12)
|
||||||
|
)
|
||||||
|
|
||||||
|
ASSET_NUMBER_CHAINS_7 = pygame.transform.scale(
|
||||||
|
pygame.image.load(os.path.join(DIR_ASSETS, "chain_numbers/chain_number_7.png")),
|
||||||
|
(6, 12)
|
||||||
|
)
|
||||||
|
|
||||||
|
ASSET_NUMBER_CHAINS_8 = pygame.transform.scale(
|
||||||
|
pygame.image.load(os.path.join(DIR_ASSETS, "chain_numbers/chain_number_8.png")),
|
||||||
|
(6, 12)
|
||||||
|
)
|
||||||
|
|
||||||
|
ASSET_NUMBER_CHAINS_9 = pygame.transform.scale(
|
||||||
|
pygame.image.load(os.path.join(DIR_ASSETS, "chain_numbers/chain_number_9.png")),
|
||||||
|
(6, 12)
|
||||||
|
)
|
||||||
|
|
||||||
|
ASSET_NUMBER_CHAINS_10 = pygame.transform.scale(
|
||||||
|
pygame.image.load(os.path.join(DIR_ASSETS, "chain_numbers/chain_number_10.png")),
|
||||||
|
(6, 12)
|
||||||
|
)
|
||||||
|
|
||||||
|
ASSET_NUMBER_CHAINS_11 = pygame.transform.scale(
|
||||||
|
pygame.image.load(os.path.join(DIR_ASSETS, "chain_numbers/chain_number_11.png")),
|
||||||
|
(6, 12)
|
||||||
|
)
|
||||||
|
|
||||||
|
ASSET_NUMBER_CHAINS_12 = pygame.transform.scale(
|
||||||
|
pygame.image.load(os.path.join(DIR_ASSETS, "chain_numbers/chain_number_12.png")),
|
||||||
|
(6, 12)
|
||||||
|
)
|
||||||
|
|
||||||
|
ASSET_NUMBER_CHAINS_13 = pygame.transform.scale(
|
||||||
|
pygame.image.load(os.path.join(DIR_ASSETS, "chain_numbers/chain_number_13.png")),
|
||||||
|
(6, 12)
|
||||||
|
)
|
||||||
|
|
||||||
|
ASSET_NUMBER_CHAINS_14 = pygame.transform.scale(
|
||||||
|
pygame.image.load(os.path.join(DIR_ASSETS, "chain_numbers/chain_number_14.png")),
|
||||||
|
(6, 12)
|
||||||
|
)
|
||||||
|
|
||||||
|
ASSET_NUMBER_CHAINS_15 = pygame.transform.scale(
|
||||||
|
pygame.image.load(os.path.join(DIR_ASSETS, "chain_numbers/chain_number_15.png")),
|
||||||
|
(6, 12)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# ================== #
|
||||||
|
# === OLD ASSETS === #
|
||||||
|
# ================== #
|
||||||
|
|
||||||
|
ASSET_MINE_A = pygame.transform.scale(
|
||||||
|
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(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(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(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(DIR_ASSETS, "old_tiles/tile_orange.png")),
|
||||||
|
(V_TILE_SIZE, V_TILE_SIZE)
|
||||||
|
)
|
||||||
|
|
||||||
|
ASSET_TILE_RED = pygame.transform.scale(
|
||||||
|
pygame.image.load(os.path.join(DIR_ASSETS, "old_tiles/tile_red.png")),
|
||||||
|
(V_TILE_SIZE, V_TILE_SIZE)
|
||||||
|
)
|
||||||
|
|
||||||
|
ASSET_TILE_BLUE = pygame.transform.scale(
|
||||||
|
pygame.image.load(os.path.join(DIR_ASSETS, "old_tiles/tile_blue.png")),
|
||||||
|
(V_TILE_SIZE, V_TILE_SIZE)
|
||||||
|
)
|
||||||
|
|
||||||
|
ASSET_TILE_PURPLE = pygame.transform.scale(
|
||||||
|
pygame.image.load(os.path.join(DIR_ASSETS, "old_tiles/tile_purple.png")),
|
||||||
|
(V_TILE_SIZE, V_TILE_SIZE)
|
||||||
|
)
|
||||||
|
|
||||||
|
ASSET_TILE_GREEN = pygame.transform.scale(
|
||||||
|
pygame.image.load(os.path.join(DIR_ASSETS, "old_tiles/tile_green.png")),
|
||||||
|
(V_TILE_SIZE, V_TILE_SIZE)
|
||||||
|
)
|
||||||
|
|
||||||
|
ASSET_TILE_YELLOW = pygame.transform.scale(
|
||||||
|
pygame.image.load(os.path.join(DIR_ASSETS, "old_tiles/tile_yellow.png")),
|
||||||
|
(V_TILE_SIZE, V_TILE_SIZE)
|
||||||
|
)
|
||||||
|
|
||||||
|
ASSET_TILE_WHITE = pygame.transform.scale(
|
||||||
|
pygame.image.load(os.path.join(DIR_ASSETS, "old_tiles/tile_white.png")),
|
||||||
|
(V_TILE_SIZE, V_TILE_SIZE)
|
||||||
|
)
|
@ -1,6 +1,7 @@
|
|||||||
import pygame
|
import pygame
|
||||||
|
|
||||||
import project_constants as const
|
import project_constants as const
|
||||||
|
from assets import asset_constants as asset
|
||||||
|
|
||||||
from mine_models.standard_mine import StandardMine
|
from mine_models.standard_mine import StandardMine
|
||||||
from mine_models.chained_mine import ChainedMine
|
from mine_models.chained_mine import ChainedMine
|
||||||
@ -12,15 +13,15 @@ from mine_models.time_mine import TimeMine
|
|||||||
# ================================= #
|
# ================================= #
|
||||||
|
|
||||||
tile_asset_options = {
|
tile_asset_options = {
|
||||||
"MUD": const.ASSET_MUD,
|
"MUD": asset.ASSET_MUD,
|
||||||
"GRASS": const.ASSET_GRASS,
|
"GRASS": asset.ASSET_GRASS,
|
||||||
"CONCRETE": const.ASSET_CONCRETE
|
"CONCRETE": asset.ASSET_CONCRETE
|
||||||
}
|
}
|
||||||
|
|
||||||
mine_asset_options = {
|
mine_asset_options = {
|
||||||
"MINE": const.ASSET_MINE,
|
"MINE": asset.ASSET_MINE,
|
||||||
"CHAINS": const.ASSET_CHAINS,
|
"CHAINS": asset.ASSET_CHAINS,
|
||||||
"TIME_MINE": const.ASSET_TIME_MINE,
|
"TIME_MINE": asset.ASSET_TIME_MINE,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -33,7 +34,7 @@ def blit_graphics(minefield):
|
|||||||
# background grid (fills frame with white, blits grid)
|
# background grid (fills frame with white, blits grid)
|
||||||
const.SCREEN.fill((255, 255, 255))
|
const.SCREEN.fill((255, 255, 255))
|
||||||
const.SCREEN.blit(
|
const.SCREEN.blit(
|
||||||
const.ASSET_BACKGROUND,
|
asset.ASSET_BACKGROUND,
|
||||||
(
|
(
|
||||||
const.V_SCREEN_PADDING,
|
const.V_SCREEN_PADDING,
|
||||||
const.V_SCREEN_PADDING
|
const.V_SCREEN_PADDING
|
||||||
@ -112,22 +113,22 @@ def display_sapper(coords, direction):
|
|||||||
|
|
||||||
if direction == const.Direction.UP:
|
if direction == const.Direction.UP:
|
||||||
const.SCREEN.blit(
|
const.SCREEN.blit(
|
||||||
const.ASSET_SAPPER,
|
asset.ASSET_SAPPER,
|
||||||
sapper_screen_coords
|
sapper_screen_coords
|
||||||
)
|
)
|
||||||
elif direction == const.Direction.RIGHT:
|
elif direction == const.Direction.RIGHT:
|
||||||
const.SCREEN.blit(
|
const.SCREEN.blit(
|
||||||
pygame.transform.rotate(const.ASSET_SAPPER, 270),
|
pygame.transform.rotate(asset.ASSET_SAPPER, 270),
|
||||||
sapper_screen_coords
|
sapper_screen_coords
|
||||||
)
|
)
|
||||||
elif direction == const.Direction.DOWN:
|
elif direction == const.Direction.DOWN:
|
||||||
const.SCREEN.blit(
|
const.SCREEN.blit(
|
||||||
pygame.transform.rotate(const.ASSET_SAPPER, 180),
|
pygame.transform.rotate(asset.ASSET_SAPPER, 180),
|
||||||
sapper_screen_coords
|
sapper_screen_coords
|
||||||
)
|
)
|
||||||
elif direction == const.Direction.LEFT:
|
elif direction == const.Direction.LEFT:
|
||||||
const.SCREEN.blit(
|
const.SCREEN.blit(
|
||||||
pygame.transform.rotate(const.ASSET_SAPPER, 90),
|
pygame.transform.rotate(asset.ASSET_SAPPER, 90),
|
||||||
sapper_screen_coords
|
sapper_screen_coords
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -139,21 +140,21 @@ def display_sapper(coords, direction):
|
|||||||
|
|
||||||
def display_concrete(coords):
|
def display_concrete(coords):
|
||||||
const.SCREEN.blit(
|
const.SCREEN.blit(
|
||||||
const.ASSET_CONCRETE,
|
asset.ASSET_CONCRETE,
|
||||||
calculate_screen_position(coords)
|
calculate_screen_position(coords)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def display_mud(coords):
|
def display_mud(coords):
|
||||||
const.SCREEN.blit(
|
const.SCREEN.blit(
|
||||||
const.ASSET_MUD,
|
asset.ASSET_MUD,
|
||||||
calculate_screen_position(coords)
|
calculate_screen_position(coords)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def display_grass(coords):
|
def display_grass(coords):
|
||||||
const.SCREEN.blit(
|
const.SCREEN.blit(
|
||||||
const.ASSET_GRASS,
|
asset.ASSET_GRASS,
|
||||||
calculate_screen_position(coords)
|
calculate_screen_position(coords)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -165,7 +166,7 @@ def display_grass(coords):
|
|||||||
|
|
||||||
def display_mine(coords):
|
def display_mine(coords):
|
||||||
const.SCREEN.blit(
|
const.SCREEN.blit(
|
||||||
const.ASSET_MINE,
|
asset.ASSET_MINE,
|
||||||
calculate_screen_position(coords)
|
calculate_screen_position(coords)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -173,35 +174,35 @@ def display_mine(coords):
|
|||||||
def display_chained_mine(coords, parent_coords=None):
|
def display_chained_mine(coords, parent_coords=None):
|
||||||
def display_number(which_coord, number):
|
def display_number(which_coord, number):
|
||||||
|
|
||||||
number_asset = const.ASSET_NUMBER_CHAINS_0
|
number_asset = asset.ASSET_NUMBER_CHAINS_0
|
||||||
if number == 1:
|
if number == 1:
|
||||||
number_asset = const.ASSET_NUMBER_CHAINS_1
|
number_asset = asset.ASSET_NUMBER_CHAINS_1
|
||||||
elif number == 3:
|
elif number == 3:
|
||||||
number_asset = const.ASSET_NUMBER_CHAINS_3
|
number_asset = asset.ASSET_NUMBER_CHAINS_3
|
||||||
elif number == 4:
|
elif number == 4:
|
||||||
number_asset = const.ASSET_NUMBER_CHAINS_4
|
number_asset = asset.ASSET_NUMBER_CHAINS_4
|
||||||
elif number == 5:
|
elif number == 5:
|
||||||
number_asset = const.ASSET_NUMBER_CHAINS_5
|
number_asset = asset.ASSET_NUMBER_CHAINS_5
|
||||||
elif number == 6:
|
elif number == 6:
|
||||||
number_asset = const.ASSET_NUMBER_CHAINS_6
|
number_asset = asset.ASSET_NUMBER_CHAINS_6
|
||||||
elif number == 7:
|
elif number == 7:
|
||||||
number_asset = const.ASSET_NUMBER_CHAINS_7
|
number_asset = asset.ASSET_NUMBER_CHAINS_7
|
||||||
elif number == 8:
|
elif number == 8:
|
||||||
number_asset = const.ASSET_NUMBER_CHAINS_8
|
number_asset = asset.ASSET_NUMBER_CHAINS_8
|
||||||
elif number == 9:
|
elif number == 9:
|
||||||
number_asset = const.ASSET_NUMBER_CHAINS_9
|
number_asset = asset.ASSET_NUMBER_CHAINS_9
|
||||||
elif number == 10:
|
elif number == 10:
|
||||||
number_asset = const.ASSET_NUMBER_CHAINS_10
|
number_asset = asset.ASSET_NUMBER_CHAINS_10
|
||||||
elif number == 11:
|
elif number == 11:
|
||||||
number_asset = const.ASSET_NUMBER_CHAINS_11
|
number_asset = asset.ASSET_NUMBER_CHAINS_11
|
||||||
elif number == 12:
|
elif number == 12:
|
||||||
number_asset = const.ASSET_NUMBER_CHAINS_12
|
number_asset = asset.ASSET_NUMBER_CHAINS_12
|
||||||
elif number == 13:
|
elif number == 13:
|
||||||
number_asset = const.ASSET_NUMBER_CHAINS_13
|
number_asset = asset.ASSET_NUMBER_CHAINS_13
|
||||||
elif number == 14:
|
elif number == 14:
|
||||||
number_asset = const.ASSET_NUMBER_CHAINS_14
|
number_asset = asset.ASSET_NUMBER_CHAINS_14
|
||||||
elif number == 15:
|
elif number == 15:
|
||||||
number_asset = const.ASSET_NUMBER_CHAINS_15
|
number_asset = asset.ASSET_NUMBER_CHAINS_15
|
||||||
|
|
||||||
mine_coords = calculate_screen_position(coords)
|
mine_coords = calculate_screen_position(coords)
|
||||||
number_coords = mine_coords
|
number_coords = mine_coords
|
||||||
@ -218,11 +219,17 @@ def display_chained_mine(coords, parent_coords=None):
|
|||||||
display_mine(coords)
|
display_mine(coords)
|
||||||
|
|
||||||
const.SCREEN.blit(
|
const.SCREEN.blit(
|
||||||
const.ASSET_CHAINS,
|
asset.ASSET_CHAINS,
|
||||||
calculate_screen_position(coords)
|
calculate_screen_position(coords)
|
||||||
)
|
)
|
||||||
|
|
||||||
if parent_coords is not None:
|
if parent_coords is not None:
|
||||||
|
|
||||||
|
const.SCREEN.blit(
|
||||||
|
asset.ASSET_CHAIN_COUNTER,
|
||||||
|
calculate_screen_position(coords)
|
||||||
|
)
|
||||||
|
|
||||||
display_number(const.Coords.X, parent_coords[0])
|
display_number(const.Coords.X, parent_coords[0])
|
||||||
display_number(const.Coords.Y, parent_coords[1])
|
display_number(const.Coords.Y, parent_coords[1])
|
||||||
|
|
||||||
@ -231,25 +238,25 @@ def display_time_mine(coords, time):
|
|||||||
|
|
||||||
def display_number(which_digit, number):
|
def display_number(which_digit, number):
|
||||||
|
|
||||||
number_asset = const.ASSET_NUMBER_TIME_0
|
number_asset = asset.ASSET_NUMBER_TIME_0
|
||||||
if number == 1:
|
if number == 1:
|
||||||
number_asset = const.ASSET_NUMBER_TIME_1
|
number_asset = asset.ASSET_NUMBER_TIME_1
|
||||||
elif number == 2:
|
elif number == 2:
|
||||||
number_asset = const.ASSET_NUMBER_TIME_2
|
number_asset = asset.ASSET_NUMBER_TIME_2
|
||||||
elif number == 3:
|
elif number == 3:
|
||||||
number_asset = const.ASSET_NUMBER_TIME_3
|
number_asset = asset.ASSET_NUMBER_TIME_3
|
||||||
elif number == 4:
|
elif number == 4:
|
||||||
number_asset = const.ASSET_NUMBER_TIME_4
|
number_asset = asset.ASSET_NUMBER_TIME_4
|
||||||
elif number == 5:
|
elif number == 5:
|
||||||
number_asset = const.ASSET_NUMBER_TIME_5
|
number_asset = asset.ASSET_NUMBER_TIME_5
|
||||||
elif number == 6:
|
elif number == 6:
|
||||||
number_asset = const.ASSET_NUMBER_TIME_6
|
number_asset = asset.ASSET_NUMBER_TIME_6
|
||||||
elif number == 7:
|
elif number == 7:
|
||||||
number_asset = const.ASSET_NUMBER_TIME_7
|
number_asset = asset.ASSET_NUMBER_TIME_7
|
||||||
elif number == 8:
|
elif number == 8:
|
||||||
number_asset = const.ASSET_NUMBER_TIME_8
|
number_asset = asset.ASSET_NUMBER_TIME_8
|
||||||
elif number == 9:
|
elif number == 9:
|
||||||
number_asset = const.ASSET_NUMBER_TIME_9
|
number_asset = asset.ASSET_NUMBER_TIME_9
|
||||||
|
|
||||||
mine_coords = calculate_screen_position(coords)
|
mine_coords = calculate_screen_position(coords)
|
||||||
number_coords = mine_coords
|
number_coords = mine_coords
|
||||||
@ -264,7 +271,7 @@ def display_time_mine(coords, time):
|
|||||||
)
|
)
|
||||||
|
|
||||||
const.SCREEN.blit(
|
const.SCREEN.blit(
|
||||||
const.ASSET_TIME_MINE,
|
asset.ASSET_TIME_MINE,
|
||||||
calculate_screen_position(coords)
|
calculate_screen_position(coords)
|
||||||
)
|
)
|
||||||
|
|
2
game.py
2
game.py
@ -2,7 +2,7 @@ from random import randint
|
|||||||
|
|
||||||
import project_constants as const
|
import project_constants as const
|
||||||
|
|
||||||
from display_assets import blit_graphics
|
from assets.display_assets import blit_graphics
|
||||||
from searching_algorithms import a_star
|
from searching_algorithms import a_star
|
||||||
|
|
||||||
from minefield import Minefield
|
from minefield import Minefield
|
||||||
|
@ -10,7 +10,7 @@ from ui.input_box import InputBox
|
|||||||
# STRUCT a list or other structure of values
|
# STRUCT a list or other structure of values
|
||||||
# FUNC a function
|
# FUNC a function
|
||||||
# OBJ a classes instance
|
# OBJ a classes instance
|
||||||
# ASSET a png file (or other graphic format)
|
# ASSET a png file (or other graphic format) (moved to asset_constants)
|
||||||
# MAP a JSON map file
|
# MAP a JSON map file
|
||||||
|
|
||||||
|
|
||||||
@ -19,9 +19,10 @@ from ui.input_box import InputBox
|
|||||||
# ================= #
|
# ================= #
|
||||||
|
|
||||||
V_NAME_OF_WINDOW = "MineFusion TM"
|
V_NAME_OF_WINDOW = "MineFusion TM"
|
||||||
DIR_ASSETS = os.path.join("resources", "assets")
|
|
||||||
V_FPS = 60
|
V_FPS = 60
|
||||||
|
|
||||||
|
DIR_ASSETS = os.path.join("resources", "assets")
|
||||||
|
|
||||||
TURN_INTERVAL = 0.3 # interval between two turns in seconds
|
TURN_INTERVAL = 0.3 # interval between two turns in seconds
|
||||||
|
|
||||||
V_TILE_SIZE = 60
|
V_TILE_SIZE = 60
|
||||||
@ -211,248 +212,4 @@ OK_BUTTON = Button(
|
|||||||
|
|
||||||
MAP_RANDOM_10x10 = os.path.join("resources", "minefields", "fourthmap.json")
|
MAP_RANDOM_10x10 = os.path.join("resources", "minefields", "fourthmap.json")
|
||||||
|
|
||||||
# ============== #
|
|
||||||
# === ASSETS === #
|
|
||||||
# ============== #
|
|
||||||
|
|
||||||
ASSET_BACKGROUND = pygame.transform.scale(
|
|
||||||
pygame.image.load(os.path.join(DIR_ASSETS, "numbered_grid.png")),
|
|
||||||
(650, 650)
|
|
||||||
)
|
|
||||||
|
|
||||||
ASSET_SAPPER = pygame.transform.scale(
|
|
||||||
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(DIR_ASSETS, "brick_wall.png")),
|
|
||||||
(V_TILE_SIZE, V_TILE_SIZE)
|
|
||||||
)
|
|
||||||
|
|
||||||
ASSET_CONCRETE = pygame.transform.scale(
|
|
||||||
pygame.image.load(os.path.join(DIR_ASSETS, "concrete.png")),
|
|
||||||
(V_TILE_SIZE, V_TILE_SIZE)
|
|
||||||
)
|
|
||||||
|
|
||||||
ASSET_MUD = pygame.transform.scale(
|
|
||||||
pygame.image.load(os.path.join(DIR_ASSETS, "mud.png")),
|
|
||||||
(V_TILE_SIZE, V_TILE_SIZE)
|
|
||||||
)
|
|
||||||
|
|
||||||
ASSET_GRASS = pygame.transform.scale(
|
|
||||||
pygame.image.load(os.path.join(DIR_ASSETS, "grass.png")),
|
|
||||||
(V_TILE_SIZE, V_TILE_SIZE)
|
|
||||||
)
|
|
||||||
|
|
||||||
ASSET_MINE = pygame.transform.scale(
|
|
||||||
pygame.image.load(os.path.join(DIR_ASSETS, "mine.png")),
|
|
||||||
(V_TILE_SIZE, V_TILE_SIZE)
|
|
||||||
)
|
|
||||||
|
|
||||||
ASSET_CHAINS = pygame.transform.scale(
|
|
||||||
pygame.image.load(os.path.join(DIR_ASSETS, "chains.png")),
|
|
||||||
(V_TILE_SIZE, V_TILE_SIZE)
|
|
||||||
)
|
|
||||||
|
|
||||||
ASSET_TIME_MINE = pygame.transform.scale(
|
|
||||||
pygame.image.load(os.path.join(DIR_ASSETS, "time_mine.png")),
|
|
||||||
(V_TILE_SIZE, V_TILE_SIZE)
|
|
||||||
)
|
|
||||||
|
|
||||||
# ==================== #
|
|
||||||
# === TIME NUMBERS === #
|
|
||||||
# ==================== #
|
|
||||||
|
|
||||||
ASSET_NUMBER_TIME_0 = pygame.transform.scale(
|
|
||||||
pygame.image.load(os.path.join(DIR_ASSETS, "time_numbers/time_number_0.png")),
|
|
||||||
(6, 16)
|
|
||||||
)
|
|
||||||
|
|
||||||
ASSET_NUMBER_TIME_1 = pygame.transform.scale(
|
|
||||||
pygame.image.load(os.path.join(DIR_ASSETS, "time_numbers/time_number_1.png")),
|
|
||||||
(6, 16)
|
|
||||||
)
|
|
||||||
|
|
||||||
ASSET_NUMBER_TIME_2 = pygame.transform.scale(
|
|
||||||
pygame.image.load(os.path.join(DIR_ASSETS, "time_numbers/time_number_2.png")),
|
|
||||||
(6, 16)
|
|
||||||
)
|
|
||||||
|
|
||||||
ASSET_NUMBER_TIME_3 = pygame.transform.scale(
|
|
||||||
pygame.image.load(os.path.join(DIR_ASSETS, "time_numbers/time_number_3.png")),
|
|
||||||
(6, 16)
|
|
||||||
)
|
|
||||||
|
|
||||||
ASSET_NUMBER_TIME_4 = pygame.transform.scale(
|
|
||||||
pygame.image.load(os.path.join(DIR_ASSETS, "time_numbers/time_number_4.png")),
|
|
||||||
(6, 16)
|
|
||||||
)
|
|
||||||
|
|
||||||
ASSET_NUMBER_TIME_5 = pygame.transform.scale(
|
|
||||||
pygame.image.load(os.path.join(DIR_ASSETS, "time_numbers/time_number_5.png")),
|
|
||||||
(6, 16)
|
|
||||||
)
|
|
||||||
|
|
||||||
ASSET_NUMBER_TIME_6 = pygame.transform.scale(
|
|
||||||
pygame.image.load(os.path.join(DIR_ASSETS, "time_numbers/time_number_6.png")),
|
|
||||||
(6, 16)
|
|
||||||
)
|
|
||||||
|
|
||||||
ASSET_NUMBER_TIME_7 = pygame.transform.scale(
|
|
||||||
pygame.image.load(os.path.join(DIR_ASSETS, "time_numbers/time_number_7.png")),
|
|
||||||
(6, 16)
|
|
||||||
)
|
|
||||||
|
|
||||||
ASSET_NUMBER_TIME_8 = pygame.transform.scale(
|
|
||||||
pygame.image.load(os.path.join(DIR_ASSETS, "time_numbers/time_number_8.png")),
|
|
||||||
(6, 16)
|
|
||||||
)
|
|
||||||
|
|
||||||
ASSET_NUMBER_TIME_9 = pygame.transform.scale(
|
|
||||||
pygame.image.load(os.path.join(DIR_ASSETS, "time_numbers/time_number_9.png")),
|
|
||||||
(6, 16)
|
|
||||||
)
|
|
||||||
|
|
||||||
# ====================== #
|
|
||||||
# === CHAINS NUMBERS === #
|
|
||||||
# ====================== #
|
|
||||||
|
|
||||||
ASSET_NUMBER_CHAINS_0 = pygame.transform.scale(
|
|
||||||
pygame.image.load(os.path.join(DIR_ASSETS, "chain_numbers/chain_number_0.png")),
|
|
||||||
(6, 12)
|
|
||||||
)
|
|
||||||
|
|
||||||
ASSET_NUMBER_CHAINS_1 = pygame.transform.scale(
|
|
||||||
pygame.image.load(os.path.join(DIR_ASSETS, "chain_numbers/chain_number_1.png")),
|
|
||||||
(6, 12)
|
|
||||||
)
|
|
||||||
|
|
||||||
ASSET_NUMBER_CHAINS_2 = pygame.transform.scale(
|
|
||||||
pygame.image.load(os.path.join(DIR_ASSETS, "chain_numbers/chain_number_2.png")),
|
|
||||||
(6, 12)
|
|
||||||
)
|
|
||||||
|
|
||||||
ASSET_NUMBER_CHAINS_3 = pygame.transform.scale(
|
|
||||||
pygame.image.load(os.path.join(DIR_ASSETS, "chain_numbers/chain_number_3.png")),
|
|
||||||
(6, 12)
|
|
||||||
)
|
|
||||||
|
|
||||||
ASSET_NUMBER_CHAINS_4 = pygame.transform.scale(
|
|
||||||
pygame.image.load(os.path.join(DIR_ASSETS, "chain_numbers/chain_number_4.png")),
|
|
||||||
(6, 12)
|
|
||||||
)
|
|
||||||
|
|
||||||
ASSET_NUMBER_CHAINS_5 = pygame.transform.scale(
|
|
||||||
pygame.image.load(os.path.join(DIR_ASSETS, "chain_numbers/chain_number_5.png")),
|
|
||||||
(6, 12)
|
|
||||||
)
|
|
||||||
|
|
||||||
ASSET_NUMBER_CHAINS_6 = pygame.transform.scale(
|
|
||||||
pygame.image.load(os.path.join(DIR_ASSETS, "chain_numbers/chain_number_6.png")),
|
|
||||||
(6, 12)
|
|
||||||
)
|
|
||||||
|
|
||||||
ASSET_NUMBER_CHAINS_7 = pygame.transform.scale(
|
|
||||||
pygame.image.load(os.path.join(DIR_ASSETS, "chain_numbers/chain_number_7.png")),
|
|
||||||
(6, 12)
|
|
||||||
)
|
|
||||||
|
|
||||||
ASSET_NUMBER_CHAINS_8 = pygame.transform.scale(
|
|
||||||
pygame.image.load(os.path.join(DIR_ASSETS, "chain_numbers/chain_number_8.png")),
|
|
||||||
(6, 12)
|
|
||||||
)
|
|
||||||
|
|
||||||
ASSET_NUMBER_CHAINS_9 = pygame.transform.scale(
|
|
||||||
pygame.image.load(os.path.join(DIR_ASSETS, "chain_numbers/chain_number_9.png")),
|
|
||||||
(6, 12)
|
|
||||||
)
|
|
||||||
|
|
||||||
ASSET_NUMBER_CHAINS_10 = pygame.transform.scale(
|
|
||||||
pygame.image.load(os.path.join(DIR_ASSETS, "chain_numbers/chain_number_10.png")),
|
|
||||||
(6, 12)
|
|
||||||
)
|
|
||||||
|
|
||||||
ASSET_NUMBER_CHAINS_11 = pygame.transform.scale(
|
|
||||||
pygame.image.load(os.path.join(DIR_ASSETS, "chain_numbers/chain_number_11.png")),
|
|
||||||
(6, 12)
|
|
||||||
)
|
|
||||||
|
|
||||||
ASSET_NUMBER_CHAINS_12 = pygame.transform.scale(
|
|
||||||
pygame.image.load(os.path.join(DIR_ASSETS, "chain_numbers/chain_number_12.png")),
|
|
||||||
(6, 12)
|
|
||||||
)
|
|
||||||
|
|
||||||
ASSET_NUMBER_CHAINS_13 = pygame.transform.scale(
|
|
||||||
pygame.image.load(os.path.join(DIR_ASSETS, "chain_numbers/chain_number_13.png")),
|
|
||||||
(6, 12)
|
|
||||||
)
|
|
||||||
|
|
||||||
ASSET_NUMBER_CHAINS_14 = pygame.transform.scale(
|
|
||||||
pygame.image.load(os.path.join(DIR_ASSETS, "chain_numbers/chain_number_14.png")),
|
|
||||||
(6, 12)
|
|
||||||
)
|
|
||||||
|
|
||||||
ASSET_NUMBER_CHAINS_15 = pygame.transform.scale(
|
|
||||||
pygame.image.load(os.path.join(DIR_ASSETS, "chain_numbers/chain_number_15.png")),
|
|
||||||
(6, 12)
|
|
||||||
)
|
|
||||||
|
|
||||||
# ================== #
|
|
||||||
# === OLD ASSETS === #
|
|
||||||
# ================== #
|
|
||||||
|
|
||||||
ASSET_MINE_A = pygame.transform.scale(
|
|
||||||
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(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(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(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(DIR_ASSETS, "old_tiles/tile_orange.png")),
|
|
||||||
(V_TILE_SIZE, V_TILE_SIZE)
|
|
||||||
)
|
|
||||||
|
|
||||||
ASSET_TILE_RED = pygame.transform.scale(
|
|
||||||
pygame.image.load(os.path.join(DIR_ASSETS, "old_tiles/tile_red.png")),
|
|
||||||
(V_TILE_SIZE, V_TILE_SIZE)
|
|
||||||
)
|
|
||||||
|
|
||||||
ASSET_TILE_BLUE = pygame.transform.scale(
|
|
||||||
pygame.image.load(os.path.join(DIR_ASSETS, "old_tiles/tile_blue.png")),
|
|
||||||
(V_TILE_SIZE, V_TILE_SIZE)
|
|
||||||
)
|
|
||||||
|
|
||||||
ASSET_TILE_PURPLE = pygame.transform.scale(
|
|
||||||
pygame.image.load(os.path.join(DIR_ASSETS, "old_tiles/tile_purple.png")),
|
|
||||||
(V_TILE_SIZE, V_TILE_SIZE)
|
|
||||||
)
|
|
||||||
|
|
||||||
ASSET_TILE_GREEN = pygame.transform.scale(
|
|
||||||
pygame.image.load(os.path.join(DIR_ASSETS, "old_tiles/tile_green.png")),
|
|
||||||
(V_TILE_SIZE, V_TILE_SIZE)
|
|
||||||
)
|
|
||||||
|
|
||||||
ASSET_TILE_YELLOW = pygame.transform.scale(
|
|
||||||
pygame.image.load(os.path.join(DIR_ASSETS, "old_tiles/tile_yellow.png")),
|
|
||||||
(V_TILE_SIZE, V_TILE_SIZE)
|
|
||||||
)
|
|
||||||
|
|
||||||
ASSET_TILE_WHITE = pygame.transform.scale(
|
|
||||||
pygame.image.load(os.path.join(DIR_ASSETS, "old_tiles/tile_white.png")),
|
|
||||||
(V_TILE_SIZE, V_TILE_SIZE)
|
|
||||||
)
|
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 325 B After Width: | Height: | Size: 248 B |
Binary file not shown.
Before Width: | Height: | Size: 196 B After Width: | Height: | Size: 196 B |
Binary file not shown.
Before Width: | Height: | Size: 301 B After Width: | Height: | Size: 296 B |
Loading…
Reference in New Issue
Block a user