Use map display
This commit is contained in:
		@@ -1,4 +1,5 @@
 | 
			
		||||
from .interfaces import Map
 | 
			
		||||
from .mapdisplay import MapDisplay
 | 
			
		||||
from .term_manager import TermManager
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -13,8 +14,10 @@ class Game:
 | 
			
		||||
    def _start_game(self, screen):
 | 
			
		||||
        # TODO Generate map, or make the possibility to load another one
 | 
			
		||||
        m = Map.load("example_map.txt")
 | 
			
		||||
        d = MapDisplay(m)
 | 
			
		||||
        screen.refresh()
 | 
			
		||||
        while True:
 | 
			
		||||
            screen.addstr(0, 0, m.draw_string())
 | 
			
		||||
            d.display(1, 6)
 | 
			
		||||
            screen.refresh()
 | 
			
		||||
            key = screen.getkey()
 | 
			
		||||
            self.handle_key_pressed(key)
 | 
			
		||||
 
 | 
			
		||||
@@ -9,8 +9,7 @@ class MapDisplay:
 | 
			
		||||
        self.pad = curses.newpad(m.height, m.width+1)
 | 
			
		||||
 | 
			
		||||
    def update_pad(self):
 | 
			
		||||
        for i in range(self.map.height):
 | 
			
		||||
            self.pad.addstr(i, 0, self.map.tiles[i])
 | 
			
		||||
        self.pad.addstr(0, 0, self.map.draw_string())
 | 
			
		||||
        for e in self.map.entities:
 | 
			
		||||
            self.pad.addch(e.y, e.x, e.img)
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user