Clean up
This commit is contained in:
parent
50a839826d
commit
06468ff9fb
|
@ -19,7 +19,6 @@
|
|||
|
||||
__doc__ = 'brutalmaze module for hero and enemy classes'
|
||||
|
||||
from collections import deque
|
||||
from math import atan, atan2, sin, pi
|
||||
from random import choice, randrange, shuffle
|
||||
from sys import modules
|
||||
|
@ -138,7 +137,7 @@ class Enemy:
|
|||
def get_pos(self):
|
||||
"""Return coordinate of the center of the enemy."""
|
||||
x, y = self.maze.get_pos(self.x, self.y)
|
||||
step = self.maze.distance * HERO_SPEED / self.maze.fps
|
||||
step = self.maze.distance * ENEMY_SPEED / self.maze.fps
|
||||
return x + self.offsetx*step, y + self.offsety*step
|
||||
|
||||
def get_distance(self):
|
||||
|
|
|
@ -19,9 +19,20 @@
|
|||
|
||||
__doc__ = 'brutalmaze module for shared constants'
|
||||
|
||||
from pygame import image, K_UP, K_w, K_LEFT, K_a, K_DOWN, K_s, K_RIGHT, K_d
|
||||
from pygame.mixer import Sound
|
||||
from os.path import join
|
||||
|
||||
from appdirs import user_config_dir, site_config_dir
|
||||
from pkg_resources import resource_filename
|
||||
from pygame import image
|
||||
from pygame.mixer import Sound
|
||||
|
||||
USER_CONFIG = join(user_config_dir('brutalmaze'), 'settings.ini')
|
||||
SITE_CONFIG = join(site_config_dir('brutalmaze'), 'settings.ini')
|
||||
DEFAULT_BINDINGS = {'New game': 'F2', 'Pause': 'p',
|
||||
'Move left': 'Left', 'Move right': 'Right',
|
||||
'Move up': 'Up', 'Move down': 'Down',
|
||||
'Long-range attack': 'Mouse1',
|
||||
'Close-range attack': 'Mouse3'}
|
||||
|
||||
ICON = image.load(resource_filename('brutalmaze', 'icon.png'))
|
||||
MUSIC = resource_filename('brutalmaze', 'soundfx/music.ogg')
|
||||
|
@ -34,16 +45,8 @@ SFX_MISSED = resource_filename('brutalmaze', 'soundfx/missed.ogg')
|
|||
SFX_HEART = resource_filename('brutalmaze', 'soundfx/heart.ogg')
|
||||
SFX_LOSE = resource_filename('brutalmaze', 'soundfx/lose.ogg')
|
||||
|
||||
UP = (K_UP, K_w)
|
||||
LEFT = (K_LEFT, K_a)
|
||||
DOWN = (K_DOWN, K_s)
|
||||
RIGHT = (K_RIGHT, K_d)
|
||||
|
||||
SQRT2 = 2 ** 0.5
|
||||
INIT_SCORE = 5**0.5/2 + 0.5 # golden mean
|
||||
INIT_FPS = 30.0
|
||||
MAX_FPS = 60.0
|
||||
SIZE = 640, 480
|
||||
MAZE_SIZE = 10
|
||||
ROAD_WIDTH = 5 # grids
|
||||
CELL_WIDTH = ROAD_WIDTH * 2 # grids
|
||||
|
|
|
@ -23,26 +23,14 @@ try: # Python 3
|
|||
from configparser import ConfigParser, NoOptionError, NoSectionError
|
||||
except ImportError: # Python 2
|
||||
from ConfigParser import ConfigParser, NoOptionError, NoSectionError
|
||||
from os.path import join
|
||||
|
||||
from appdirs import user_config_dir, site_config_dir
|
||||
from pkg_resources import resource_filename
|
||||
import pygame
|
||||
from pygame import DOUBLEBUF, KEYDOWN, OPENGL, QUIT, RESIZABLE, VIDEORESIZE
|
||||
|
||||
from .constants import *
|
||||
from .constants import USER_CONFIG, SITE_CONFIG, DEFAULT_BINDINGS, ICON, MUSIC
|
||||
from .maze import Maze
|
||||
|
||||
|
||||
USER_CONFIG = join(user_config_dir('brutalmaze'), 'settings.ini')
|
||||
SITE_CONFIG = join(site_config_dir('brutalmaze'), 'settings.ini')
|
||||
DEFAULT_BINDINGS = {'New game': 'F2', 'Pause': 'p',
|
||||
'Move left': 'Left', 'Move right': 'Right',
|
||||
'Move up': 'Up', 'Move down': 'Down',
|
||||
'Long-range attack': 'Mouse1',
|
||||
'Close-range attack': 'Mouse3'}
|
||||
|
||||
|
||||
def getconf(config, section, option, valtype=str, fallback=None):
|
||||
"""Return an option value for a given section from a ConfigParser
|
||||
object.
|
||||
|
@ -77,7 +65,7 @@ def main():
|
|||
scrtype = RESIZABLE
|
||||
if getconf(config, 'Graphics', 'OpenGL', bool):
|
||||
scrtype |= OPENGL | DOUBLEBUF
|
||||
fps = getconf(config, 'Graphics', 'Maximum FPS', float, 60.0)
|
||||
fps = max_fps = getconf(config, 'Graphics', 'Maximum FPS', float, 60.0)
|
||||
|
||||
# Read control configurations
|
||||
key, mouse = {}, {}
|
||||
|
@ -144,7 +132,7 @@ def main():
|
|||
flash_time.popleft()
|
||||
if new_fps < fps:
|
||||
fps -= 1
|
||||
elif fps < MAX_FPS and not maze.paused:
|
||||
elif fps < max_fps and not maze.paused:
|
||||
fps += 5
|
||||
maze.update(fps)
|
||||
flash_time.append(pygame.time.get_ticks())
|
||||
|
|
|
@ -25,8 +25,6 @@ from random import uniform
|
|||
import pygame
|
||||
from pygame.gfxdraw import filled_polygon, aapolygon
|
||||
|
||||
from .constants import MIDDLE
|
||||
|
||||
|
||||
def round2(number):
|
||||
"""Round a number to an int."""
|
||||
|
|
4
setup.py
4
setup.py
|
@ -15,7 +15,7 @@ setup(
|
|||
author_email='vn.mcsinyx@gmail.com',
|
||||
license='GPLv3+',
|
||||
classifiers=[
|
||||
'Development Status :: 3 - Alpha',
|
||||
'Development Status :: 4 - Beta',
|
||||
'Environment :: MacOS X',
|
||||
'Environment :: Win32 (MS Windows)',
|
||||
'Environment :: X11 Applications',
|
||||
|
@ -28,5 +28,5 @@ setup(
|
|||
keywords='pygame action-game arcade-game maze',
|
||||
packages=['brutalmaze'],
|
||||
install_requires=['appdirs', 'pygame>=1.9'],
|
||||
package_data={'brutalmaze': ['icon.png', 'soundfx/*.ogg', 'settings.ini']},
|
||||
package_data={'brutalmaze': ['icon.png', 'soundfx/*.ogg']},
|
||||
entry_points={'gui_scripts': ['brutalmaze = brutalmaze:main']})
|
||||
|
|
Loading…
Reference in New Issue