Finished cleaning conflicts
This commit is contained in:
parent
065f648118
commit
6e5cd9084b
|
@ -18,10 +18,10 @@ class Game:
|
||||||
def new_game(self):
|
def new_game(self):
|
||||||
# TODO generate a new map procedurally
|
# TODO generate a new map procedurally
|
||||||
self.m = Map.load("example_map.txt")
|
self.m = Map.load("example_map.txt")
|
||||||
self.d = MapDisplay(self.m)
|
|
||||||
self.player = Player()
|
self.player = Player()
|
||||||
self.player.y = 1
|
self.player.y = 1
|
||||||
self.player.x = 6
|
self.player.x = 6
|
||||||
|
self.d = MapDisplay(self.m, self.player)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def load_game(filename):
|
def load_game(filename):
|
||||||
|
@ -32,7 +32,7 @@ class Game:
|
||||||
while True:
|
while True:
|
||||||
screen.clear()
|
screen.clear()
|
||||||
screen.refresh()
|
screen.refresh()
|
||||||
self.d.display(self.player.getPosY(), self.player.getPosX())
|
self.d.display(self.player.y, self.player.x)
|
||||||
key = screen.getkey()
|
key = screen.getkey()
|
||||||
self.handle_key_pressed(key)
|
self.handle_key_pressed(key)
|
||||||
|
|
||||||
|
|
|
@ -5,23 +5,18 @@ from typing import Any
|
||||||
from dungeonbattle.interfaces import Map
|
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:
|
class MapDisplay:
|
||||||
def __init__(self, m: Map, player: Any):
|
def __init__(self, m: Map, player: Any):
|
||||||
# TODO Type the player field with the good type
|
# TODO Type the player field with the good type
|
||||||
self.map = m
|
self.map = m
|
||||||
self.pad = curses.newpad(m.height, m.width + 1)
|
self.pad = curses.newpad(m.height, m.width + 1)
|
||||||
self.player = player
|
self.player = player
|
||||||
>>>>>>> master
|
|
||||||
|
|
||||||
def update_pad(self) -> None:
|
def update_pad(self) -> None:
|
||||||
self.pad.addstr(0, 0, self.map.draw_string())
|
self.pad.addstr(0, 0, self.map.draw_string())
|
||||||
for e in self.map.entities:
|
for e in self.map.entities:
|
||||||
self.pad.addch(e.y, e.x, e.img)
|
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:
|
def display(self, y: int, x: int) -> None:
|
||||||
deltay, deltax = (curses.LINES // 2) + 1, (curses.COLS // 2) + 1
|
deltay, deltax = (curses.LINES // 2) + 1, (curses.COLS // 2) + 1
|
||||||
|
|
7
main.py
7
main.py
|
@ -1,5 +1,10 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
from dungeonbattle.game import Game
|
from dungeonbattle.game import Game
|
||||||
|
from dungeonbattle.term_manager import TermManager
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
Game().init()
|
with TermManager() as term_manager:
|
||||||
|
game = Game()
|
||||||
|
game.init()
|
||||||
|
game.new_game()
|
||||||
|
game.run(term_manager.screen)
|
||||||
|
|
Loading…
Reference in New Issue