153 lines
4.2 KiB
Python
153 lines
4.2 KiB
Python
import pygame
|
|
import os
|
|
|
|
# VARIABLE STARTS WITH ... IF IT'S
|
|
# V a value like a string or an int
|
|
# STRUCT a list or other structure of values
|
|
# ASSET a png file (or other graphic format)
|
|
# MAP a JSON map file
|
|
|
|
|
|
# ================= #
|
|
# === VARIABLES === #
|
|
# ================= #
|
|
|
|
V_NAME_OF_WINDOW = "MineFusion TM"
|
|
ASSETS_DIR = os.path.join("resources", "assets")
|
|
V_FPS = 60
|
|
|
|
V_TILE_SIZE = 60
|
|
V_GRID_VER_TILES = V_GRID_HOR_TILES = 10 # vertical (number of rows), horizontal (number of columns)
|
|
V_SCREEN_PADDING = 10
|
|
V_MINEFIELD_HEIGHT = V_TILE_SIZE * V_GRID_VER_TILES
|
|
V_MINEFIELD_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
|
|
)
|
|
)
|
|
|
|
# =============== #
|
|
# === STRUCTS === #
|
|
# =============== #
|
|
|
|
# # NORMAL STRUCTS
|
|
|
|
# # USED BY JSON GENERATOR
|
|
|
|
# used to generate random tile colors
|
|
STRUCT_TILE_COLORS = ["BLUE", "GREEN", "ORANGE", "PURPLE", "RED", "WHITE", "YELLOW"]
|
|
|
|
# used to generate random mines and create not random mines
|
|
STRUCT_MINE_TYPES = ["standard", "chained", "time"]
|
|
STRUCT_MINE_ASSET_TYPES = ['A', 'B', 'F', 'K']
|
|
|
|
# values that are predefined for certain mine types and can't be changed by changing any parameters
|
|
# put here all dict keys that have hardcoded values and are not supposed to be editable
|
|
HARDCODED_VALUES = ["asset", "mine_type"]
|
|
|
|
# default values and key-value pairs for JsonGenerator class
|
|
# when defining a new mine it's dict template must be put here
|
|
STRUCT_MINE_ATTRIBUTES = {
|
|
"standard": {
|
|
"asset": STRUCT_MINE_ASSET_TYPES.__getitem__(0),
|
|
"mine_type": "standard"
|
|
},
|
|
"chained": {
|
|
"asset": STRUCT_MINE_ASSET_TYPES.__getitem__(1),
|
|
"mine_type": "chained",
|
|
"predecessor": None
|
|
},
|
|
"time": {
|
|
"asset": STRUCT_MINE_ASSET_TYPES.__getitem__(2),
|
|
"mine_type": "time",
|
|
"timer": None
|
|
}
|
|
}
|
|
|
|
# types of attributes the mines have
|
|
# used for random mine generation
|
|
# int - integral number
|
|
# (int, int) - index "row,column" where row=int and column=int (used exclusively for chained mine)
|
|
STRUCT_MINE_ATTRIBUTE_TYPES = {
|
|
"standard": [],
|
|
"chained": [],
|
|
"time": [int]
|
|
}
|
|
|
|
# ============== #
|
|
# ==== MAPS ==== #
|
|
# ============== #
|
|
MAP_RANDOM_10x10 = os.path.join("resources", "minefields", "secondmap.json")
|
|
|
|
# ============== #
|
|
# === ASSETS === #
|
|
# ============== #
|
|
|
|
ASSET_BACKGROUND = pygame.transform.scale(
|
|
pygame.image.load(os.path.join(ASSETS_DIR, "new_grid.png")),
|
|
(V_MINEFIELD_WIDTH, V_MINEFIELD_WIDTH)
|
|
)
|
|
|
|
ASSET_SAPPER = pygame.transform.scale(
|
|
pygame.image.load(os.path.join(ASSETS_DIR, "sapper.png")),
|
|
(V_TILE_SIZE, V_TILE_SIZE)
|
|
)
|
|
|
|
ASSET_MINE_A = pygame.transform.scale(
|
|
pygame.image.load(os.path.join(ASSETS_DIR, "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")),
|
|
(V_TILE_SIZE, V_TILE_SIZE)
|
|
)
|
|
|
|
ASSET_MINE_F = pygame.transform.scale(
|
|
pygame.image.load(os.path.join(ASSETS_DIR, "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")),
|
|
(V_TILE_SIZE, V_TILE_SIZE)
|
|
)
|
|
|
|
ASSET_TILE_ORANGE = pygame.transform.scale(
|
|
pygame.image.load(os.path.join(ASSETS_DIR, "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")),
|
|
(V_TILE_SIZE, V_TILE_SIZE)
|
|
)
|
|
|
|
ASSET_TILE_BLUE = pygame.transform.scale(
|
|
pygame.image.load(os.path.join(ASSETS_DIR, "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")),
|
|
(V_TILE_SIZE, V_TILE_SIZE)
|
|
)
|
|
|
|
ASSET_TILE_GREEN = pygame.transform.scale(
|
|
pygame.image.load(os.path.join(ASSETS_DIR, "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")),
|
|
(V_TILE_SIZE, V_TILE_SIZE)
|
|
)
|
|
|
|
ASSET_TILE_WHITE = pygame.transform.scale(
|
|
pygame.image.load(os.path.join(ASSETS_DIR, "tile_white.png")),
|
|
(V_TILE_SIZE, V_TILE_SIZE)
|
|
)
|