2021-03-13 17:41:38 +01:00
|
|
|
from model import GameMap
|
|
|
|
from mesa.visualization.modules import CanvasGrid
|
|
|
|
from mesa.visualization.ModularVisualization import ModularServer
|
|
|
|
|
|
|
|
|
2021-03-16 15:36:24 +01:00
|
|
|
def player_representation(agent):
|
2021-03-28 15:23:14 +02:00
|
|
|
portrayal = {"Shape": "sprites/hero.png",
|
2021-04-13 23:08:57 +02:00
|
|
|
"Layer": 1}
|
2021-03-16 15:36:24 +01:00
|
|
|
if agent.isBox:
|
2021-03-28 15:23:14 +02:00
|
|
|
portrayal["Shape"] = "sprites/box.png"
|
|
|
|
portrayal["Layer"] = 0
|
2021-03-30 14:17:54 +02:00
|
|
|
elif agent.isCreature:
|
2021-03-31 01:55:17 +02:00
|
|
|
portrayal["Shape"]='sprites/goblin.png'
|
2021-03-13 17:41:38 +01:00
|
|
|
return portrayal
|
|
|
|
|
2021-03-16 15:36:24 +01:00
|
|
|
grid = CanvasGrid(player_representation, 10, 10, 500, 500)
|
2021-03-13 17:41:38 +01:00
|
|
|
server = ModularServer(GameMap,
|
|
|
|
[grid],
|
|
|
|
"Map",
|
2021-03-30 23:36:19 +02:00
|
|
|
{"x":10, "y":10})
|
2021-04-28 03:02:59 +02:00
|
|
|
server.port = 8081
|
2021-03-13 17:41:38 +01:00
|
|
|
server.launch()
|