Return to repo list

tzed

Simple story-driven open world 2D CRPG.
Return to HMagellan.com

commit c4f5bde233d4efe6fd2af609e43eacd38259976e
parent 087ad955ffa7c1654efbb4e0aac11d0a036e8359
Author: Erik Letson <hmagellan@hmagellan.com>
Date:   Sat, 28 Aug 2021 14:16:54 -0500

multi-palette support

Diffstat:
Mdata/etc/defaults.json | 19+------------------
Adata/etc/palettes.json | 38++++++++++++++++++++++++++++++++++++++
Msrc/gamelib.py | 7++++++-
3 files changed, 45 insertions(+), 19 deletions(-)

diff --git a/data/etc/defaults.json b/data/etc/defaults.json @@ -14,23 +14,6 @@ "wait" : [32, 53, 1073741917], "examine" : [101] }, - "color_palette" : [ - [0, 0, 0], - [0, 0, 128], - [128, 128, 0], - [128, 128, 128], - [128, 0, 0], - [170, 0, 170], - [255, 128, 0], - [255, 128, 128], - [0, 128, 0], - [0, 170, 170], - [128, 255, 0], - [128, 255, 128], - [170, 170, 170], - [128, 128, 255], - [255, 255, 128], - [255, 255, 255] - ], + "color_palette" : "Crazy", "overlay_sheet" : "ovrly" } diff --git a/data/etc/palettes.json b/data/etc/palettes.json @@ -0,0 +1,38 @@ +{ + "Default": [ + [0, 0, 0], + [0, 0, 128], + [128, 128, 0], + [128, 128, 128], + [128, 0, 0], + [170, 0, 170], + [255, 128, 0], + [255, 128, 128], + [0, 128, 0], + [0, 170, 170], + [128, 255, 0], + [128, 255, 128], + [170, 170, 170], + [128, 128, 255], + [255, 255, 128], + [255, 255, 255] + ], + "Crazy" : [ + [0, 0, 0], + [15, 64, 110], + [110, 110, 15], + [64, 64, 64], + [110, 15, 64], + [200, 15, 200], + [64, 150, 15], + [64, 150, 150], + [64, 110, 15], + [15, 200, 200], + [150, 64, 15], + [150, 64, 150], + [110, 110, 110], + [150, 150, 64], + [64, 64, 150], + [255, 255, 255] + ] +} diff --git a/src/gamelib.py b/src/gamelib.py @@ -31,6 +31,11 @@ OVERWORLD_PATH = os.path.join(BOARD_PATH, "overworlds") LOCATION_PATH = os.path.join(BOARD_PATH, "locations") SAVE_PATH = os.path.join(USERLOCAL_PATH, "saves") +# Palettes +with open(os.path.join(ETC_PATH, "palettes.json")) as pf: PALETTE_COLLECTION = json.load(pf) +for p in PALETTE_COLLECTION: + PALETTE_COLLECTION[p] = tuple(tuple(color) for color in PALETTE_COLLECTION[p]) + # Game settings with open(SETTINGS_PATH) as sf: SETTINGS_RAW = json.load(sf) SCREEN_WIDTH = SETTINGS_RAW["screen_width"] @@ -40,7 +45,7 @@ FRAMERATE = SETTINGS_RAW["framerate"] CONTROLS = SETTINGS_RAW["controls"] MESSAGE_FONT = SETTINGS_RAW["message_font"] MESSAGE_FONT_SIZE = SETTINGS_RAW["message_font_size"] -COLOR_PALETTE = tuple(tuple(color) for color in SETTINGS_RAW["color_palette"]) +COLOR_PALETTE = PALETTE_COLLECTION[SETTINGS_RAW["color_palette"]] OVERLAY_SHEET = SETTINGS_RAW["overlay_sheet"] # Color constants