Skip to content

Commit

Permalink
changed is_shooting to shoot_angle in client
Browse files Browse the repository at this point in the history
not yet impmlemented. using int instead of a bool now (for future
angle sending)
  • Loading branch information
moltenwolfcub committed Dec 24, 2024
1 parent bfac785 commit c029feb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 10 additions & 2 deletions client/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def __init__(self, port: int) -> None:
self.movement_codes: list[int] = [0, 0, 0, 0]
self.movement_codes_dirty: bool = False

self.is_shooting: bool = False
self.shoot_angle: int = -1

self.quit = False

Expand Down Expand Up @@ -127,7 +127,7 @@ def _check_keydown_events(self, event: pygame.event.Event) -> None:
self.movement_codes_dirty = True

case keybinds.SHOOT:
self.is_shooting = True
self.shoot()

case _:
pass
Expand Down Expand Up @@ -176,4 +176,12 @@ def _resize_screen(self, event: pygame.event.Event) -> None:
def exit_game(self) -> None:
self.network.close_connection()
self.quit = True

def shoot(self) -> None:
if not pygame.mouse.get_focused():
return # mouse not on screen

# mouse_x, mouse_y = pygame.mouse.get_pos()

self.shoot_angle = 1

4 changes: 2 additions & 2 deletions client/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,6 @@ def send_updates(self) -> None:

self.game.movement_codes_dirty = False

if self.game.is_shooting:
if self.game.shoot_angle != -1:
self.send(C2SCreateBullet())
self.game.is_shooting = False
self.game.shoot_angle = -1

0 comments on commit c029feb

Please sign in to comment.