-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
114 lines (105 loc) · 3.97 KB
/
main.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
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/usr/bin/python3.2
from levelManager import levelManager
from entity import Player, Enemy, Zombie, Item
import sys
from UniCurses12.unicurses import cbreak, clear, curs_set, endwin, initscr, keypad, refresh, noecho, start_color, stdscr, getch, erase, mvaddch
import UniCurses12.unicurses as unicurses
from worldManager import worldManager
import config
import os
from camera import Camera
from religion import Pantheon
"""
The main loop. The magic all happens here.
Each iteration of the while loop has currentLevel
progress() once through its timeline, updating all
actors in that quantum. The screen is drawn right
before the players' quanta.
"""
try:
# Turn on terminal 256-color mode
try:
bool(os.environ['TERM']) #?
except KeyError:
# os.environ['TERM'] = foo
pass
os.environ['TERM'] = "xterm-256color"
os.environ["ESCDELAY"] = "25"
# Curses set-up
stdscr = initscr()
start_color()
noecho()
cbreak()
curs_set(0)
keypad(stdscr, True)
ESCDELAY = 100
start_color()
# Set up the global colorPalette
for i in range(0, 256):
config.colorPalette.update({i:[i, i, unicurses.COLOR_BLACK]})
config.colorDict.update({str(i):i})
for entry in config.colorPalette:
unicurses.init_pair(config.colorPalette[entry][0], config.colorPalette[entry][1], config.colorPalette[entry][2])
# Main menu
erase()
selected = 0
temp_camera = Camera(51, 19, None)
temp_camera.drawHUDBoundaries()
while(True):
if(selected == 0):
unicurses.attron(unicurses.COLOR_PAIR(config.colorDict["white"]))
unicurses.mvaddstr(1, 1, "New game")
unicurses.attroff(unicurses.COLOR_PAIR(config.colorDict["white"]))
else:
unicurses.attron(unicurses.COLOR_PAIR(config.colorDict["g12"]))
unicurses.mvaddstr(1, 1, "New game")
unicurses.attroff(unicurses.COLOR_PAIR(config.colorDict["g12"]))
if(selected == 1):
unicurses.attron(unicurses.COLOR_PAIR(config.colorDict["white"]))
unicurses.mvaddstr(2, 1, "Load game")
unicurses.attroff(unicurses.COLOR_PAIR(config.colorDict["white"]))
else:
unicurses.attron(unicurses.COLOR_PAIR(config.colorDict["g12"]))
unicurses.mvaddstr(2, 1, "Load game")
unicurses.attroff(unicurses.COLOR_PAIR(config.colorDict["g12"]))
if(selected == 2):
unicurses.attron(unicurses.COLOR_PAIR(config.colorDict["white"]))
unicurses.mvaddstr(3, 1, "Credits")
unicurses.attroff(unicurses.COLOR_PAIR(config.colorDict["white"]))
else:
unicurses.attron(unicurses.COLOR_PAIR(config.colorDict["g12"]))
unicurses.mvaddstr(3, 1, "Credits")
unicurses.attroff(unicurses.COLOR_PAIR(config.colorDict["g12"]))
lineIn = unicurses.wgetch(stdscr)
if(lineIn == unicurses.KEY_DOWN or lineIn == 'j'):
selected = (selected + 1) % 3
elif(lineIn == unicurses.KEY_UP or lineIn == 'k'):
selected = (selected - 1) % 3
# enter = 10, esc = 27; why? no clue
elif(lineIn == 10 or lineIn == unicurses.KEY_ENTER or lineIn == ' ' or lineIn == unicurses.KEY_LEFT or lineIn == unicurses.KEY_RIGHT):
if(selected == 0):
# Game world set-up
world = worldManager()
config.world = world
world.pantheon = Pantheon()
#stdscr.refresh()
refresh()
# Main loop
while(True):
world.update()
elif(selected == 1):
# Game world load
world = worldManager()
world.load()
config.world = world
#stdscr.refresh()
refresh()
# Main loop
while(True):
world.update()
except:
#os.environ['TERM'] = "xterm"
clear()
refresh()
endwin()
raise