added sprites and made them render as agents in visualisation
This commit is contained in:
parent
020b1aa6a1
commit
b39c20da5f
11
server.py
11
server.py
@ -4,14 +4,11 @@ from mesa.visualization.ModularVisualization import ModularServer
|
|||||||
|
|
||||||
|
|
||||||
def player_representation(agent):
|
def player_representation(agent):
|
||||||
portrayal = {"Shape": "circle",
|
portrayal = {"Shape": "sprites/hero.png",
|
||||||
"Filled": "true",
|
"Layer": 1}
|
||||||
"Layer": 0,
|
|
||||||
"Color": "red",
|
|
||||||
"r": 0.5}
|
|
||||||
if agent.isBox:
|
if agent.isBox:
|
||||||
portrayal["Color"] = "grey"
|
portrayal["Shape"] = "sprites/box.png"
|
||||||
portrayal["Layer"] = 1
|
portrayal["Layer"] = 0
|
||||||
return portrayal
|
return portrayal
|
||||||
|
|
||||||
grid = CanvasGrid(player_representation, 10, 10, 500, 500)
|
grid = CanvasGrid(player_representation, 10, 10, 500, 500)
|
||||||
|
BIN
sprites/box.png
Normal file
BIN
sprites/box.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 153 B |
BIN
sprites/hero.png
Normal file
BIN
sprites/hero.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 221 B |
Loading…
Reference in New Issue
Block a user