Separated scene logic from game logic

This commit is contained in:
duckduckdoof 2025-02-04 14:43:54 -05:00
parent 0c8bc99b90
commit f993cccf1f
5 changed files with 22 additions and 10 deletions

68
lib/scene/scene_config.py Normal file
View file

@ -0,0 +1,68 @@
"""
scene_config.py
author: Caleb Scott
Configuration file for modifying the visual scene of the game.
This is not the same as game_config.py, which is used to adjust
game objects (apart from their visuals, like sprites)
"""
# CONSTANTS ---------------------------------------------------------
# Sizing
TILE_SCALE = 1.0
# Screen constants
SCREEN_WIDTH = 960
SCREEN_HEIGHT = 960
SCREEN_TITLE = "Miniopolis Demo"
# World size
WORLD_WIDTH = 960
WORLD_HEIGHT = 640
# Text placement
TEXT_X = 10
TEXT_Y = SCREEN_HEIGHT - 30
TEXT_Y_WIDTH = 30
# Resources/sprites
RES = "res/"
MINING_RES = RES + "miner.png"
HOUSING_RES = RES + "housing.png"
CROPS_RES = RES + "crops.png"
LOGGER_RES = RES + "logger.png"
HYDRO_RES = RES + "hydropower.png"
FACTORY_RES = RES + "factory.png"
JUNCTION_RES = RES + "connector.png"
# Maps dir + map presets
MAPS = "maps/"
TEST_MAP = MAPS + "default-map.json"
# Layers for Map
LAYER_STRUCTURES = "Structures"
LAYER_ENVIRONMENT = "Environment"
# Tile Types
LOGGER = "LoggerTile"
CROPS = "CropsTile"
HYDROPOWER = "HydroPowerTile"
HOUSING = "HousingTile"
MINER = "MinerTile"
FACTORY = "FactoryTile"
JUNCTION = "JunctionTile"
GROUND = "GroundTile"
WATER = "WaterTile"
IRON = "IronTile"
TREES = "TreesTile"
# Game Starting Resources
STARTING_RESOURCES = {
"iron": 50,
"wood": 100,
"people": 10,
"food": 200
}

91
lib/scene/scene_tiles.py Normal file
View file

@ -0,0 +1,91 @@
"""
scene_tiles.py
author: Caleb Scott
Contains all classes of tiles used in miniopolis
"""
# IMPORTS -----------------------------------------------------------
import arcade
from lib.scene.scene_config import *
# CLASSES -----------------------------------------------------------
class HousingTile(arcade.Sprite):
def __init__(self, x, y):
self.image_file_name = HOUSING_RES
super().__init__(self.image_file_name, TILE_SCALE)
# Set custom properties
self.properties["type"] = HOUSING
self.center_x = x
self.center_y = y
class LoggerTile(arcade.Sprite):
def __init__(self, x, y):
self.image_file_name = LOGGER_RES
super().__init__(self.image_file_name, TILE_SCALE)
# Set custom properties
self.properties["type"] = LOGGER
self.center_x = x
self.center_y = y
class CropsTile(arcade.Sprite):
def __init__(self, x, y):
self.image_file_name = CROPS_RES
super().__init__(self.image_file_name, TILE_SCALE)
# Set custom properties
self.properties["type"] = CROPS
self.center_x = x
self.center_y = y
class HyroPowerTile(arcade.Sprite):
def __init__(self, x, y):
self.image_file_name = HYDRO_RES
super().__init__(self.image_file_name, TILE_SCALE)
# Set custom properties
self.properties["type"] = HYDROPOWER
self.center_x = x
self.center_y = y
class MinerTile(arcade.Sprite):
def __init__(self, x, y):
self.image_file_name = MINING_RES
super().__init__(self.image_file_name, TILE_SCALE)
# Set custom properties
self.properties["type"] = MINER
self.center_x = x
self.center_y = y
class FactoryTile(arcade.Sprite):
def __init__(self, x, y):
self.image_file_name = FACTORY_RES
super().__init__(self.image_file_name, TILE_SCALE)
# Set custom properties
self.properties["type"] = FACTORY
self.center_x = x
self.center_y = y
class JunctionTile(arcade.Sprite):
def __init__(self, x, y):
self.image_file_name = JUNCTION_RES
super().__init__(self.image_file_name, TILE_SCALE)
# Set custom properties
self.properties["type"] = JUNCTION
self.center_x = x
self.center_y = y