2017-10-12 15:29:55 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
2017-10-16 17:12:32 +02:00
|
|
|
# constants.py - module for shared constants
|
2018-02-27 14:39:28 +01:00
|
|
|
# Copyright (C) 2017, 2018 Nguyễn Gia Phong
|
2017-10-12 15:29:55 +02:00
|
|
|
#
|
2018-02-27 14:39:28 +01:00
|
|
|
# This file is part of Brutal Maze.
|
2017-10-12 15:29:55 +02:00
|
|
|
#
|
2018-02-27 14:39:28 +01:00
|
|
|
# Brutal Maze is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Affero General Public License as
|
|
|
|
# published by the Free Software Foundation, either version 3 of the
|
|
|
|
# License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# Brutal Maze is distributed in the hope that it will be useful,
|
2017-10-12 15:29:55 +02:00
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2018-02-27 14:39:28 +01:00
|
|
|
# GNU Affero General Public License for more details.
|
2017-10-12 15:29:55 +02:00
|
|
|
#
|
2018-02-27 14:39:28 +01:00
|
|
|
# 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/>.
|
2017-10-12 15:29:55 +02:00
|
|
|
|
2018-02-27 14:39:28 +01:00
|
|
|
__doc__ = 'Brutal Maze module for shared constants'
|
2017-10-16 17:12:32 +02:00
|
|
|
|
2018-02-26 15:02:11 +01:00
|
|
|
from string import ascii_lowercase
|
|
|
|
|
2018-02-19 10:55:55 +01:00
|
|
|
from pkg_resources import resource_filename as pkg_file
|
|
|
|
import pygame
|
2018-02-12 06:17:39 +01:00
|
|
|
from pygame.mixer import Sound
|
|
|
|
|
2018-02-19 10:55:55 +01:00
|
|
|
SETTINGS = pkg_file('brutalmaze', 'settings.ini')
|
|
|
|
ICON = pygame.image.load(pkg_file('brutalmaze', 'icon.png'))
|
|
|
|
MUSIC = pkg_file('brutalmaze', 'soundfx/music.ogg')
|
2018-05-22 16:15:01 +02:00
|
|
|
NOISE = pkg_file('brutalmaze', 'soundfx/noise.ogg')
|
2018-02-19 10:55:55 +01:00
|
|
|
|
|
|
|
mixer = pygame.mixer.get_init()
|
|
|
|
if mixer is None: pygame.mixer.init(frequency=44100)
|
|
|
|
SFX_SPAWN = Sound(pkg_file('brutalmaze', 'soundfx/spawn.ogg'))
|
|
|
|
SFX_SLASH_ENEMY = Sound(pkg_file('brutalmaze', 'soundfx/slash-enemy.ogg'))
|
|
|
|
SFX_SLASH_HERO = Sound(pkg_file('brutalmaze', 'soundfx/slash-hero.ogg'))
|
|
|
|
SFX_SHOT_ENEMY = Sound(pkg_file('brutalmaze', 'soundfx/shot-enemy.ogg'))
|
|
|
|
SFX_SHOT_HERO = Sound(pkg_file('brutalmaze', 'soundfx/shot-hero.ogg'))
|
|
|
|
SFX_MISSED = Sound(pkg_file('brutalmaze', 'soundfx/missed.ogg'))
|
|
|
|
SFX_HEART = Sound(pkg_file('brutalmaze', 'soundfx/heart.ogg'))
|
|
|
|
SFX_LOSE = Sound(pkg_file('brutalmaze', 'soundfx/lose.ogg'))
|
|
|
|
if mixer is None: pygame.mixer.quit()
|
2017-12-17 11:05:17 +01:00
|
|
|
|
2017-10-12 15:29:55 +02:00
|
|
|
SQRT2 = 2 ** 0.5
|
2017-11-02 15:39:06 +01:00
|
|
|
INIT_SCORE = 5**0.5/2 + 0.5 # golden mean
|
2018-06-23 19:00:50 +02:00
|
|
|
ROAD_WIDTH = 3 # grids
|
|
|
|
WALL_WIDTH = 4 # grids
|
|
|
|
CELL_WIDTH = WALL_WIDTH + ROAD_WIDTH*2 # grids
|
|
|
|
CELL_NODES = ROAD_WIDTH, ROAD_WIDTH + WALL_WIDTH, 0
|
|
|
|
MAZE_SIZE = 10 # cells
|
|
|
|
MIDDLE = MAZE_SIZE // 2 * CELL_WIDTH
|
2017-10-22 12:07:05 +02:00
|
|
|
HEAL_SPEED = 1 # HP/s
|
2017-10-26 16:37:21 +02:00
|
|
|
HERO_SPEED = 5 # grid/s
|
|
|
|
ENEMY_SPEED = 6 # grid/s
|
|
|
|
BULLET_SPEED = 15 # grid/s
|
2018-03-06 15:01:27 +01:00
|
|
|
ATTACK_SPEED = 333.333 # ms/strike
|
2017-10-26 16:37:21 +02:00
|
|
|
FIRANGE = 6 # grids
|
|
|
|
BULLET_LIFETIME = 1000.0 * FIRANGE / (BULLET_SPEED-HERO_SPEED) # ms
|
2017-10-15 12:50:06 +02:00
|
|
|
EMPTY, WALL, HERO, ENEMY = range(4)
|
2018-05-20 15:33:50 +02:00
|
|
|
ADJACENTS = (1, 0), (0, 1), (-1, 0), (0, -1)
|
|
|
|
CORNERS = (1, 1), (-1, 1), (-1, -1), (1, -1)
|
|
|
|
AROUND_HERO = set((MIDDLE + x, MIDDLE + y) for x, y in ADJACENTS + CORNERS)
|
2017-10-12 15:29:55 +02:00
|
|
|
|
|
|
|
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)),
|
2017-11-12 15:08:14 +01:00
|
|
|
'SkyBlue': ((114, 159, 207), (52, 101, 164), (32, 74, 135)),
|
2017-10-12 15:29:55 +02:00
|
|
|
'Plum': ((173, 127, 168), (117, 80, 123), (92, 53, 102)),
|
2017-11-12 15:08:14 +01:00
|
|
|
'ScarletRed': ((239, 41, 41), (204, 0, 0), (164, 0, 0)),
|
2017-10-12 15:29:55 +02:00
|
|
|
'Aluminium': ((238, 238, 236), (211, 215, 207), (186, 189, 182),
|
|
|
|
(136, 138, 133), (85, 87, 83), (46, 52, 54))}
|
2018-05-22 15:44:22 +02:00
|
|
|
TANGO_VALUES = list(TANGO.values())
|
2017-11-12 15:08:14 +01:00
|
|
|
ENEMIES = ['Butter', 'Orange', 'Chocolate', 'Chameleon',
|
|
|
|
'SkyBlue', 'Plum', 'ScarletRed']
|
2018-02-26 15:02:11 +01:00
|
|
|
COLOR_CODE = ascii_lowercase + '0'
|
|
|
|
COLORS = {c: COLOR_CODE[i] for i, c in enumerate(
|
|
|
|
color for code in ENEMIES + ['Aluminium'] for color in TANGO[code])}
|
2017-11-19 06:10:45 +01:00
|
|
|
MINW, MAXW = 24, 36
|
2017-10-22 12:07:05 +02:00
|
|
|
ENEMY_HP = 3
|
2017-11-24 14:43:47 +01:00
|
|
|
HERO_HP = 5
|
2018-01-22 17:29:22 +01:00
|
|
|
MIN_BEAT = 526
|
2017-10-12 15:29:55 +02:00
|
|
|
BG_COLOR = TANGO['Aluminium'][-1]
|
|
|
|
FG_COLOR = TANGO['Aluminium'][0]
|