-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
116f677
commit 023e4b3
Showing
3 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from typing import TYPE_CHECKING, Callable | ||
|
||
import pygame | ||
|
||
from common.bullet import CommonBullet | ||
from common.data_types import Vec2D | ||
|
||
if TYPE_CHECKING: | ||
from client.main import Game | ||
|
||
|
||
class ClientBullet: | ||
|
||
def __init__(self, game: 'Game', pos: Vec2D) -> None: | ||
self.game: Game = game | ||
|
||
self.pos: Vec2D = pos | ||
|
||
self.radius: int = 10 | ||
|
||
self.rect = pygame.Rect(self.pos.x-self.radius, self.pos.y-self.radius, self.radius*2, self.radius*2) | ||
|
||
def draw(self, scaler: Callable[[pygame.Rect], pygame.Rect]) -> None: | ||
draw_rect = scaler(self.rect) | ||
|
||
pygame.draw.circle(self.game.screen, (0, 0, 0), draw_rect.center, self.radius) | ||
|
||
@staticmethod | ||
def from_common(common: CommonBullet, game: 'Game') -> 'ClientBullet': | ||
return ClientBullet(game, common.pos) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters