2021-03-11 00:47:14 +01:00
|
|
|
import pygame
|
2021-03-12 11:45:27 +01:00
|
|
|
import os
|
2021-03-11 00:47:14 +01:00
|
|
|
|
|
|
|
# VARIABLE STARTS WITH ... IF IT'S
|
|
|
|
# V a value like a string or an int
|
2021-03-12 20:48:16 +01:00
|
|
|
# STRUCT a list or other structure of values
|
2021-03-11 00:47:14 +01:00
|
|
|
# ASSET a png file (or other graphic format)
|
2021-03-12 21:25:33 +01:00
|
|
|
# MAP a JSON map file
|
2021-03-11 00:47:14 +01:00
|
|
|
|
|
|
|
|
2021-03-11 18:51:43 +01:00
|
|
|
# ================= #
|
|
|
|
# === VARIABLES === #
|
|
|
|
# ================= #
|
|
|
|
|
2021-03-11 00:47:14 +01:00
|
|
|
V_NAME_OF_WINDOW = "MineFusion TM"
|
2021-03-12 11:45:27 +01:00
|
|
|
ASSETS_DIR = os.path.join("resources", "assets")
|
2021-03-16 06:41:40 +01:00
|
|
|
V_FPS = 60
|
2021-03-11 00:47:14 +01:00
|
|
|
|
|
|
|
V_TILE_SIZE = 60
|
2021-03-14 18:27:12 +01:00
|
|
|
V_GRID_VER_TILES = V_GRID_HOR_TILES = 10 # vertical, horizontal
|
2021-03-11 00:47:14 +01:00
|
|
|
V_SCREEN_PADDING = 10
|
2021-03-12 09:55:59 +01:00
|
|
|
V_MINEFIELD_HEIGHT = V_TILE_SIZE * V_GRID_VER_TILES
|
|
|
|
V_MINEFIELD_WIDTH = V_TILE_SIZE * V_GRID_HOR_TILES
|
2021-03-11 00:47:14 +01:00
|
|
|
|
2021-03-14 18:27:12 +01:00
|
|
|
SCREEN = pygame.display.set_mode(
|
2021-03-11 00:47:14 +01:00
|
|
|
(
|
|
|
|
V_TILE_SIZE * V_GRID_HOR_TILES + 2 * V_SCREEN_PADDING, # screen width
|
2021-03-14 18:27:12 +01:00
|
|
|
V_TILE_SIZE * V_GRID_HOR_TILES + 2 * V_SCREEN_PADDING # screen height
|
2021-03-11 00:47:14 +01:00
|
|
|
)
|
|
|
|
)
|
|
|
|
|
2021-03-12 20:48:16 +01:00
|
|
|
# =============== #
|
|
|
|
# === STRUCTS === #
|
|
|
|
# =============== #
|
|
|
|
|
2021-03-27 18:22:04 +01:00
|
|
|
# # NORMAL STRUCTS
|
|
|
|
|
|
|
|
# # USED BY JSON GENERATOR
|
2021-03-27 18:30:46 +01:00
|
|
|
|
2021-03-27 18:22:04 +01:00
|
|
|
# used to generate random tile colors
|
2021-03-14 00:59:00 +01:00
|
|
|
STRUCT_TILE_COLORS = ["BLUE", "GREEN", "ORANGE", "PURPLE", "RED", "WHITE", "YELLOW"]
|
2021-03-27 18:30:46 +01:00
|
|
|
|
2021-03-27 18:22:04 +01:00
|
|
|
# used to generate random mines and create not random mines
|
|
|
|
STRUCT_MINE_TYPES = ["standard", "chained", "time"]
|
|
|
|
STRUCT_MINE_ASSET_TYPES = ['A', 'B', 'F', 'K']
|
2021-03-27 18:30:46 +01:00
|
|
|
|
2021-03-27 18:22:04 +01:00
|
|
|
# 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"]
|
2021-03-27 18:30:46 +01:00
|
|
|
|
2021-03-27 18:22:04 +01:00
|
|
|
# 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
|
|
|
|
}
|
|
|
|
}
|
2021-03-27 18:30:46 +01:00
|
|
|
|
2021-03-27 18:22:04 +01:00
|
|
|
# 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": [(int, int)],
|
|
|
|
"time": [int]
|
|
|
|
}
|
2021-03-12 20:48:16 +01:00
|
|
|
|
2021-03-12 21:25:33 +01:00
|
|
|
# ============== #
|
|
|
|
# ==== MAPS ==== #
|
|
|
|
# ============== #
|
|
|
|
MAP_RANDOM_10x10 = os.path.join("resources", "minefields", "firstmap.json")
|
|
|
|
|
2021-03-11 18:51:43 +01:00
|
|
|
# ============== #
|
|
|
|
# === ASSETS === #
|
|
|
|
# ============== #
|
|
|
|
|
2021-03-14 18:27:12 +01:00
|
|
|
ASSET_BACKGROUND = pygame.transform.scale(
|
2021-03-12 11:45:27 +01:00
|
|
|
pygame.image.load(os.path.join(ASSETS_DIR, "new_grid.png")),
|
2021-03-12 09:55:59 +01:00
|
|
|
(V_MINEFIELD_WIDTH, V_MINEFIELD_WIDTH)
|
2021-03-11 18:51:43 +01:00
|
|
|
)
|
|
|
|
|
2021-03-14 18:27:12 +01:00
|
|
|
ASSET_SAPPER = pygame.transform.scale(
|
2021-03-12 11:45:27 +01:00
|
|
|
pygame.image.load(os.path.join(ASSETS_DIR, "sapper.png")),
|
2021-03-12 09:55:59 +01:00
|
|
|
(V_TILE_SIZE, V_TILE_SIZE)
|
2021-03-11 18:51:43 +01:00
|
|
|
)
|
|
|
|
|
2021-03-14 18:27:12 +01:00
|
|
|
ASSET_MINE_A = pygame.transform.scale(
|
2021-03-12 11:45:27 +01:00
|
|
|
pygame.image.load(os.path.join(ASSETS_DIR, "mine_a.png")),
|
2021-03-12 09:55:59 +01:00
|
|
|
(V_TILE_SIZE, V_TILE_SIZE)
|
2021-03-11 18:51:43 +01:00
|
|
|
)
|
|
|
|
|
2021-03-14 18:27:12 +01:00
|
|
|
ASSET_MINE_B = pygame.transform.scale(
|
2021-03-12 11:45:27 +01:00
|
|
|
pygame.image.load(os.path.join(ASSETS_DIR, "mine_b.png")),
|
2021-03-12 09:55:59 +01:00
|
|
|
(V_TILE_SIZE, V_TILE_SIZE)
|
2021-03-11 18:51:43 +01:00
|
|
|
)
|
|
|
|
|
2021-03-14 18:27:12 +01:00
|
|
|
ASSET_MINE_F = pygame.transform.scale(
|
2021-03-12 11:45:27 +01:00
|
|
|
pygame.image.load(os.path.join(ASSETS_DIR, "mine_f.png")),
|
2021-03-12 09:55:59 +01:00
|
|
|
(V_TILE_SIZE, V_TILE_SIZE)
|
2021-03-11 18:51:43 +01:00
|
|
|
)
|
|
|
|
|
2021-03-14 18:27:12 +01:00
|
|
|
ASSET_MINE_K = pygame.transform.scale(
|
2021-03-12 11:45:27 +01:00
|
|
|
pygame.image.load(os.path.join(ASSETS_DIR, "mine_k.png")),
|
2021-03-12 09:55:59 +01:00
|
|
|
(V_TILE_SIZE, V_TILE_SIZE)
|
2021-03-11 18:51:43 +01:00
|
|
|
)
|
|
|
|
|
2021-03-14 18:27:12 +01:00
|
|
|
ASSET_TILE_ORANGE = pygame.transform.scale(
|
2021-03-12 11:45:27 +01:00
|
|
|
pygame.image.load(os.path.join(ASSETS_DIR, "tile_orange.png")),
|
2021-03-12 09:55:59 +01:00
|
|
|
(V_TILE_SIZE, V_TILE_SIZE)
|
2021-03-11 18:51:43 +01:00
|
|
|
)
|
|
|
|
|
2021-03-14 18:27:12 +01:00
|
|
|
ASSET_TILE_RED = pygame.transform.scale(
|
2021-03-12 11:45:27 +01:00
|
|
|
pygame.image.load(os.path.join(ASSETS_DIR, "tile_red.png")),
|
2021-03-12 09:55:59 +01:00
|
|
|
(V_TILE_SIZE, V_TILE_SIZE)
|
2021-03-11 18:51:43 +01:00
|
|
|
)
|
|
|
|
|
2021-03-14 18:27:12 +01:00
|
|
|
ASSET_TILE_BLUE = pygame.transform.scale(
|
2021-03-12 11:45:27 +01:00
|
|
|
pygame.image.load(os.path.join(ASSETS_DIR, "tile_blue.png")),
|
2021-03-12 09:55:59 +01:00
|
|
|
(V_TILE_SIZE, V_TILE_SIZE)
|
2021-03-11 18:51:43 +01:00
|
|
|
)
|
|
|
|
|
2021-03-14 18:27:12 +01:00
|
|
|
ASSET_TILE_PURPLE = pygame.transform.scale(
|
2021-03-12 11:45:27 +01:00
|
|
|
pygame.image.load(os.path.join(ASSETS_DIR, "tile_purple.png")),
|
2021-03-12 09:55:59 +01:00
|
|
|
(V_TILE_SIZE, V_TILE_SIZE)
|
2021-03-11 18:51:43 +01:00
|
|
|
)
|
|
|
|
|
2021-03-14 18:27:12 +01:00
|
|
|
ASSET_TILE_GREEN = pygame.transform.scale(
|
2021-03-12 11:45:27 +01:00
|
|
|
pygame.image.load(os.path.join(ASSETS_DIR, "tile_green.png")),
|
2021-03-12 09:55:59 +01:00
|
|
|
(V_TILE_SIZE, V_TILE_SIZE)
|
2021-03-11 18:51:43 +01:00
|
|
|
)
|
|
|
|
|
2021-03-14 18:27:12 +01:00
|
|
|
ASSET_TILE_YELLOW = pygame.transform.scale(
|
2021-03-12 11:45:27 +01:00
|
|
|
pygame.image.load(os.path.join(ASSETS_DIR, "tile_yellow.png")),
|
2021-03-12 09:55:59 +01:00
|
|
|
(V_TILE_SIZE, V_TILE_SIZE)
|
2021-03-11 18:51:43 +01:00
|
|
|
)
|
|
|
|
|
2021-03-14 18:27:12 +01:00
|
|
|
ASSET_TILE_WHITE = pygame.transform.scale(
|
2021-03-12 11:45:27 +01:00
|
|
|
pygame.image.load(os.path.join(ASSETS_DIR, "tile_white.png")),
|
2021-03-12 09:55:59 +01:00
|
|
|
(V_TILE_SIZE, V_TILE_SIZE)
|
2021-03-14 18:27:12 +01:00
|
|
|
)
|