Specify imports, fix frozen bullets on game-over and uniform object value export

This commit is contained in:
Nguyễn Gia Phong 2018-02-28 22:06:03 +07:00
parent 781b347fcb
commit 79ae3ed383
5 changed files with 23 additions and 14 deletions

View File

@ -23,10 +23,12 @@ from math import atan, atan2, sin, pi
from random import choice, randrange, shuffle
from sys import modules
import pygame
from pygame.time import get_ticks
from .constants import *
from .constants import (
TANGO, HERO_HP, SFX_HEART, HEAL_SPEED, MIN_BEAT, ATTACK_SPEED, ENEMY,
ENEMY_SPEED, ENEMY_HP, SFX_SLASH_HERO, MIDDLE, WALL, FIRANGE, AROUND_HERO,
ADJACENT_GRIDS, EMPTY, FG_COLOR, SQRT2, MINW)
from .misc import sign, cosin, randsign, regpoly, fill_aapolygon, choices, play
from .weapons import Bullet
@ -93,11 +95,15 @@ class Hero:
self.spin_queue = 0.0
self.angle = angle
def get_color(self):
"""Return current color of the hero."""
return self.color[int(self.wound)]
def draw(self):
"""Draw the hero."""
sides = 3 if get_ticks() >= self.next_heal else 4
trigon = regpoly(sides, self.R, self.angle, self.x, self.y)
fill_aapolygon(self.surface, trigon, self.color[int(self.wound)])
fill_aapolygon(self.surface, trigon, self.get_color())
def resize(self, maze_size):
"""Resize the hero."""

View File

@ -17,7 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with Brutal Maze. If not, see <https://www.gnu.org/licenses/>.
__version__ = '0.5.4'
__version__ = '0.5.5'
import re
from argparse import ArgumentParser, FileType, RawTextHelpFormatter
@ -26,7 +26,6 @@ try: # Python 3
from configparser import ConfigParser
except ImportError: # Python 2
from ConfigParser import ConfigParser
from itertools import repeat
from math import atan2, degrees, radians
from os.path import join, pathsep
from socket import socket, SOL_SOCKET, SO_REUSEADDR
@ -174,9 +173,9 @@ class Game:
if walls: lines.appendleft('\n'.join(''.join(str(cell) for cell in row)
for row in walls))
x, y = self.expos(maze.x, maze.y)
lines.appendleft('{} {} {} {} {} {} {:.0f} {:d} {:d}'.format(
len(walls), ne, nb, maze.get_score(), x, y, hero.wound,
hero.next_strike <= tick, hero.next_heal <= tick))
lines.appendleft('{} {} {} {} {} {} {} {:d} {:d}'.format(
len(walls), ne, nb, maze.get_score(), COLORS[hero.get_color()],
x, y, hero.next_strike <= tick, hero.next_heal <= tick))
return '\n'.join(lines).encode()
def update(self):

View File

@ -24,11 +24,14 @@ from math import pi, log
from random import choice, getrandbits, uniform
import pygame
from pygame import RESIZABLE
from pygame.time import get_ticks
from .characters import Hero, new_enemy
from .constants import *
from .constants import (
EMPTY, WALL, HERO, ROAD_WIDTH, MAZE_SIZE, MIDDLE, INIT_SCORE, ENEMIES,
MINW, MAXW, SQRT2, SFX_SPAWN, SFX_SLASH_ENEMY, SFX_LOSE, ADJACENT_GRIDS,
BG_COLOR, FG_COLOR, CELL_WIDTH, LAST_ROW, HERO_HP, ENEMY_HP, ATTACK_SPEED,
HERO_SPEED, BULLET_LIFETIME)
from .misc import round2, sign, regpoly, fill_aapolygon, play
from .weapons import Bullet
@ -323,7 +326,7 @@ class Maze:
if not self.hero.dead:
self.hero.update(fps)
self.slash()
self.track_bullets()
self.track_bullets()
def resize(self, size):
"""Resize the maze."""

View File

@ -23,7 +23,8 @@ from math import cos, sin
from pygame.time import get_ticks
from .constants import *
from .constants import (BULLET_LIFETIME, SFX_SHOT_ENEMY, SFX_SHOT_HERO,
SFX_MISSED, BULLET_SPEED, ENEMY_HP, TANGO, BG_COLOR)
from .misc import regpoly, fill_aapolygon

View File

@ -7,7 +7,7 @@ with open('README.rst') as f:
setup(
name='brutalmaze',
version='0.5.4',
version='0.5.5',
description='A minimalist hack and slash game with fast-paced action',
long_description=long_description,
url='https://github.com/McSinyx/brutalmaze',
@ -29,4 +29,4 @@ setup(
packages=['brutalmaze'],
install_requires=['appdirs', 'pygame>=1.9'],
package_data={'brutalmaze': ['icon.png', 'soundfx/*.ogg', 'settings.ini']},
entry_points={'gui_scripts': ['brutalmaze = brutalmaze:main']})
entry_points={'gui_scripts': ['brutalmaze = brutalmaze.game:main']})