added docstrings to every file and function. (with claude, checked it)
tower and game_play dont meet pylint check yet.
This commit is contained in:
+15
-11
@@ -6,6 +6,7 @@ import pygame as pg
|
||||
from game.util import tile_to_pixel
|
||||
|
||||
class Enemy(pg.sprite.Sprite):
|
||||
# pylint: disable=too-many-instance-attributes
|
||||
"""A single enemy that follows waypoints
|
||||
across the tilemap.
|
||||
|
||||
@@ -13,31 +14,33 @@ class Enemy(pg.sprite.Sprite):
|
||||
game (Game): Whole Game instances, contains everything that the game class has.
|
||||
speed (float): Movement speed in pixels per update.
|
||||
health (float): Current health points.
|
||||
angle (float): Current facing angle in degrees.
|
||||
angle (float): Current facing angle in degrees. (initalized on 0 degress)
|
||||
"""
|
||||
def __init__(self, game, speed, health):
|
||||
super().__init__()
|
||||
self.game = game
|
||||
# coordinate on where the enemy should move to (in map json)
|
||||
self.waypoints = self.game.tilemap.waypoints
|
||||
|
||||
self.speed = speed
|
||||
self.angle = 0
|
||||
self.health = health
|
||||
|
||||
#starting waypoint index
|
||||
self.target_index = 1
|
||||
self.target = None #iititalise target var
|
||||
self.angle = 0
|
||||
self.healthbar = HealthBar(
|
||||
18,
|
||||
4,
|
||||
self.health
|
||||
)
|
||||
|
||||
#initalise objects need to be initalized last (depend on ealier dependencies)
|
||||
self.image = pg.transform.rotate(self.game.assets['enemy'].copy(), self.angle)
|
||||
self.rect = self.image.get_rect()
|
||||
|
||||
self.pos = pg.Vector2(
|
||||
tile_to_pixel(self.waypoints[0], self.game.tilemap.tile_size, True)
|
||||
)
|
||||
|
||||
self.target_index = 1
|
||||
self.rect.center = self.pos
|
||||
self.healthbar = HealthBar(
|
||||
18,
|
||||
5,
|
||||
self.health
|
||||
)
|
||||
|
||||
def update(self):
|
||||
"""Advance movement and update rotation each frame."""
|
||||
@@ -133,6 +136,7 @@ class EnemyGroup(pg.sprite.Group):
|
||||
enemy.update()
|
||||
|
||||
class HealthBar():
|
||||
# pylint: disable=too-few-public-methods
|
||||
"""A simple two-rect health bar drawn in world space.
|
||||
|
||||
Attributes:
|
||||
|
||||
Reference in New Issue
Block a user