UPDATE: yaw beam only appears when player is shooting
This commit is contained in:
2
main.py
2
main.py
@@ -8,7 +8,7 @@ def main():
|
||||
|
||||
demo_parser = demoparser2.DemoParser("demo.dem")
|
||||
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()
|
||||
map_name = header_info['map_name']
|
||||
players = demo_parser.parse_player_info()
|
||||
|
||||
@@ -31,6 +31,7 @@ class Match:
|
||||
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.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:
|
||||
if self.current_tick.empty:
|
||||
|
||||
@@ -9,5 +9,6 @@ class Player:
|
||||
self.pitch = pitch
|
||||
self.yaw = yaw # Probably only need this if top-down
|
||||
self.dead = False
|
||||
self.is_shooting = False
|
||||
|
||||
|
||||
@@ -95,11 +95,13 @@ class Renderer:
|
||||
self.screen.blit(text, (mapped_x-10, mapped_y-15))
|
||||
|
||||
def _render_player_yaw(self, player: Player, team: Team):
|
||||
mapped_x, mapped_y = self.map_coord_controller.map_to_screen(player.x, player.y)
|
||||
player_yaw = math.radians(player.yaw)
|
||||
end_x = mapped_x + (20 * math.cos(player_yaw))
|
||||
end_y = mapped_y - (20 * math.sin(player_yaw))
|
||||
pygame.draw.line(self.screen, team.colour, (mapped_x, mapped_y), (end_x, end_y), 2)
|
||||
if player.is_shooting:
|
||||
|
||||
mapped_x, mapped_y = self.map_coord_controller.map_to_screen(player.x, player.y)
|
||||
player_yaw = math.radians(player.yaw)
|
||||
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):
|
||||
self.screen.fill((30, 30, 30)) # Clear screen
|
||||
|
||||
Reference in New Issue
Block a user