Texture packs are working

This commit is contained in:
Yohann D'ANELLO
2020-11-06 17:43:30 +01:00
parent 4115363b74
commit f9dcc8f1c1
6 changed files with 61 additions and 38 deletions

View File

@ -1,25 +1,22 @@
#!/usr/bin/env python
import curses
from dungeonbattle.interfaces import Map
from dungeonbattle.settings import Settings
import .texturepack as tp
from .texturepack import TexturePack
class MapDisplay:
def __init__(self, m: Map, settings : Settings, height: int, width: int):
def __init__(self, m: Map, pack: TexturePack, height: int, width: int):
self.width = width
self.height = height
self.map = m
self.pad = curses.newpad(m.height, m.width+1)
if self.settings.TEXTURE_PACK == 'ASCII' :
self.textures = tp.ascii_textures
if self.settings.TEXTURE_PACK == 'SQUIRREL' :
self.textures = tp.squirrel_textures
self.pack = pack
def update_pad(self):
self.pad.addstr(0, 0, self.map.draw_string())
self.pad.addstr(0, 0, self.map.draw_string(self.pack))
for e in self.map.entities:
self.pad.addstr(e.y, e.x, self.textures[e.name])
self.pad.addstr(e.y, e.x, self.pack.PLAYER)
def display(self, y, x):
deltay, deltax = (self.height // 2) + 1, (self.width //2) + 1