mirror of
https://github.com/illiumst/marl-factory-grid.git
synced 2025-05-23 07:16:44 +02:00
added X button to renderer.py
This commit is contained in:
parent
35765881ce
commit
b991e7f5fc
@ -1,4 +1,4 @@
|
|||||||
import numpy as np
|
import sys
|
||||||
import pygame
|
import pygame
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
@ -21,7 +21,6 @@ class Renderer:
|
|||||||
self.clock = pygame.time.Clock()
|
self.clock = pygame.time.Clock()
|
||||||
assets = list((Path(__file__).parent / 'assets').glob('*.png'))
|
assets = list((Path(__file__).parent / 'assets').glob('*.png'))
|
||||||
self.assets = {path.stem: self.load_asset(str(path), 0.95) for path in assets}
|
self.assets = {path.stem: self.load_asset(str(path), 0.95) for path in assets}
|
||||||
print(self.assets)
|
|
||||||
self.fill_bg()
|
self.fill_bg()
|
||||||
|
|
||||||
def fill_bg(self):
|
def fill_bg(self):
|
||||||
@ -49,6 +48,10 @@ class Renderer:
|
|||||||
return wall_img
|
return wall_img
|
||||||
|
|
||||||
def render(self, pos_dict):
|
def render(self, pos_dict):
|
||||||
|
for event in pygame.event.get():
|
||||||
|
if event.type == pygame.QUIT:
|
||||||
|
pygame.quit()
|
||||||
|
sys.exit()
|
||||||
self.fill_bg()
|
self.fill_bg()
|
||||||
for asset, positions in pos_dict.items():
|
for asset, positions in pos_dict.items():
|
||||||
for x, y in positions:
|
for x, y in positions:
|
||||||
@ -64,7 +67,7 @@ class Renderer:
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
renderer = Renderer(fps=2, cell_size=40, assets=['wall', 'agent', 'dirt'])
|
renderer = Renderer(fps=2, cell_size=40)
|
||||||
for i in range(15):
|
for i in range(15):
|
||||||
renderer.render({'agent': [(5, i)], 'wall': [(0, i), (i, 0)], 'dirt': [(3,3), (3,4)]})
|
renderer.render({'agent': [(5, i)], 'wall': [(0, i), (i, 0)], 'dirt': [(3,3), (3,4)]})
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user