add impassable terrain

This commit is contained in:
s452717 2021-04-09 19:48:59 +02:00
parent edb56dac1d
commit 227a246968

View File

@ -18,6 +18,13 @@ class GameUi:
coord = 'x' if self.agent.dir in (1, 3) else 'y'
shift = -1 if self.agent.dir in (2, 3) else 1
# print(coord, shift)
test = int(getattr(self.agent, coord) + shift)
if coord == 'x':
if self.env.field[self.agent.y][test].number in (2, 3):
return
elif coord == 'y':
if self.env.field[test][self.agent.x].number in (2, 3):
return
for x in range(8):
setattr(
self.agent,
@ -38,7 +45,7 @@ class GameUi:
def rotate(self, dir):
self.agent.dir = (self.agent.dir + dir) % 4
print(self.agent.dir)
#print(self.agent.dir)
self.agent.img = pg.image.load(SAPPER_IDLE[self.agent.dir])
self.update()