# -*- coding: utf-8 -*- # constants.py - module for shared constants # This file is part of brutalmaze # # brutalmaze is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # brutalmaze is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with brutalmaze. If not, see . # # Copyright (C) 2017 Nguyễn Gia Phong __doc__ = 'brutalmaze module for shared constants' 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') SFX_SPAWN = resource_filename('brutalmaze', 'soundfx/spawn.ogg') SFX_SLASH_ENEMY = resource_filename('brutalmaze', 'soundfx/slash-enemy.ogg') SFX_SLASH_HERO = resource_filename('brutalmaze', 'soundfx/slash-hero.ogg') SFX_SHOT_ENEMY = resource_filename('brutalmaze', 'soundfx/shot-enemy.ogg') SFX_SHOT_HERO = resource_filename('brutalmaze', 'soundfx/shot-hero.ogg') SFX_MISSED = resource_filename('brutalmaze', 'soundfx/missed.ogg') SFX_HEART = resource_filename('brutalmaze', 'soundfx/heart.ogg') SFX_LOSE = resource_filename('brutalmaze', 'soundfx/lose.ogg') SQRT2 = 2 ** 0.5 INIT_SCORE = 5**0.5/2 + 0.5 # golden mean MAZE_SIZE = 10 ROAD_WIDTH = 5 # grids CELL_WIDTH = ROAD_WIDTH * 2 # grids MIDDLE = (MAZE_SIZE + MAZE_SIZE%2 - 1)*ROAD_WIDTH + ROAD_WIDTH//2 LAST_ROW = (MAZE_SIZE-1) * ROAD_WIDTH * 2 HEAL_SPEED = 1 # HP/s HERO_SPEED = 5 # grid/s ENEMY_SPEED = 6 # grid/s BULLET_SPEED = 15 # grid/s ATTACK_SPEED = 333 # ms/strike FIRANGE = 6 # grids BULLET_LIFETIME = 1000.0 * FIRANGE / (BULLET_SPEED-HERO_SPEED) # ms EMPTY, WALL, HERO, ENEMY = range(4) ADJACENT_GRIDS = (1, 0), (0, 1), (-1, 0), (0, -1) AROUND_HERO = set((MIDDLE + x, MIDDLE + y) for x, y in ADJACENT_GRIDS + ((1, 1), (-1, 1), (-1, -1), (1, -1))) TANGO = {'Butter': ((252, 233, 79), (237, 212, 0), (196, 160, 0)), 'Orange': ((252, 175, 62), (245, 121, 0), (206, 92, 0)), 'Chocolate': ((233, 185, 110), (193, 125, 17), (143, 89, 2)), 'Chameleon': ((138, 226, 52), (115, 210, 22), (78, 154, 6)), 'SkyBlue': ((114, 159, 207), (52, 101, 164), (32, 74, 135)), 'Plum': ((173, 127, 168), (117, 80, 123), (92, 53, 102)), 'ScarletRed': ((239, 41, 41), (204, 0, 0), (164, 0, 0)), 'Aluminium': ((238, 238, 236), (211, 215, 207), (186, 189, 182), (136, 138, 133), (85, 87, 83), (46, 52, 54))} ENEMIES = ['Butter', 'Orange', 'Chocolate', 'Chameleon', 'SkyBlue', 'Plum', 'ScarletRed'] MINW, MAXW = 24, 36 ENEMY_HP = 3 HERO_HP = 5 MIN_BEAT = 526 BG_COLOR = TANGO['Aluminium'][-1] FG_COLOR = TANGO['Aluminium'][0]