Return to repo list

heart-of-gold

Tactical RPG written in python, using pygame.
Return to HMagellan.com

commit 47a93e59fe4c96cf13b2bc0ffaf14bb3ae30592d
parent eb3abd68a107d089c7af47b433e99cda5b5c9ffa
Author: Erik Letson <hmagellan@hmagellan.com>
Date:   Sat, 17 Oct 2020 15:13:34 -0500

Character displays now in still scene

Diffstat:
Mdata/json/scenes/testscene.json | 24+++++++++++-------------
Msrc/scene.py | 14++++++--------
2 files changed, 17 insertions(+), 21 deletions(-)

diff --git a/data/json/scenes/testscene.json b/data/json/scenes/testscene.json @@ -1,16 +1,10 @@ { "name" : "TestScene", "fonts" : { - "A" : ["ArchivoNarrow-Regular.otf", 22] + "A" : ["ArchivoNarrow-Regular.otf", 28] }, "bg_sheet" : "test_scene_bg_1", "bg_sprite" : [0, 0], - "characters" : { - "Jisella1" : { - "sheet" : "test_scene_char1", - "sprite" : [0, 0] - } - }, "script" : [ { "speaker" : "Jisella", @@ -18,11 +12,13 @@ "name_pos" : [20, 480], "line_font" : "A", "voice" : 0, - "line" : "Hi there. This is a test of the Scene system.", + "line" : "Hi there. This is a test of the Scene system. This test is currently being done. This is a very long line meant to be automatically split appart several lines in the actual rendered display in the pygame window.", "characters" : [ { "name" : "Jisella1", - "pos" : [100, 600] + "sheet" : "test_scene_char1", + "sprite" : [0, 0], + "pos" : [100, 300] } ], "effects" : [ @@ -36,12 +32,14 @@ "voice" : 0, "line" : "", "characters" : [ - ], - "effects" : [ { - "name" : "clear_character", - "target" : "Jisella1" + "name" : "Jisella1", + "sheet" : "test_scene_char1", + "sprite" : [0, 0], + "pos" : [100, 300] } + ], + "effects" : [ ] } ] diff --git a/src/scene.py b/src/scene.py @@ -68,7 +68,6 @@ class StillScene(object): self.name = None self.script = [] self.fonts = {} - self.characters = {} self.text_speed = 1 self.text_write_timer = 0 self.current_text_char_index = 0 @@ -83,7 +82,7 @@ class StillScene(object): self.text_box_pos = (0, 508) self.continue_prompt = None self.continue_prompt_pos = (964, 748) - self.text_area_topleft = (48, 540) + self.text_area_topleft = (48, 560) self.background = None # Swap-in values @@ -121,10 +120,6 @@ class StillScene(object): self.script = scenedef["script"] for f in scenedef["fonts"]: self.fonts[f] = pygame.font.Font(os.path.join(FONT_PATH, scenedef["fonts"][f][0]), scenedef["fonts"][f][1]) - for c in scenedef["characters"]: - nc = vgo.VisibleGameObject(self.manager.game.sheet_manager.loaded_sheets[scenedef["characters"][c]["sheet"]], tuple(scenedef["characters"][c]["sprite"])) - nc.custom_flags = c # TODO: Hacky solution for now, fix later - self.characters[c] = nc # Cycle in for the first time self.cycle_script_segment() @@ -137,14 +132,17 @@ class StillScene(object): self.displayed_strings = [""] self.rendered_text_surfaces = [None] self.line_number = 0 - # NOTE: The displayed_characters group is not emptied here. - # That must be done manually in a script event. + self.displayed_characters.empty() # Next, load up the next segment self.script_index += 1 self.current_font = self.fonts[self.script[self.script_index]["line_font"]] self.current_font_height = self.current_font.get_height() self.current_text_string = self.script[self.script_index]["line"] + for c in self.script[self.script_index]["characters"]: + nc = vgo.VisibleGameObject(self.manager.game.sheet_manager.loaded_sheets[c["sheet"]], tuple(c["sprite"])) + nc.set_position(tuple(c["pos"])) + self.displayed_characters.add(nc) def write_text(self): """