ADD kill, death, assist stats
This commit is contained in:
BIN
assets/fonts/Metropolis-Bold.ttf
Normal file
BIN
assets/fonts/Metropolis-Bold.ttf
Normal file
Binary file not shown.
3
main.py
3
main.py
@@ -22,7 +22,8 @@ def main():
|
||||
},
|
||||
"styling": {
|
||||
"font": pygame.font.Font("assets/fonts/Metropolis-Regular.ttf", 30),
|
||||
"small_font": pygame.font.Font("assets/fonts/Metropolis-Regular.ttf", 15),
|
||||
"small_font": pygame.font.Font("assets/fonts/Metropolis-Regular.ttf", 18),
|
||||
"underline_bold_font": (lambda f: (f.set_underline(True), f)[1])(pygame.font.Font("assets/fonts/Metropolis-Bold.ttf", 30)),
|
||||
"button_colour": (200, 200, 200),
|
||||
"pressed_button_colour": (150, 150, 150),
|
||||
"text_colour": (255, 255, 255),
|
||||
|
||||
@@ -39,6 +39,9 @@ class Match:
|
||||
player.health = int(self.current_tick[self.current_tick["player_steamid"] == player.steam_id]["health"].values[0])
|
||||
player.armour = int(self.current_tick[self.current_tick["player_steamid"] == player.steam_id]["armor_value"].values[0])
|
||||
player.current_weapon = self.current_tick[self.current_tick["player_steamid"] == player.steam_id]["active_weapon_name"].values[0]
|
||||
player.kills = int(self.current_tick[self.current_tick["player_steamid"] == player.steam_id]["kills_total"].values[0])
|
||||
player.deaths = int(self.current_tick[self.current_tick["player_steamid"] == player.steam_id]["deaths_total"].values[0])
|
||||
player.assists = int(self.current_tick[self.current_tick["player_steamid"] == player.steam_id]["assists_total"].values[0])
|
||||
|
||||
def _update_round(self) -> None:
|
||||
if self.current_tick.empty:
|
||||
|
||||
@@ -14,6 +14,10 @@ class Player:
|
||||
self.is_shooting = False
|
||||
self.current_weapon = None
|
||||
|
||||
self.kills = 0
|
||||
self.deaths = 0
|
||||
self.assists = 0
|
||||
|
||||
## UI-related state
|
||||
self.is_selected = False
|
||||
self.is_hovered = False
|
||||
|
||||
@@ -8,25 +8,44 @@ class InfoRenderer:
|
||||
self.colour = self.styling["text_colour"]
|
||||
self.font = self.styling["font"]
|
||||
self.small_font = self.styling["small_font"]
|
||||
|
||||
self.underline_bold_font = self.styling["underline_bold_font"]
|
||||
self.selected_player = None
|
||||
|
||||
self.player_info_start_y = 100
|
||||
self.match_info_start_y = 400
|
||||
|
||||
# Private methods
|
||||
def _render_player_info(self):
|
||||
"""Draws the player info on the screen."""
|
||||
if self.selected_player is None:
|
||||
return
|
||||
|
||||
player_info_title = f"{self.selected_player.name}\n"
|
||||
player_info_title = "No player selected\n"
|
||||
player_info = ""
|
||||
else:
|
||||
player_info_title = f"Player: {self.selected_player.name}\n"
|
||||
player_info = f"Active Weapon: {self.selected_player.current_weapon}\n"
|
||||
player_info += f"Health: {self.selected_player.health}\n"
|
||||
player_info += f"Armour: {self.selected_player.armour}\n"
|
||||
player_info += f"Kills: {self.selected_player.kills}\n"
|
||||
player_info += f"Deaths: {self.selected_player.deaths}\n"
|
||||
player_info += f"Assists: {self.selected_player.assists}\n"
|
||||
|
||||
text_surface = self.font.render(player_info_title, True, self.styling["text_colour"])
|
||||
self.screen.blit(text_surface, (10, 100))
|
||||
text_surface = self.underline_bold_font.render(player_info_title, True, self.styling["text_colour"])
|
||||
self.screen.blit(text_surface, (10, self.player_info_start_y))
|
||||
|
||||
text_surface = self.small_font.render(player_info, True, self.styling["text_colour"])
|
||||
self.screen.blit(text_surface, (10, 150))
|
||||
self.screen.blit(text_surface, (10, self.player_info_start_y + 50))
|
||||
|
||||
def _render_match_info(self):
|
||||
"""Draws the match info on the screen."""
|
||||
match_info_title = "Match Info\n"
|
||||
match_info = f"Map: {self.match.map_name}\n"
|
||||
match_info += f"Score: {self.match.team_1.score}-{self.match.team_2.score}\n"
|
||||
|
||||
text_surface = self.underline_bold_font.render(match_info_title, True, self.styling["text_colour"])
|
||||
self.screen.blit(text_surface, (10, self.match_info_start_y))
|
||||
|
||||
text_surface = self.small_font.render(match_info, True, self.styling["text_colour"])
|
||||
self.screen.blit(text_surface, (10, self.match_info_start_y + 50))
|
||||
|
||||
def _render_current_tick(self, match_tick, max_tick):
|
||||
text = self.font.render(f"Tick: {match_tick}/{max_tick}", True, self.colour)
|
||||
@@ -41,4 +60,4 @@ class InfoRenderer:
|
||||
"""Renders the info on the screen."""
|
||||
self._render_player_info()
|
||||
self._render_current_tick(self.match.tick, self.match.max_tick)
|
||||
self._render_team_scores(self.match.team_1.score, self.match.team_2.score)
|
||||
self._render_match_info()
|
||||
@@ -84,6 +84,7 @@ class StartMenu(GameState):
|
||||
demo_parser = demoparser2.DemoParser(demo_file)
|
||||
game_info = demo_parser.parse_ticks(["X", "Y", "Z", "pitch", "yaw", "is_alive", "team", "player_steamid",
|
||||
"team_rounds_total", "team_num", "total_rounds_played", "shots_fired",
|
||||
"kills_total", "deaths_total", "assists_total",
|
||||
"health", "armor_value", "active_weapon_name"])
|
||||
header_info = demo_parser.parse_header()
|
||||
map_name = header_info['map_name']
|
||||
|
||||
Reference in New Issue
Block a user