Finished cleaning conflicts

This commit is contained in:
Nicolas Margulies 2020-11-06 17:02:59 +01:00
parent 065f648118
commit 6e5cd9084b
3 changed files with 9 additions and 9 deletions

View File

@ -18,10 +18,10 @@ class Game:
def new_game(self):
# TODO generate a new map procedurally
self.m = Map.load("example_map.txt")
self.d = MapDisplay(self.m)
self.player = Player()
self.player.y = 1
self.player.x = 6
self.d = MapDisplay(self.m, self.player)
@classmethod
def load_game(filename):
@ -32,7 +32,7 @@ class Game:
while True:
screen.clear()
screen.refresh()
self.d.display(self.player.getPosY(), self.player.getPosX())
self.d.display(self.player.y, self.player.x)
key = screen.getkey()
self.handle_key_pressed(key)

View File

@ -5,23 +5,18 @@ from typing import Any
from dungeonbattle.interfaces import Map
<<<<<<< HEAD
def __init__(self, m: Map):
self.map = m
self.pad = curses.newpad(m.height, m.width+1)
=======
class MapDisplay:
def __init__(self, m: Map, player: Any):
# TODO Type the player field with the good type
self.map = m
self.pad = curses.newpad(m.height, m.width + 1)
self.player = player
>>>>>>> master
def update_pad(self) -> None:
self.pad.addstr(0, 0, self.map.draw_string())
for e in self.map.entities:
self.pad.addch(e.y, e.x, e.img)
self.pad.addstr(self.player.y, self.player.x, '🐿️')
def display(self, y: int, x: int) -> None:
deltay, deltax = (curses.LINES // 2) + 1, (curses.COLS // 2) + 1

View File

@ -1,5 +1,10 @@
#!/usr/bin/env python
from dungeonbattle.game import Game
from dungeonbattle.term_manager import TermManager
if __name__ == "__main__":
Game().init()
with TermManager() as term_manager:
game = Game()
game.init()
game.new_game()
game.run(term_manager.screen)