commit aca7d428901de8ca938e8650b2007378e18770c8
parent 056f8bae3e22af6475018c00af376ca8810c4850
Author: Erik Letson <hmagellan@hmagellan.com>
Date: Fri, 4 Dec 2020 17:09:45 -0600
Perpixel alpha now working and improving scenes actors
Diffstat:
11 files changed, 49 insertions(+), 28 deletions(-)
diff --git a/data/img/actors/jisella/base.png b/data/img/actors/jisella/base.png
Binary files differ.
diff --git a/data/img/actors/jisella/mouth.png b/data/img/actors/jisella/mouth.png
Binary files differ.
diff --git a/data/img/pictures/jisella_1/battle_portrait.png b/data/img/pictures/jisella_1/battle_portrait.png
Binary files differ.
diff --git a/data/img/pictures/jisella_2/battle_portrait.png b/data/img/pictures/jisella_2/battle_portrait.png
Binary files differ.
diff --git a/data/img/pictures/jisella_3/battle_portrait.png b/data/img/pictures/jisella_3/battle_portrait.png
Binary files differ.
diff --git a/data/img/pictures/jisella_4/battle_portrait.png b/data/img/pictures/jisella_4/battle_portrait.png
Binary files differ.
diff --git a/data/json/scenes/testscene.json b/data/json/scenes/testscene.json
@@ -15,14 +15,14 @@
"line" : "Hello there. How are you doing today? I'm fine, thanks for asking.",
"characters" : [
{
- "name" : "Jisella1",
- "sheet" : "test_scene_char1",
- "sprite" : [0, 0],
- "pos" : [100, 300]
+ "name" : "jisella",
+ "actor" : [
+ { "sheet" : "base", "sprite" : [0, 0], "pos" : [100, 300] },
+ { "sheet" : "mouth", "sprite" : [0, 0], "pos" : [100, 300] }
+ ]
}
],
- "effects" : [
- ]
+ "effects" : [ ]
},
{
"speaker" : "",
@@ -31,14 +31,7 @@
"line_font" : "A",
"voice" : null,
"line" : "",
- "characters" : [
- {
- "name" : "Jisella1",
- "sheet" : "test_scene_char1",
- "sprite" : [0, 0],
- "pos" : [100, 300]
- }
- ],
+ "characters" : [ ],
"effects" : [
{
"call" : "ef_game_switch_mode",
diff --git a/data/json/sheets.json b/data/json/sheets.json
@@ -48,6 +48,20 @@
"anim_class" : null,
"alpha" : false
},
+ "jisella_actor_base" : {
+ "filename" : "actors/jisella/base.png",
+ "dimensions" : [350, 650],
+ "total_sprites" : 1,
+ "anim_class" : null,
+ "alpha" : true
+ },
+ "jisella_actor_mouth" : {
+ "filename" : "actors/jisella/mouth.png",
+ "dimensions" : [32, 32],
+ "total_sprites" : 10,
+ "anim_class" : null,
+ "alpha" : true
+ },
"jisella_1" : {
"filename" : "jisella_1.png",
"dimensions" : [64, 64],
@@ -106,28 +120,28 @@
},
"jisella_pictures_1_battle_portrait" : {
"filename" : "pictures/jisella_1/battle_portrait.png",
- "dimensions" : [294, 651],
+ "dimensions" : [300, 650],
"total_sprites" : 1,
"anim_class" : null,
"alpha" : false
},
"jisella_pictures_2_battle_portrait" : {
"filename" : "pictures/jisella_2/battle_portrait.png",
- "dimensions" : [294, 651],
+ "dimensions" : [300, 650],
"total_sprites" : 1,
"anim_class" : null,
"alpha" : false
},
"jisella_pictures_3_battle_portrait" : {
"filename" : "pictures/jisella_3/battle_portrait.png",
- "dimensions" : [294, 651],
+ "dimensions" : [300, 650],
"total_sprites" : 1,
"anim_class" : null,
"alpha" : false
},
"jisella_pictures_4_battle_portrait" : {
"filename" : "pictures/jisella_4/battle_portrait.png",
- "dimensions" : [294, 651],
+ "dimensions" : [300, 650],
"total_sprites" : 1,
"anim_class" : null,
"alpha" : false
diff --git a/src/images.py b/src/images.py
@@ -63,13 +63,17 @@ class SheetManager(manager.Manager):
if type(self.anims_def[c][a][i][v]) == list:
self.animations[c][a][i][v] = tuple(self.anims_def[c][a][i][v])
- def load_image(self, filename):
+ def load_image(self, filename, alpha = False):
"""
Load an image file as a PyGame image. This is generic
and can function even outside of the normal sheet
dynamic that the game uses.
"""
- return pygame.image.load(os.path.join(IMAGE_PATH, filename)).convert()
+ if alpha:
+ im = pygame.image.load(os.path.join(IMAGE_PATH, filename)).convert_alpha()
+ else:
+ im = pygame.image.load(os.path.join(IMAGE_PATH, filename)).convert()
+ return im
def get_sheet(self, name):
"""
@@ -125,7 +129,7 @@ class Sheet(object):
# First, attempt to load the image file. Failing that, create
# a sheet as a NoneType object
try:
- self.sheet = self.manager.load_image(filename)
+ self.sheet = self.manager.load_image(filename, self.alpha)
except:
self.sheet = None
diff --git a/src/scene.py b/src/scene.py
@@ -99,7 +99,7 @@ class StillScene(object):
self.background = None
# Swap-in values
- self.displayed_characters = pygame.sprite.LayeredDirty()
+ self.displayed_characters = [] # Must be an ordered list rather than a sprite group
self.current_text_string = ""
self.displayed_strings = [""] # list of text lines
self.rendered_text_surfaces = [None]
@@ -153,7 +153,8 @@ class StillScene(object):
self.rendered_name_topleft = (0, 0)
self.line_number = 0
self.current_line_starting_index = 0
- self.displayed_characters.empty()
+ self.displayed_characters = []
+ sh = self.manager.bus.fetch("sheet_manager", "sheets")
# Next, load up the next segment
self.script_index += 1
@@ -165,9 +166,13 @@ class StillScene(object):
self.current_voice = self.script[self.script_index]["voice"]
self.current_text_string = self.script[self.script_index]["line"]
for c in self.script[self.script_index]["characters"]:
- nc = entity.Entity(self.manager.bus.fetch("sheet_manager", "sheets")[c["sheet"]], tuple(c["sprite"]))
- nc.set_position(tuple(c["pos"]))
- self.displayed_characters.add(nc)
+ nc_name = c["name"]
+ nel = []
+ for a in c["actor"]:
+ ne = entity.Entity(sh[nc_name + "_actor_" + a["sheet"]], tuple(a["sprite"]))
+ ne.set_position(tuple(a["pos"]))
+ nel.append(ne)
+ self.displayed_characters.append(nel)
if self.script[self.script_index]["speaker"] != None:
self.rendered_name = self.current_name_font.render(self.script[self.script_index]["speaker"], False, (255, 255, 255)).convert()
self.rendered_name_topleft = (self.name_box_pos[0] + ((self.name_box.image.get_width() / 2) - (self.rendered_name.get_width() / 2)), self.name_box_pos[1] + ((self.name_box.image.get_height() / 2) - (self.rendered_name.get_height() / 2)))
@@ -262,7 +267,12 @@ class StillScene(object):
"""
if surface != None:
self.background.update(surface)
- self.displayed_characters.update(surface)
+
+ # Update character compounds
+ for c in self.displayed_characters:
+ for e in c:
+ e.update(surface)
+
self.text_box.update(surface)
self.name_box.update(surface)
diff --git a/src/status.py b/src/status.py
@@ -58,7 +58,7 @@ class StatusDisplay(entity.Entity):
# Surface base positions
# TODO: hardcoded
self.affinity_icon_position = (504, 84)
- self.battle_portrait_position = (674, 58)
+ self.battle_portrait_position = (666, 59)
self.name_surface_position = (94, 95)
self.class_surface_position = (94, 152)
self.level_surface_rect_position = (800, 620)