rpg-szi/server.py

22 lines
696 B
Python
Raw Normal View History

from model import GameMap
from mesa.visualization.modules import CanvasGrid
from mesa.visualization.ModularVisualization import ModularServer
def player_representation(agent):
portrayal = {"Shape": "sprites/hero.png",
"Layer": 1}
if agent.isBox:
portrayal["Shape"] = "sprites/box.png"
portrayal["Layer"] = 0
elif agent.isCreature:
2021-03-31 01:55:17 +02:00
portrayal["Shape"]='sprites/goblin.png'
return portrayal
grid = CanvasGrid(player_representation, 10, 10, 500, 500)
server = ModularServer(GameMap,
[grid],
"Map",
{"x":10, "y":10})
server.port = 8080
server.launch()