added sprites and made them render as agents in visualisation

This commit is contained in:
Niebby 2021-03-28 15:23:14 +02:00
parent 020b1aa6a1
commit b39c20da5f
3 changed files with 4 additions and 7 deletions

View File

@ -4,14 +4,11 @@ from mesa.visualization.ModularVisualization import ModularServer
def player_representation(agent):
portrayal = {"Shape": "circle",
"Filled": "true",
"Layer": 0,
"Color": "red",
"r": 0.5}
portrayal = {"Shape": "sprites/hero.png",
"Layer": 1}
if agent.isBox:
portrayal["Color"] = "grey"
portrayal["Layer"] = 1
portrayal["Shape"] = "sprites/box.png"
portrayal["Layer"] = 0
return portrayal
grid = CanvasGrid(player_representation, 10, 10, 500, 500)

BIN
sprites/box.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 B

BIN
sprites/hero.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B