From 6e5cd9084b1a4d9db970a1dbbdf20930c40a870d Mon Sep 17 00:00:00 2001 From: Nicolas Margulies Date: Fri, 6 Nov 2020 17:02:59 +0100 Subject: [PATCH] Finished cleaning conflicts --- dungeonbattle/game.py | 4 ++-- dungeonbattle/mapdisplay.py | 7 +------ main.py | 7 ++++++- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/dungeonbattle/game.py b/dungeonbattle/game.py index e974e41..77daf35 100644 --- a/dungeonbattle/game.py +++ b/dungeonbattle/game.py @@ -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) diff --git a/dungeonbattle/mapdisplay.py b/dungeonbattle/mapdisplay.py index fb977a0..d61b7e6 100644 --- a/dungeonbattle/mapdisplay.py +++ b/dungeonbattle/mapdisplay.py @@ -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 diff --git a/main.py b/main.py index a3c6f79..56cc77c 100755 --- a/main.py +++ b/main.py @@ -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)