Skip to content

Commit

Permalink
Merge pull request #287 from PixPanz/nick
Browse files Browse the repository at this point in the history
Added team name to endscreen, and fixed health bar lengths
  • Loading branch information
wylyandrews authored Feb 8, 2020
2 parents 879064d + dafa77e commit 381335b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
21 changes: 15 additions & 6 deletions game/visualizer/end_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,32 @@ class EndLayer(cocos.layer.Layer):
def __init__(self, display_size, parser):
self.display = display_size
super().__init__()
label = cocos.text.Label(
game_over_label = cocos.text.Label(
"Game Over",
font_size=64,
font_size=32,
color=(255, 0, 0, 255),
anchor_x='center',
anchor_y='center'

)
label.position = self.display[0] / 2, self.display[1] / 2 + 300
self.add(label)
game_over_label.position = self.display[0] / 2, self.display[1] / 2 + 315
self.add(game_over_label)

# Fun stats
results = dict()
with open(RESULTS_FILE, 'r') as f:
results = json.load(f)
stats = results['Statistics']
team_name = results['Team']

team_label = cocos.text.Label(
team_name,
font_size=32,
color=(240, 240, 255, 255),
anchor_x='center',
anchor_y='center'
)
team_label.position = self.display[0] / 2, self.display[1] / 2 + 275
self.add(team_label)

dis_def_percent = f'{stats["disasters_correctly_protected"] / stats["total_disasters"]:.2%}'
dis_def_label = cocos.text.Label(
Expand Down Expand Up @@ -90,5 +100,4 @@ def __init__(self, display_size, parser):
self.add(final_score_label)

# Line graph
# self.add(LineGraph([6,48,367], 200,100, parser))
self.add(LineGraph(parser, self.display[0]-100, self.display[1]-100-100, 50, 50))
5 changes: 2 additions & 3 deletions game/visualizer/health_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,16 @@ def __init__(self, display_size, turn_info):
struct_label.position = x, s_y

p_start = x+20, p_y
p_end = x+20+population, p_y
p_end = max(x+5+population, x+20), p_y
s_start = x+20, s_y
s_end = x+20+structure, s_y
s_end = max(x+5+structure, x+20), s_y

self.add(pop_label)
self.add(struct_label)

pop_bar = cocos.draw.Line(p_start, p_end, color=(56,168,255,255), stroke_width=15)
struct_bar = cocos.draw.Line(s_start, s_end, color=(255,0,0,255), stroke_width=15)


self.add(struct_bar)
self.add(pop_bar)

Expand Down

0 comments on commit 381335b

Please sign in to comment.