Make critical close-range hits independent of FPS

This commit is contained in:
Nguyễn Gia Phong 2017-11-24 20:43:47 +07:00
parent 1578586f24
commit 4370b1531d
4 changed files with 7 additions and 9 deletions

View File

@ -63,10 +63,11 @@ class Hero:
def update(self, fps):
"""Update the hero."""
if self.dead: return
old_speed, time = self.spin_speed, pygame.time.get_ticks()
self.spin_speed = fps / (HERO_HP-self.wound**0.5)
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
if self.wound < 0: self.wound = 0.0
@ -82,10 +83,7 @@ class Hero:
self.angle = atan2(y - self.y, x - self.x)
self.spin_queue = 0.0
trigon = regpoly(3, self.R, self.angle, self.x, self.y)
try:
fill_aapolygon(self.surface, trigon, self.color[int(self.wound)])
except IndexError: # When the hero is wounded over his HP
self.wound = HERO_HP
fill_aapolygon(self.surface, trigon, self.color[int(self.wound)])
def die(self):
"""Handle the hero's death."""

View File

@ -63,6 +63,6 @@ ENEMIES = ['Butter', 'Orange', 'Chocolate', 'Chameleon',
'SkyBlue', 'Plum', 'ScarletRed']
MINW, MAXW = 24, 36
ENEMY_HP = 3
HERO_HP = 6
HERO_HP = 5
BG_COLOR = TANGO['Aluminium'][-1]
FG_COLOR = TANGO['Aluminium'][0]

View File

@ -186,7 +186,7 @@ class Maze:
< self.enemy_weights[color])
time = pygame.time.get_ticks()
if (color == 'Butter' or color == 'ScarletRed') and fx:
self.hero.wound += 1.0
self.hero.wound += wound * 2.5
elif color == 'Orange' and fx:
self.hero.next_heal = max(self.hero.next_heal, time) + wound*1000
elif color == 'SkyBlue' and fx:
@ -195,6 +195,7 @@ class Maze:
self.hero.wound += wound
if self.enemy_weights[color] + wound < MAXW:
self.enemy_weights[color] += wound
if self.hero.wound > HERO_HP: self.lose()
def slash(self):
"""Handle close-range attacks."""
@ -288,7 +289,6 @@ class Maze:
pygame.display.flip()
pygame.display.set_caption('Brutal Maze - Score: {}'.format(
int(self.score - INIT_SCORE)))
if self.hero.wound + 1 > HERO_HP: self.lose()
def move(self, x, y, fps):
"""Command the hero to move faster in the given direction."""

View File

@ -7,7 +7,7 @@ with open('README.rst') as f:
setup(
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',
long_description=long_description,
url='https://github.com/McSinyx/brutalmaze',