Skip to content

Commit

Permalink
Added very basic party member handler to test things out -- not final\!
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Fiano committed Jan 16, 2010
1 parent 1db37ce commit da534af
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 13 deletions.
Binary file removed data/images/map/terrain/water0.png
Binary file not shown.
2 changes: 0 additions & 2 deletions lib/gui.py
Expand Up @@ -27,8 +27,6 @@ def __init__(self, chars):
self.rect = self.image.get_rect()
self.rect.left = 16
self.rect.bottom = WINDOW_SIZE[1] - 16
self.images = [
load_image("gui", "dialog", "dialog_bg") ]
self.font_bg = Font("gui", STATS_TEXT_SIZE, STATS_TEXT_BGCOLOR, None)
self.font_fg = Font("gui", STATS_TEXT_SIZE, STATS_TEXT_FGCOLOR, None)
self.draw()
Expand Down
8 changes: 4 additions & 4 deletions lib/map.py
Expand Up @@ -232,12 +232,12 @@ def set_edges(self, offset):
'w': rect.move(-w,0),
'nw': rect.move(-w,-h) }
for edge in edges:
current = (edges[edge][0], edges[edge][1])
cur_x, cur_y = current
cursor = (edges[edge][0], edges[edge][1])
cur_x, cur_y = cursor
map_w, map_h = self.get_size()
if (0 <= cur_x <= map_w and 0 <= cur_y <= map_h and
current in self.position and offset in self.position):
self.position[offset][1][edge] = self.position[current][0].type
cursor in self.position and offset in self.position):
self.position[offset][1][edge] = self.position[cursor][0].type

def align_objects(self, w, h, offset):
"""Re-align bigger tiles to fit the rest."""
Expand Down
28 changes: 22 additions & 6 deletions lib/screens.py
Expand Up @@ -79,31 +79,47 @@ def __init__(self, map_name):
self.map = Map(map_name)
self.dialog_text = "Sample dialog text."
self.hero = CharHero(self)
self.chartest = CharTest(self)
self.map.scroll(self.camera, self.hero)
self.add()

def add(self):
"""Add sprites to the screen in the correct order."""

# Add character objects to a new group.
char_sprites = pygame.sprite.Group([
self.hero, self.chartest ])
# Add party characters to a new group.
self.party_sprites = pygame.sprite.Group([
self.hero ])

# Add all characters to a new group.
self.char_sprites = pygame.sprite.Group([
self.party_sprites ])

# Create GUI objects and add them to a new group.
gui_stats = StatsWindow(char_sprites)
gui_stats = StatsWindow(self.party_sprites)

# Create a queue of all sprites to be drawn to the screen in order.
self.all_sprites = pygame.sprite.OrderedUpdates([
self.map.layers['terrain'],
char_sprites,
self.char_sprites,
self.map.layers['foreground'],
gui_stats ])

# Give each item in the queue a new layer of the screen to be drawn to.
for sprite in self.all_sprites:
self.layers.add(sprite)

def add_to_party(self):
"""Called during gameplay to add a new character to the existing
map."""

exists = False
for char in self.party_sprites:
if char.name == "test":
exists = True

if not exists:
chartest = CharTest(self)
self.party_sprites.add(chartest)

def draw(self):
"""Draws the sprites to the screen and updates the window."""

Expand Down
2 changes: 1 addition & 1 deletion lib/states.py
Expand Up @@ -86,7 +86,7 @@ def check_events(self):
elif event.key == K_d:
pygame.time.set_timer(DIALOG_EVENT, 100)
elif event.key == K_e:
self.screen.hero.hp += 1
self.screen.add_to_party()
elif event.key in (
HERO_MOVE_DOWN,
HERO_MOVE_UP,
Expand Down

0 comments on commit da534af

Please sign in to comment.