-
Notifications
You must be signed in to change notification settings - Fork 0
/
game.py
101 lines (83 loc) · 2.74 KB
/
game.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import tcod as libtcod
from collections import namedtuple
from entity import Entity
from dijkstra import Neighborhood
from game_state_machine import GameStateMachine
from map_functions import GameMap
from systems.factory import create_monster
from systems.message_log import MessageLog
COLORS = { 'dark_floor': libtcod.light_blue,
'dark_wall': libtcod.dark_blue,
'light_floor': libtcod.light_yellow,
'light_wall': libtcod.dark_yellow,
'hud_border_fg': libtcod.light_grey,
'hud_text': libtcod.white,
'hud_skill_description': libtcod.lime,
'status_stunned': libtcod.purple,
'message_very_good': libtcod.cyan,
'message_good': libtcod.green,
'message_ok': libtcod.white,
'message_bad': libtcod.crimson,
'message_very_bad': libtcod.red,
'message_kill': libtcod.darker_red}
FOV_RADIUS = 10
GAME_TITLE = 'Anima Mea v0.1.2'
' Console constants. '
Console = namedtuple('Console', ['X', 'Y', 'W', 'H'])
ROOT = Console(
X=0,
Y=0,
W=100,
H=60)
MAP = Console(
X=0,
Y=0,
W=100,
H=42)
LOG = Console(
X=16,
Y=43,
W=83,
H=16)
INFO = Console(
X=1,
Y=43,
W=14,
H=7)
ITEMMENU = Console(
X=1,
Y=51,
W=14,
H=8)
def initialize_new_game():
# Create player entity.
player = create_monster('player')
# Fill entities list.
entities = []
entities.append(player)
# Create consoles.
libtcod.console_set_custom_font('rexpaint_cp437_10x10.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_CP437)
consoles = {}
consoles['root'] = libtcod.console_init_root(ROOT.W, ROOT.H, title=GAME_TITLE, order='F')
consoles['map'] = libtcod.console.Console(MAP.W, MAP.H, order='F')
consoles['log'] = libtcod.console.Console(LOG.W, LOG.H, order='F')
consoles['info'] = libtcod.console.Console(INFO.W, INFO.H, order='F')
consoles['item_menu'] = libtcod.console.Console(ITEMMENU.W, ITEMMENU.H, order='F')
# Create other basic functions.
game = GameThing()
game_map = GameMap(MAP.W, MAP.H, FOV_RADIUS, 1)
key = libtcod.Key()
message_log = MessageLog(LOG.W, LOG.H)
mouse = libtcod.Mouse()
# Create a first map.
game_map.generate_new_map(entities, player)
# Create game state machine.
game_state_machine = GameStateMachine()
# Create a neighborhood.
neighborhood = Neighborhood(game_map)
neighborhood.update_dijkstra_map(entities, (player.pos.x, player.pos.y))
return consoles, entities, game, game_map, game_state_machine, key, message_log, mouse, neighborhood, player
class GameThing:
def __init__(self):
self.debug_mode = False
self.redraw_map = False