Skip to content

Commit

Permalink
[IMP] Some minor improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
japinol7 committed Apr 30, 2024
1 parent f05a3f3 commit 66b5728
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion codemaster/models/actors/npcs/snakes.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def __init__(self, x, y, game, name=None, change_x=0, change_y=0,


class SnakeRed(Snake):
"""Represents a blue red."""
"""Represents a red snake."""

def __init__(self, x, y, game, name=None, change_x=0, change_y=0,
border_left=0, border_right=0,
Expand Down
20 changes: 10 additions & 10 deletions codemaster/models/special_effects/vortex.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ def __init__(self, position, angle, speed, color=Color.WHITE,
self.draw_method = self.draw_method_circle

def calc_move(self, dt):
return [math.cos(self.angle) * self.speed * dt,
math.sin(self.angle) * self.speed * dt]
return (math.cos(self.angle) * self.speed * dt,
math.sin(self.angle) * self.speed * dt)

def set_point_towards(self, angle, rate):
rotate_dir = ((angle - self.angle + math.pi * 3) % (math.pi * 2)) - math.pi
Expand All @@ -69,18 +69,18 @@ def move(self, dt):
self.alive = False

def draw_method_polygon(self, surface):
lateral_point = [
lateral_point = (
self.position[0] + math.cos(self.angle + math.pi / 2) * self.speed * self.scale * 0.3,
self.position[1] + math.sin(self.angle + math.pi / 2) * self.speed * self.scale * 0.3]
self.position[1] + math.sin(self.angle + math.pi / 2) * self.speed * self.scale * 0.3)

points = [
[self.position[0] + math.cos(self.angle) * self.speed * self.scale,
self.position[1] + math.sin(self.angle) * self.speed * self.scale],
points = (
(self.position[0] + math.cos(self.angle) * self.speed * self.scale,
self.position[1] + math.sin(self.angle) * self.speed * self.scale),
lateral_point,
[self.position[0] + math.cos(self.angle) * self.speed * self.scale * 3.5,
self.position[1] + math.sin(self.angle) * self.speed * self.scale * 3.5],
(self.position[0] + math.cos(self.angle) * self.speed * self.scale * 3.5,
self.position[1] + math.sin(self.angle) * self.speed * self.scale * 3.5),
lateral_point,
]
)
pg.draw.polygon(surface, self.color, points)

def draw_method_circle(self, surface):
Expand Down
9 changes: 5 additions & 4 deletions codemaster/tools/utils/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@


class Queue:
def __init__(self, iterable=(), maxlen=None, name=''):
def __init__(self, iterable=(), maxlen=None, name='', num=0):
self._container = deque(iterable=iterable, maxlen=maxlen)
self.name = name

def __iter__(self):
return iter(self._container)
self.num = num

@property
def is_empty(self):
Expand All @@ -22,6 +20,9 @@ def pop(self):
def peek(self):
return self._container[0] if not self.is_empty else None

def __iter__(self):
return iter(self._container)

def __len__(self):
return len(self._container)

Expand Down
6 changes: 3 additions & 3 deletions codemaster/tools/utils/stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ def __init__(self, iterable=(), maxlen=None, name='', num=0):
self.name = name
self.num = num

def __iter__(self):
return iter(self._container)

@property
def is_empty(self):
return not self._container
Expand All @@ -23,6 +20,9 @@ def pop(self):
def peek(self):
return self._container[-1] if not self.is_empty else None

def __iter__(self):
return iter(self._container)

def __len__(self):
return len(self._container)

Expand Down

0 comments on commit 66b5728

Please sign in to comment.