Make Scarlet Red vampiric
This commit is contained in:
parent
1174c77836
commit
764fe3421f
|
@ -176,7 +176,7 @@ class Enemy:
|
||||||
atan2(self.maze.y - y, self.maze.x - x), self.color))
|
atan2(self.maze.y - y, self.maze.x - x), self.color))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def move(self):
|
def move(self, speed=ENEMY_SPEED):
|
||||||
"""Return True if it has just moved, False otherwise."""
|
"""Return True if it has just moved, False otherwise."""
|
||||||
if self.offsetx:
|
if self.offsetx:
|
||||||
self.offsetx -= sign(self.offsetx)
|
self.offsetx -= sign(self.offsetx)
|
||||||
|
@ -186,7 +186,7 @@ class Enemy:
|
||||||
return True
|
return True
|
||||||
if self.next_strike > pygame.time.get_ticks(): return False
|
if self.next_strike > pygame.time.get_ticks(): return False
|
||||||
|
|
||||||
self.move_speed = self.maze.fps / ENEMY_SPEED
|
self.move_speed = self.maze.fps / speed
|
||||||
directions = [(sign(MIDDLE - self.x), 0), (0, sign(MIDDLE - self.y))]
|
directions = [(sign(MIDDLE - self.x), 0), (0, sign(MIDDLE - self.y))]
|
||||||
shuffle(directions)
|
shuffle(directions)
|
||||||
directions.append(choice(CROSS))
|
directions.append(choice(CROSS))
|
||||||
|
@ -199,6 +199,14 @@ class Enemy:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def slash(self):
|
||||||
|
"""Handle the enemy's close-range attack."""
|
||||||
|
if not self.spin_queue: return
|
||||||
|
x, y = self.pos()
|
||||||
|
d = self.maze.slashd - self.maze.length(x, y)
|
||||||
|
if d >= 0:
|
||||||
|
self.maze.hit(d / self.maze.hero.R / self.spin_speed, self.color)
|
||||||
|
|
||||||
def draw(self):
|
def draw(self):
|
||||||
"""Draw the enemy."""
|
"""Draw the enemy."""
|
||||||
radious = self.maze.distance/SQRT2 - self.awake*2
|
radious = self.maze.distance/SQRT2 - self.awake*2
|
||||||
|
@ -295,6 +303,24 @@ class ScarletRed(Enemy):
|
||||||
def __init__(self, maze, x, y):
|
def __init__(self, maze, x, y):
|
||||||
Enemy.__init__(self, maze, x, y, 'ScarletRed')
|
Enemy.__init__(self, maze, x, y, 'ScarletRed')
|
||||||
|
|
||||||
|
def fire(self):
|
||||||
|
"""Scarlet Red doesn't shoot."""
|
||||||
|
return False
|
||||||
|
|
||||||
|
def move(self):
|
||||||
|
return Enemy.move(self, ENEMY_SPEED * SQRT2)
|
||||||
|
|
||||||
|
def slash(self):
|
||||||
|
"""Handle the Scarlet Red's close-range attack."""
|
||||||
|
if not self.spin_queue: return
|
||||||
|
x, y = self.pos()
|
||||||
|
d = self.maze.slashd - self.maze.length(x, y)
|
||||||
|
wound = d / self.maze.hero.R / self.spin_speed
|
||||||
|
if wound >= 0:
|
||||||
|
self.maze.hit(wound, self.color)
|
||||||
|
self.wound -= wound
|
||||||
|
if self.wound < 0: self.wound = 0.0
|
||||||
|
|
||||||
|
|
||||||
def new_enemy(maze, x, y):
|
def new_enemy(maze, x, y):
|
||||||
"""Return an enemy of a random type in the grid (x, y)."""
|
"""Return an enemy of a random type in the grid (x, y)."""
|
||||||
|
|
|
@ -185,13 +185,7 @@ class Maze:
|
||||||
|
|
||||||
def slash(self):
|
def slash(self):
|
||||||
"""Handle close-range attacks."""
|
"""Handle close-range attacks."""
|
||||||
for enemy in self.enemies:
|
for enemy in self.enemies: enemy.slash()
|
||||||
if not enemy.spin_queue: continue
|
|
||||||
x, y = enemy.pos()
|
|
||||||
d = self.slashd - self.length(x, y)
|
|
||||||
if d >= 0:
|
|
||||||
self.hit(d / self.hero.R / enemy.spin_speed, enemy.color)
|
|
||||||
|
|
||||||
if not self.hero.spin_queue: return
|
if not self.hero.spin_queue: return
|
||||||
unit, killist = self.distance/SQRT2 * self.hero.spin_speed, []
|
unit, killist = self.distance/SQRT2 * self.hero.spin_speed, []
|
||||||
for i, enemy in enumerate(self.enemies):
|
for i, enemy in enumerate(self.enemies):
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -7,7 +7,7 @@ with open('README.rst') as f:
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='brutalmaze',
|
name='brutalmaze',
|
||||||
version='0.1.0',
|
version='0.1.1',
|
||||||
description='A hash and slash game with fast-paced action and a minimalist art style',
|
description='A hash and slash game with fast-paced action and a minimalist art style',
|
||||||
long_description=long_description,
|
long_description=long_description,
|
||||||
url='https://github.com/McSinyx/brutalmaze',
|
url='https://github.com/McSinyx/brutalmaze',
|
||||||
|
|
Loading…
Reference in New Issue