UPDATE: yaw beam only appears when player is shooting

This commit is contained in:
2025-03-18 23:18:24 +01:00
parent 259e68b832
commit e168e413e0
4 changed files with 10 additions and 6 deletions

View File

@@ -8,7 +8,7 @@ def main():
demo_parser = demoparser2.DemoParser("demo.dem") demo_parser = demoparser2.DemoParser("demo.dem")
game_info = demo_parser.parse_ticks(["X", "Y", "Z", "pitch", "yaw", "is_alive", "team", "player_steamid", game_info = demo_parser.parse_ticks(["X", "Y", "Z", "pitch", "yaw", "is_alive", "team", "player_steamid",
"team_rounds_total", "team_num", "total_rounds_played"]) "team_rounds_total", "team_num", "total_rounds_played", "shots_fired"])
header_info = demo_parser.parse_header() header_info = demo_parser.parse_header()
map_name = header_info['map_name'] map_name = header_info['map_name']
players = demo_parser.parse_player_info() players = demo_parser.parse_player_info()

View File

@@ -31,6 +31,7 @@ class Match:
player.pitch = self.current_tick[self.current_tick["player_steamid"] == player.steam_id]["pitch"].values[0] player.pitch = self.current_tick[self.current_tick["player_steamid"] == player.steam_id]["pitch"].values[0]
player.yaw = self.current_tick[self.current_tick["player_steamid"] == player.steam_id]["yaw"].values[0] player.yaw = self.current_tick[self.current_tick["player_steamid"] == player.steam_id]["yaw"].values[0]
player.dead = self.current_tick[self.current_tick["player_steamid"] == player.steam_id]["is_alive"].values[0] == 0 player.dead = self.current_tick[self.current_tick["player_steamid"] == player.steam_id]["is_alive"].values[0] == 0
player.is_shooting = self.current_tick[self.current_tick["player_steamid"] == player.steam_id]["shots_fired"].values[0]
def _update_round(self) -> None: def _update_round(self) -> None:
if self.current_tick.empty: if self.current_tick.empty:

View File

@@ -9,5 +9,6 @@ class Player:
self.pitch = pitch self.pitch = pitch
self.yaw = yaw # Probably only need this if top-down self.yaw = yaw # Probably only need this if top-down
self.dead = False self.dead = False
self.is_shooting = False

View File

@@ -95,11 +95,13 @@ class Renderer:
self.screen.blit(text, (mapped_x-10, mapped_y-15)) self.screen.blit(text, (mapped_x-10, mapped_y-15))
def _render_player_yaw(self, player: Player, team: Team): def _render_player_yaw(self, player: Player, team: Team):
mapped_x, mapped_y = self.map_coord_controller.map_to_screen(player.x, player.y) if player.is_shooting:
player_yaw = math.radians(player.yaw)
end_x = mapped_x + (20 * math.cos(player_yaw)) mapped_x, mapped_y = self.map_coord_controller.map_to_screen(player.x, player.y)
end_y = mapped_y - (20 * math.sin(player_yaw)) player_yaw = math.radians(player.yaw)
pygame.draw.line(self.screen, team.colour, (mapped_x, mapped_y), (end_x, end_y), 2) end_x = mapped_x + (100 * math.cos(player_yaw))
end_y = mapped_y - (100 * math.sin(player_yaw))
pygame.draw.line(self.screen, team.colour, (mapped_x, mapped_y), (end_x, end_y), 2)
def render(self): def render(self):
self.screen.fill((30, 30, 30)) # Clear screen self.screen.fill((30, 30, 30)) # Clear screen