fullwidth characters work now too

This commit is contained in:
troido 2017-10-24 16:33:17 +02:00
parent 31d9ac0778
commit d2d6448793
4 changed files with 39 additions and 5 deletions

View File

@ -82,6 +82,7 @@ The idea is to make 3 different kind of areas:
## DONE
- fullwidth characters as sprites
- load world from files
- more content (rooms, objects etc)
- multiple socket types (regular unix, abstract unix, inet), selectable as command line arguments

View File

@ -26,5 +26,6 @@
"troll": "T",
" ": " "
},
"default": "?"
"default": "?",
"charwidth": 1
}

View File

@ -45,7 +45,8 @@ class Client:
self.fieldHeight = 0
self.characters = characters["mapping"]
self.defaultChar = characters["default"]
self.defaultChar = characters.get("default", '?')
self.charWidth = characters.get("charwidth", 1)
threading.Thread(target=self.listen, daemon=True).start()
self.command_loop()
@ -79,12 +80,12 @@ class Client:
) for y in range(self.fieldHeight)
)
if outputstring != self.lastoutputstring:
self.screen.put(outputstring, self.fieldWidth, self.fieldHeight)
self.screen.put(outputstring, self.fieldWidth*self.charWidth, self.fieldHeight)
self.lastoutputstring = outputstring
if 'changecells' in data and len(data['changecells']):
self.screen.changeCells((
(x, y, self.characters.get(sprite, self.defaultChar))
(x*self.charWidth, y, self.characters.get(sprite, self.defaultChar))
for ((x, y), sprite) in data['changecells']
), self.fieldWidth, self.fieldHeight)
@ -92,7 +93,7 @@ class Client:
infostring = json.dumps(data['info'], indent=2)
infostring += "\n\n" + self.controlsString
if infostring != self.lastinfostring:
self.screen.putPlayers(infostring, self.fieldWidth+2)
self.screen.putPlayers(infostring, self.fieldWidth*self.charWidth+2)
self.lastinfostring = infostring
self.screen.refresh()

31
client/fullwidth.json Normal file
View File

@ -0,0 +1,31 @@
{
"mapping":{
"tree": "",
"wall": "",
"rock": "",
"stone": "",
"pebble": "",
"player": "",
"ground": "",
"grass1": "",
"grass2": "",
"grass3": "",
"rabbit": "",
"water": "",
"floor": "",
"portal": "",
"stairdown": "",
"stairup": "",
"dummy": "",
"spikes": "",
"goblin": "",
"seed": "",
"plant": "",
"youngplant": "",
"food": "",
"troll": "",
" ": " "
},
"default": "",
"charwidth": 2
}