-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame.py
50 lines (45 loc) · 1.44 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
import world
import vars
import player
import gui
import info
import time
from bearlibterminal import terminal
class Game(object):
def __init__(self):
self.info = info.InfoBar()
self.world = world.World(50, 50, self.info)
self.player = player.Player("Frederico", self.world)
self.world.create_enemies()
self.gui = gui.GUI(self.player)
terminal.open()
terminal.set("window: title='Frederico', size={0}x{1}".format(vars.CONSOLE_WIDTH, vars.CONSOLE_HEIGHT))
terminal.set("0xE000: resources/materials.png, size=16x16, resize=32x32, spacing=2x1")
self.game_loop()
self.quit = False
def update(self):
self.player.update()
if not self.player.died:
for e in self.world.enemies:
e.update()
if self.player.restart:
self.info = info.InfoBar()
self.world = world.World(50, 50, self.info, seed=time.time())
self.player = player.Player("Frederico", self.world)
self.world.create_enemies()
self.gui = gui.GUI(self.player)
def draw(self):
terminal.clear()
self.world.draw()
self.player.draw()
self.gui.draw()
self.info.draw()
terminal.refresh()
def game_loop(self):
self.draw()
while True:
self.update()
self.draw()
if vars.QUIT:
break
terminal.close()