Skip to content
This repository has been archived by the owner on Feb 18, 2025. It is now read-only.

Commit

Permalink
Update mecs + formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Virashu committed Feb 18, 2024
1 parent 7b5ed36 commit de783c0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 13 deletions.
25 changes: 14 additions & 11 deletions danmaku/game/animated.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __init__(
xy: tuple[int | float, int | float],
width_height: tuple[int | float, int | float],
speed: int | float,
frames,
frames: dict[Direction, list[str]],
freq: int | float,
period: int | float | None = None,
) -> None:
Expand All @@ -45,8 +45,9 @@ def __init__(
self.last_direction = 0

if len(frames):
self.texture_file = self.animation_frames[
self.animation_current]
self.texture_file = self.animation_frames[Direction.STATIC][
self.animation_current
]

def can_animate(self) -> bool:
"""Check if possible to animate"""
Expand All @@ -57,13 +58,15 @@ def can_animate(self) -> bool:
return True
return False

def animate(self, direction_vector: tuple[int | float, int | float] = (0, 0)) -> None:
"""Animate one frame if possible
if self.can_animate():
self.animation_current = (self.animation_current + 1) % len(
self.animation_frames
)
self.texture_file = self.animation_frames[self.animation_current]"""
def animate(
self, direction_vector: tuple[int | float, int | float] = (0, 0)
) -> None:
"""Animate one frame if possible"""
# if self.can_animate():
# self.animation_current = (self.animation_current + 1) % len(
# self.animation_frames
# )
# self.texture_file = self.animation_frames[self.animation_current]

if self.can_animate():
direction = None
Expand Down Expand Up @@ -106,7 +109,7 @@ def frames_from_str(self, str_frames, adress):
Direction.RIGHT: [],
Direction.UP: [],
Direction.DOWN: [],
Direction.STATIC: []
Direction.STATIC: [],
}

for i in files:
Expand Down
6 changes: 4 additions & 2 deletions danmaku/game/background.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ def draw(self, graphics: vgame.graphics.Graphics):
def update(self, delta: int | float):
self.animate()

def animate(self, direction_vector: tuple[int | float, int | float] = (0, 0)) -> None:
def animate(
self, direction_vector: tuple[int | float, int | float] = (0, 0)
) -> None:
if self.can_animate():
self.animation_current = (self.animation_current + 1) % len(
self.animation_frames
)
self.texture_file = self.animation_frames[self.animation_current]
self.texture_file = self.animation_frames[self.animation_current]
10 changes: 10 additions & 0 deletions docs/mecs.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ classDiagram
GameObject <-- Animated
Animated <-- Background
Entity <-- Shooter
GameObject <-- Drop
Drop <-- Points
Drop <-- PowerUp
class Sprite {
texture_file: str
Expand Down Expand Up @@ -141,6 +144,13 @@ classDiagram
class Background {
}
class Drop {
}
class PowerUp {
}
class Points
```

## Enemies' actions processing
Expand Down

0 comments on commit de783c0

Please sign in to comment.