Make critical close-range hits independent of FPS
This commit is contained in:
parent
1578586f24
commit
4370b1531d
|
@ -63,10 +63,11 @@ class Hero:
|
||||||
|
|
||||||
def update(self, fps):
|
def update(self, fps):
|
||||||
"""Update the hero."""
|
"""Update the hero."""
|
||||||
|
if self.dead: return
|
||||||
old_speed, time = self.spin_speed, pygame.time.get_ticks()
|
old_speed, time = self.spin_speed, pygame.time.get_ticks()
|
||||||
self.spin_speed = fps / (HERO_HP-self.wound**0.5)
|
self.spin_speed = fps / (HERO_HP-self.wound**0.5)
|
||||||
self.spin_queue *= self.spin_speed / old_speed
|
self.spin_queue *= self.spin_speed / old_speed
|
||||||
if not self.dead and time > self.next_heal:
|
if time > self.next_heal:
|
||||||
self.wound -= HEAL_SPEED / self.spin_speed / HERO_HP
|
self.wound -= HEAL_SPEED / self.spin_speed / HERO_HP
|
||||||
if self.wound < 0: self.wound = 0.0
|
if self.wound < 0: self.wound = 0.0
|
||||||
|
|
||||||
|
@ -82,10 +83,7 @@ class Hero:
|
||||||
self.angle = atan2(y - self.y, x - self.x)
|
self.angle = atan2(y - self.y, x - self.x)
|
||||||
self.spin_queue = 0.0
|
self.spin_queue = 0.0
|
||||||
trigon = regpoly(3, self.R, self.angle, self.x, self.y)
|
trigon = regpoly(3, self.R, self.angle, self.x, self.y)
|
||||||
try:
|
fill_aapolygon(self.surface, trigon, self.color[int(self.wound)])
|
||||||
fill_aapolygon(self.surface, trigon, self.color[int(self.wound)])
|
|
||||||
except IndexError: # When the hero is wounded over his HP
|
|
||||||
self.wound = HERO_HP
|
|
||||||
|
|
||||||
def die(self):
|
def die(self):
|
||||||
"""Handle the hero's death."""
|
"""Handle the hero's death."""
|
||||||
|
|
|
@ -63,6 +63,6 @@ ENEMIES = ['Butter', 'Orange', 'Chocolate', 'Chameleon',
|
||||||
'SkyBlue', 'Plum', 'ScarletRed']
|
'SkyBlue', 'Plum', 'ScarletRed']
|
||||||
MINW, MAXW = 24, 36
|
MINW, MAXW = 24, 36
|
||||||
ENEMY_HP = 3
|
ENEMY_HP = 3
|
||||||
HERO_HP = 6
|
HERO_HP = 5
|
||||||
BG_COLOR = TANGO['Aluminium'][-1]
|
BG_COLOR = TANGO['Aluminium'][-1]
|
||||||
FG_COLOR = TANGO['Aluminium'][0]
|
FG_COLOR = TANGO['Aluminium'][0]
|
||||||
|
|
|
@ -186,7 +186,7 @@ class Maze:
|
||||||
< self.enemy_weights[color])
|
< self.enemy_weights[color])
|
||||||
time = pygame.time.get_ticks()
|
time = pygame.time.get_ticks()
|
||||||
if (color == 'Butter' or color == 'ScarletRed') and fx:
|
if (color == 'Butter' or color == 'ScarletRed') and fx:
|
||||||
self.hero.wound += 1.0
|
self.hero.wound += wound * 2.5
|
||||||
elif color == 'Orange' and fx:
|
elif color == 'Orange' and fx:
|
||||||
self.hero.next_heal = max(self.hero.next_heal, time) + wound*1000
|
self.hero.next_heal = max(self.hero.next_heal, time) + wound*1000
|
||||||
elif color == 'SkyBlue' and fx:
|
elif color == 'SkyBlue' and fx:
|
||||||
|
@ -195,6 +195,7 @@ class Maze:
|
||||||
self.hero.wound += wound
|
self.hero.wound += wound
|
||||||
if self.enemy_weights[color] + wound < MAXW:
|
if self.enemy_weights[color] + wound < MAXW:
|
||||||
self.enemy_weights[color] += wound
|
self.enemy_weights[color] += wound
|
||||||
|
if self.hero.wound > HERO_HP: self.lose()
|
||||||
|
|
||||||
def slash(self):
|
def slash(self):
|
||||||
"""Handle close-range attacks."""
|
"""Handle close-range attacks."""
|
||||||
|
@ -288,7 +289,6 @@ class Maze:
|
||||||
pygame.display.flip()
|
pygame.display.flip()
|
||||||
pygame.display.set_caption('Brutal Maze - Score: {}'.format(
|
pygame.display.set_caption('Brutal Maze - Score: {}'.format(
|
||||||
int(self.score - INIT_SCORE)))
|
int(self.score - INIT_SCORE)))
|
||||||
if self.hero.wound + 1 > HERO_HP: self.lose()
|
|
||||||
|
|
||||||
def move(self, x, y, fps):
|
def move(self, x, y, fps):
|
||||||
"""Command the hero to move faster in the given direction."""
|
"""Command the hero to move faster in the given direction."""
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -7,7 +7,7 @@ with open('README.rst') as f:
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='brutalmaze',
|
name='brutalmaze',
|
||||||
version='0.2.0',
|
version='0.2.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