mirror of
https://github.com/duckduckdoof/miniopolis.git
synced 2025-03-15 08:51:21 +00:00
Separated tile classes and config info
This commit is contained in:
parent
faf6c594c0
commit
032ab0c35f
2 changed files with 7 additions and 45 deletions
|
@ -1,57 +1,18 @@
|
||||||
|
|
||||||
"""
|
"""
|
||||||
tile-demo.py
|
miniopolis.py
|
||||||
|
|
||||||
author: Caleb Scott
|
author: Caleb Scott
|
||||||
|
|
||||||
Attempting to make a tile-based layout for a colony-sim game.
|
First attempt to make a tile-based colony-sim game.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# IMPORTS -----------------------------------------------------------
|
# IMPORTS -----------------------------------------------------------
|
||||||
|
|
||||||
import arcade
|
import arcade
|
||||||
|
from lib.game_config import *
|
||||||
# CONSTANTS ---------------------------------------------------------
|
|
||||||
|
|
||||||
# Sizing
|
|
||||||
TILE_SCALE = 1.0
|
|
||||||
|
|
||||||
# Screen constants
|
|
||||||
SCREEN_WIDTH = 960
|
|
||||||
SCREEN_HEIGHT = 960
|
|
||||||
SCREEN_TITLE = "ColonySim Tiles Demo"
|
|
||||||
|
|
||||||
# World size
|
|
||||||
WORLD_WIDTH = 960
|
|
||||||
WORLD_HEIGHT = 640
|
|
||||||
|
|
||||||
# Text placement
|
|
||||||
TEXT_X = 10
|
|
||||||
TEXT_Y = SCREEN_HEIGHT - 30
|
|
||||||
TEXT_Y_WIDTH = 30
|
|
||||||
|
|
||||||
# Resources dir
|
|
||||||
RES = "res/"
|
|
||||||
|
|
||||||
# Maps dir + map presets
|
|
||||||
MAPS = "maps/"
|
|
||||||
TEST_MAP = MAPS + "default-map.json"
|
|
||||||
|
|
||||||
# Layers for Map
|
|
||||||
LAYER_STRUCTURES = "Structures"
|
|
||||||
LAYER_ENVIRONMENT = "Environment"
|
|
||||||
|
|
||||||
# CLASSES -----------------------------------------------------------
|
# CLASSES -----------------------------------------------------------
|
||||||
|
|
||||||
class HousingTile(arcade.Sprite):
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
# Basic type attributes
|
|
||||||
self.type = "Housing"
|
|
||||||
|
|
||||||
self.image_file_name = RES + "housing.png"
|
|
||||||
super().__init__(self.image_file_name, TILE_SCALE)
|
|
||||||
|
|
||||||
class GameBoard(arcade.Window):
|
class GameBoard(arcade.Window):
|
||||||
|
|
||||||
def __init__(self, width, height, title):
|
def __init__(self, width, height, title):
|
||||||
|
@ -95,7 +56,7 @@ class GameBoard(arcade.Window):
|
||||||
start_x=TEXT_X, start_y=TEXT_Y - TEXT_Y_WIDTH
|
start_x=TEXT_X, start_y=TEXT_Y - TEXT_Y_WIDTH
|
||||||
)
|
)
|
||||||
self.resources_text = arcade.Text(
|
self.resources_text = arcade.Text(
|
||||||
"RESOURCES: People: 0, Iron: 0, Wood: 0, Crops: 0",
|
"RESOURCES: People: 0, Iron: 0, Wood: 0, Food: 0",
|
||||||
start_x=TEXT_X, start_y=TEXT_Y - 2*TEXT_Y_WIDTH
|
start_x=TEXT_X, start_y=TEXT_Y - 2*TEXT_Y_WIDTH
|
||||||
)
|
)
|
||||||
self.tile_text = arcade.Text(
|
self.tile_text = arcade.Text(
|
||||||
|
@ -135,11 +96,13 @@ class GameBoard(arcade.Window):
|
||||||
# Draw updated text
|
# Draw updated text
|
||||||
self.structs_text.draw()
|
self.structs_text.draw()
|
||||||
self.commands_text.draw()
|
self.commands_text.draw()
|
||||||
self.resources_text.draw()
|
|
||||||
|
|
||||||
self.tile_text.text = f"SELECTED: {self.selected_struct_tile} on {self.selected_env_tile}"
|
self.tile_text.text = f"SELECTED: {self.selected_struct_tile} on {self.selected_env_tile}"
|
||||||
self.tile_text.draw()
|
self.tile_text.draw()
|
||||||
|
|
||||||
|
self.resources_text.text = f"RESOURCES: People: 0, Iron: 0, Wood: 0, Food: 0",
|
||||||
|
self.resources_text.draw()
|
||||||
|
|
||||||
# MAIN --------------------------------------------------------------
|
# MAIN --------------------------------------------------------------
|
||||||
|
|
||||||
def main():
|
def main():
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
"""
|
"""
|
||||||
template.py
|
template.py
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue