Projekt_Sztuczna_Inteligencja/project_constants.py

372 lines
9.5 KiB
Python
Raw Normal View History

import pygame
2021-03-12 11:45:27 +01:00
import os
2021-04-14 23:45:34 +02:00
from enum import Enum
# 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
2021-03-11 18:51:43 +01:00
# ================= #
# === VARIABLES === #
# ================= #
V_NAME_OF_WINDOW = "MineFusion TM"
2021-05-02 21:04:41 +02:00
DIR_ASSETS = os.path.join("resources", "assets")
2021-03-16 06:41:40 +01:00
V_FPS = 60
ACTION_INTERVAL = 1 # interval between two actions in seconds
V_TILE_SIZE = 60
2021-05-02 21:04:41 +02:00
V_GRID_VER_TILES = 10 # vertical (number of rows)
V_GRID_HOR_TILES = 10 # horizontal (number of columns)
V_SCREEN_PADDING = 10
2021-05-02 21:04:41 +02:00
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(
(
2021-05-02 21:04:41 +02:00
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
)
)
2021-04-14 23:45:34 +02:00
# =============== #
# ==== ENUMS ==== #
# =============== #
class Direction(Enum):
2021-04-17 16:45:20 +02:00
UP = 0
RIGHT = 1
DOWN = 2
LEFT = 3
def next(self):
v = (self.value + 1) % 4
return Direction(v)
2021-05-02 21:04:41 +02:00
def previous(self):
v = (self.value - 1) % 4
return Direction(v)
2021-04-14 23:45:34 +02:00
class Action(Enum):
2021-04-17 16:45:20 +02:00
ROTATE_LEFT = 0
ROTATE_RIGHT = 1
GO = 2
2021-04-14 23:45:34 +02:00
class Digit(Enum):
ONES = 0
TENS = 1
class Coords(Enum):
X = 0
Y = 1
# =============== #
# === STRUCTS === #
# =============== #
# # NORMAL STRUCTS
# # USED BY JSON GENERATOR
2021-03-27 18:30:46 +01:00
# used to generate random tile colors
STRUCT_TILE_COLORS = ["BLUE", "GREEN", "ORANGE", "PURPLE", "RED", "WHITE", "YELLOW"]
2021-03-27 18:30:46 +01:00
# used to generate random mines and create not random mines
STRUCT_MINE_TYPES = ["standard", "chained", "time"]
2021-03-27 18:30:46 +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 = ["mine_type"]
2021-03-27 18:30:46 +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": {
"mine_type": "standard"
},
"chained": {
"mine_type": "chained",
"predecessor": None
},
"time": {
"mine_type": "time",
"timer": None
}
}
2021-03-27 18:30:46 +01:00
# types of attributes the mines have
# used for random mine generation
# int - integral number
STRUCT_MINE_ATTRIBUTE_TYPES = {
"standard": [],
"chained": [],
"time": [int]
}
# ============== #
# ==== MAPS ==== #
# ============== #
2021-04-14 12:01:20 +02:00
MAP_RANDOM_10x10 = os.path.join("resources", "minefields", "secondmap.json")
2021-03-11 18:51:43 +01:00
# ============== #
# === ASSETS === #
# ============== #
ASSET_BACKGROUND = pygame.transform.scale(
2021-05-02 21:04:41 +02:00
pygame.image.load(os.path.join(DIR_ASSETS, "numbered_grid.png")),
(650, 650)
2021-03-11 18:51:43 +01:00
)
ASSET_SAPPER = pygame.transform.scale(
2021-05-02 21:04:41 +02:00
pygame.image.load(os.path.join(DIR_ASSETS, "robot_sapper.png")),
2021-04-14 12:01:20 +02:00
(V_TILE_SIZE, V_TILE_SIZE)
)
ASSET_WALL = pygame.transform.scale(
2021-05-02 21:04:41 +02:00
pygame.image.load(os.path.join(DIR_ASSETS, "brick_wall.png")),
2021-03-12 09:55:59 +01:00
(V_TILE_SIZE, V_TILE_SIZE)
2021-03-11 18:51:43 +01:00
)
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")),
2021-03-12 09:55:59 +01:00
(V_TILE_SIZE, V_TILE_SIZE)
2021-03-11 18:51:43 +01:00
)
ASSET_MINE_B = pygame.transform.scale(
pygame.image.load(os.path.join(DIR_ASSETS, "simple_assets/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
)
ASSET_MINE_F = pygame.transform.scale(
pygame.image.load(os.path.join(DIR_ASSETS, "simple_assets/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
)
ASSET_MINE_K = pygame.transform.scale(
pygame.image.load(os.path.join(DIR_ASSETS, "simple_assets/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
)
ASSET_TILE_ORANGE = pygame.transform.scale(
pygame.image.load(os.path.join(DIR_ASSETS, "old_tiles/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
)
ASSET_TILE_RED = pygame.transform.scale(
pygame.image.load(os.path.join(DIR_ASSETS, "old_tiles/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
)
ASSET_TILE_BLUE = pygame.transform.scale(
pygame.image.load(os.path.join(DIR_ASSETS, "old_tiles/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
)
ASSET_TILE_PURPLE = pygame.transform.scale(
pygame.image.load(os.path.join(DIR_ASSETS, "old_tiles/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
)
ASSET_TILE_GREEN = pygame.transform.scale(
pygame.image.load(os.path.join(DIR_ASSETS, "old_tiles/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
)
ASSET_TILE_YELLOW = pygame.transform.scale(
pygame.image.load(os.path.join(DIR_ASSETS, "old_tiles/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
)
ASSET_TILE_WHITE = pygame.transform.scale(
pygame.image.load(os.path.join(DIR_ASSETS, "old_tiles/tile_white.png")),
2021-03-12 09:55:59 +01:00
(V_TILE_SIZE, V_TILE_SIZE)
)