from Setup import *
from Player import Player
from Actors import Actor
-from Weapon import Sword
+from Weapon import Sword, Lightning
from Particle import Dust
class Enemy(Actor):
self.direction = -1
self.prev_direction = self.direction
- # self.health = 0 # for debugging without getting killed
+ self.health = 0 # for debugging without getting killed
self.weapon = Sword(self.position, (0, 0), self.width, -1)
run_gif = Image.open("Assets/skeleton/skeleton_king_idle.gif")
run_frames = []
for i in range(run_gif.n_frames):
- run_frames.append(pg.transform.scale(pil_to_game(get_gif_frame(run_gif, i)), (160, 240)))
+ run_frames.append(pg.transform.scale(pil_to_game(get_gif_frame(run_gif, i)), (120, 180)))
attack_gif = Image.open("Assets/skeleton/skeleton_king_summon.gif")
attack_frames = []
self.direction = -1
self.prev_direction = self.direction
- # self.health = 0 # for debugging without getting killed
-
- self.weapon = Sword(self.position, (0, 0), self.width, -1)
-
+ self.health = 1000 # for debugging without getting killed
+ self.weapon = Lightning(self.position, (-100 - self.width/2,0), self.width, -1)
self.buffer = []
self.display_offsets = {"enemy":pg.Vector2(0,0)}
self.state = "ATTACK"
self.current_frame = 0
elif 4 < self.current_frame:
- target.attack(self, self.weapon, self.direction)
+ target.attack(self, self.weapon, math.copysign(1, target.position.x - self.position.x))
# Deals with collision and applying velocity
self.position, self.velocity = self.move_and_collide(self.position.copy(), self.velocity.copy(), delta)
if self.state == "RUN":
frame = math.floor(self.current_frame)
- if self.velocity.x > 0:
- self.display = self.run_frames[math.floor(frame)]
- self.display_offsets["enemy"] = pg.Vector2(-30, -35)
- elif self.velocity.x <= 0:
- self.display = pg.transform.flip(self.run_frames[math.floor(frame)], True, False)
- self.display_offsets["enemy"] = pg.Vector2(-90, -35)
- if frame % 4 == 0 and self.on_ground:
- Dust(pg.Vector2(self.get_collision_rect().midbottom) + pg.Vector2(math.copysign(1, self.velocity.x) * -self.width/2,-15), 16, self.direction)
- self.current_frame = (self.current_frame + 0.25) % self.run_gif.n_frames
+ self.display = self.run_frames[math.floor(frame)]
+ self.display_offsets["enemy"] = pg.Vector2(0, -35)
+ self.current_frame = (self.current_frame + 0.025) % self.run_gif.n_frames
+
elif self.state == "ATTACK":
frame = math.floor(self.current_frame)
if self.direction == 1:
self.current_frame += 0.4
if math.floor(self.current_frame) >= self.attack_gif.n_frames-1:
self.state = "RUN"
+ self.current_frame = 0
# print(self.velocity)
def draw(self, surf):
# self.weapon.draw(surf)
- # super(Enemy, self).draw(surf)
+ super(King, self).draw(surf)
surf.blit(self.display, get_display_rect(self.get_collision_rect()).topleft + self.display_offsets["enemy"])
# for b in self.buffer:
# pg.draw.rect(surf,(0,0,255),get_display_rect(b),3)
# self.buffer.append(self.get_collision_rect())
- # pg.draw.rect(surf, (0, 255, 0), get_display_rect(self.get_collision_rect()), 2)
+ pg.draw.rect(surf, (0, 255, 0), get_display_rect(self.weapon.get_collision_rect()), 2)
def draw(self, surf, display_offset = pg.Vector2(0,0)):
surf.blit(self.display, get_display_rect(self.get_collision_rect()).topleft + display_offset)
+class Lightning:
+ width,height = (200,200)
+ damage = -35
+
+ def __init__(self, pos, offset, width,direction):
+ self.position = pg.Vector2(pos)
+ self.offset = pg.Vector2(offset)
+
+ def update(self, delta, pos, direction):
+ self.position = pg.Vector2(pos)
+
+ def get_collision_rect(self):
+ return pg.Rect(self.position - self.offset - pg.Vector2(self.width,self.height/4),(self.width, self.height))
+
+
+ def draw(self, surf, display_offset = pg.Vector2(0,0)):
+ pass
+ # surf.blit(self.display, get_display_rect(self.get_collision_rect()).topleft + display_offset)