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")
|
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()
|
||||||
|
|||||||
@@ -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:
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
|
|
||||||
@@ -95,10 +95,12 @@ 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):
|
||||||
|
if player.is_shooting:
|
||||||
|
|
||||||
mapped_x, mapped_y = self.map_coord_controller.map_to_screen(player.x, player.y)
|
mapped_x, mapped_y = self.map_coord_controller.map_to_screen(player.x, player.y)
|
||||||
player_yaw = math.radians(player.yaw)
|
player_yaw = math.radians(player.yaw)
|
||||||
end_x = mapped_x + (20 * math.cos(player_yaw))
|
end_x = mapped_x + (100 * math.cos(player_yaw))
|
||||||
end_y = mapped_y - (20 * math.sin(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)
|
pygame.draw.line(self.screen, team.colour, (mapped_x, mapped_y), (end_x, end_y), 2)
|
||||||
|
|
||||||
def render(self):
|
def render(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user