basic player idle animation.

This commit is contained in:
Cameron Smart
2020-04-19 19:14:04 -07:00
parent 6146ee0fa2
commit 154a959e8a
42 changed files with 234 additions and 40 deletions

View File

@@ -7,19 +7,18 @@ import arcade
from config import Config
class Mob(object):
class Mob(arcade.Sprite):
"""
Represents a Mob. No defined behaviour, it has no intelligence.
"""
def __init__(self, sprite, x, y, max_health=100, max_armor=0) -> None:
self.sprite_path = sprite
self.sprite = arcade.Sprite(self.sprite_path, Config.CHARACTER_SCALING)
def __init__(self, max_health=100, max_armor=0, *args, **kwargs) -> None:
# Set up parent class
super().__init__()
self.max_health, self.max_armor = max_health, max_armor
self.health, self.armor = max_health, max_armor
self.sprite.scale = 4
self.sprite.center_x = x
self.sprite.center_y = y
self.idle_textures = []
self.cur_texture = 0
def tick(self) -> None:
"""
@@ -36,12 +35,20 @@ class Player(Mob):
def __init__(self, *args, **kwargs) -> None:
super(Player, self).__init__(*args, **kwargs)
def setup(self):
image_source = "resources/images/monsters/skeleton.png"
self.player_sprite = arcade.Sprite(image_source, Config.CHARACTER_SCALING)
self.player_sprite.center_x = Config.SCREEN_WIDTH / 2
self.player_sprite.center_y = Config.SCREEN_HEIGHT / 2
self.player_sprite.scale = 4
main_path = "resources/images/character/knight/"
# Load textures for idle standing
for i in range(4):
texture = arcade.load_texture(f"{main_path}knight iso char_idle_{i}.png")
self.idle_textures.append(texture)
def update_animation(self, delta_time: float = 1/60):
# idle animation
self.cur_texture += 1
if self.cur_texture > 3 * Config.UPDATES_PER_FRAME:
self.cur_texture = 0
self.texture = self.idle_textures[self.cur_texture // Config.UPDATES_PER_FRAME]
print('test')
def tick(self):
"""
@@ -60,7 +67,7 @@ class Enemy(Mob):
super(Enemy, self).__init__(*args, **kwargs)
def get_enemy(self):
return self.sprite
return self
def tick(self) -> None:
"""