From 86328410619ffa33e6700ec2d7dfa861f27ad670 Mon Sep 17 00:00:00 2001 From: eugenep Date: Sun, 11 Apr 2021 12:02:52 +0200 Subject: [PATCH] Add walls --- images/wall.bmp | Bin 0 -> 16522 bytes main.py | 2 + map.txt | 6 +- maze.py | 2 + sprites.py | 172 +++++++++++++++++++++++++++++------------------- 5 files changed, 112 insertions(+), 70 deletions(-) create mode 100644 images/wall.bmp diff --git a/images/wall.bmp b/images/wall.bmp new file mode 100644 index 0000000000000000000000000000000000000000..9d3c66581aa31d97acb808b868c8a87566d9c1a0 GIT binary patch literal 16522 zcmZvj=W`aVBA-nwo1A0TB!aOf=XAOwL*4EQuf#0HKV8a?T0m z07!s9M3D`~$0z&^^L577+ugf+eowbvOFs9g*mS=g_Fil6z1Fi*FZniS(VzUk9R5$H zEt+iq@~40O(|_RHzo6qE{=7f^Dfp+W-jWsT&!s*4fB$RG$bbKD|C;fC{$){Y?0-!= zbm)IBI&|niHB?sq=P&=uU;o4Z*ijHOy^H@i{Rih`KmNt8?Revq)V_3zYhIX=+80hq z-3#Yt`7u3#Yzw+-c}~>9h^LF`dIdn#AN0`%Ge|op8Cw zzHC z9eo20pG@by*LGFw3%k1Qm7`YK3@^1~c45^MuD^2BO6y&X4k%Uvu#I*`C((4 zvvz%gwRU}}y?RZHyXLz}v*x>6=UZr7yRO}=`L@MfxvJV+NWEhi+ex@QZ1x=JbJY$U z?x(MQcQ5C=_xGBZ$SONJGS`iYNac9TjgGAHVxy|Pua`7=tpjh|Z&o*$=!i-$CaQv# zYht3xT$&dhneN0ymAbLf)!tMq=b0Q68?9$^OjJaoy>m|^bMVZbGrP!%inwgWL>2$T zJB$}y#q;4-&3Ty@Ipd_WV8JE3`~E9vPqibyxD2hLqtc6tIP65uSnfneUT{Qf(DZ(Z z8%sZ;Cn}=KJA7Pg`6Lt_QSHV=((k`-?#!4PduB|n7aLOu-Fb%J^pj;)tju>i@4a`| zeA@=UmE6C@{S5Ax@Q(P-#KDrv=B*LfMoG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{(2B{`iew@Co z)OQqV=!vOZ+|;weIqA(Rk8fs(^WP6?4#T=|`cZmP@%XuZ>@bTy!*xLZ^T^t>U(qYj zCpyaL*SD4Z=YnUa_v_ccf@|5z=X=z&Pb^$mgZ|vlTCG+54h&cAj_@rLU8gzFoGO;9 zZ&dVtrM|I)?x)t*OX_%D{fi%LDQatki!q9U$Efxt{C+S;y!U&3r~DUvN5HqG(qYt~ zNk5ii<4>noF?0N6|9iT6^2MS{e%0@5=^}%_@{G?vc+7ppNyOm))Q}T7d4Z_4o$OTC%v2eWRGL z{C44=Y)GwZ4*e84OPAIW_nWeN6t|PyX|3eH2=gwd-zPUVJR#p^Epau~c}}gr=2dZ< zz%~i4hyCFcu9qlR_bc&n#;axys%VvZUh_dKr&X|?nXF63M6jm%j<<~OI2yp#XCZ8U z_ON2Xs_oPID#m+|{)F$ud7>}MzT%!w7yRd$B}>R*HjRU=;-C78Xyt*m*8|&R7O`J) zr{JZo<>+0X=c)bg?^X1~HDYliE;SACUt{$B3Up6vn!6I;?+au+d{1$X0 0: if self.check_border(dx): - if self.collide_with_mines(dx): - #ctypes.windll.user32.MessageBoxW(0, "Mine Ahead!", "Warning", 1) - print("Mine Ahead!") - self.x += dx - else: - self.x += dx + if not self.collide_with_walls(dx): + if self.collide_with_mines(dx): + #ctypes.windll.user32.MessageBoxW(0, "Mine Ahead!", "Warning", 1) + print("Mine Ahead!") + self.x += dx + else: + self.x += dx if self.direction == Direction.Up.name: if dy < 0: if self.check_border(0, dy): - if self.collide_with_mines(0, dy): - #ctypes.windll.user32.MessageBoxW(0, "Mine Ahead!", "Warning", 1) - print("Mine Ahead!") - self.y += dy - else: - self.y += dy + if not self.collide_with_walls(0, dy): + if self.collide_with_mines(0, dy): + #ctypes.windll.user32.MessageBoxW(0, "Mine Ahead!", "Warning", 1) + print("Mine Ahead!") + self.y += dy + else: + self.y += dy if self.direction == Direction.Down.name: if dy > 0: if self.check_border(0, dy): - if self.collide_with_mines(0, dy): - #ctypes.windll.user32.MessageBoxW(0, "Mine Ahead!", "Warning", 1) - print("Mine Ahead!") - self.y += dy - else: - self.y += dy + if not self.collide_with_walls(0, dy): + if self.collide_with_mines(0, dy): + #ctypes.windll.user32.MessageBoxW(0, "Mine Ahead!", "Warning", 1) + print("Mine Ahead!") + self.y += dy + else: + self.y += dy if self.direction == Direction.Left.name: if dx < 0: if self.check_border(dx): - if self.collide_with_mines(dx): - #ctypes.windll.user32.MessageBoxW(0, "Mine Ahead!", "Warning", 1) - print("Mine Ahead!") - self.x += dx - else: - self.x += dx + if not self.collide_with_walls(dx): + if self.collide_with_mines(dx): + #ctypes.windll.user32.MessageBoxW(0, "Mine Ahead!", "Warning", 1) + print("Mine Ahead!") + self.x += dx + else: + self.x += dx elif direction != self.direction: self.direction = direction @@ -90,6 +94,12 @@ class Player(pg.sprite.Sprite): return True return False + def collide_with_walls(self, dx=0, dy=0): + for wall in self.game.walls: + if wall.x == self.x + dx and wall.y == self.y + dy: + return True + return False + """ right = 1 @@ -105,49 +115,60 @@ class Player(pg.sprite.Sprite): def parse_maze_moves(self): self.moves = [char for char in self.maze.moves] - for n, i in enumerate(self.moves): - if i == 'R': - self.moves[n] = 'Right' - if n != len(self.moves)-1: - if i != self.moves[n+1]: - if self.moves[n+1] == 'D': - self.moves.insert(n+1, 'Turn Down') - if self.moves[n+1] == 'U': - self.moves.insert(n+1, 'Turn Up') - if self.moves[n+1] == 'L': - self.moves.insert(n+1, 'Turn Left') - else: - self.move(dx=-1, direction='Right') - if i == 'L': - self.moves[n] = 'Left' - if n != len(self.moves)-1: - if i != self.moves[n+1]: - if self.moves[n+1] == 'D': - self.moves.insert(n+1, 'Turn Down') - if self.moves[n+1] == 'U': - self.moves.insert(n+1, 'Turn Up') - if self.moves[n+1] == 'R': - self.moves.insert(n+1, 'Turn Right') - if i == 'D': - self.moves[n] = 'Down' - if n != len(self.moves)-1: - if i != self.moves[n+1]: - if self.moves[n+1] == 'R': - self.moves.insert(n+1, 'Turn Right') - if self.moves[n+1] == 'U': - self.moves.insert(n+1, 'Turn Up') - if self.moves[n+1] == 'L': - self.moves.insert(n+1, 'Turn Left') - if i == 'U': - self.moves[n] = 'Up' - if n != len(self.moves)-1: - if i != self.moves[n+1]: - if self.moves[n+1] == 'D': - self.moves.insert(n+1, 'Turn Down') - if self.moves[n+1] == 'R': - self.moves.insert(n+1, 'Turn Right') - if self.moves[n+1] == 'L': - self.moves.insert(n+1, 'Turn Left') + + + if self.moves[0] != 'R': + if self.moves[0] == 'D': + self.moves.insert(0, 'Turn Down') + if self.moves[0] == 'U': + self.moves.insert(0, 'Turn Up') + if self.moves[0] == 'L': + self.moves.insert(0, 'Turn Left') + + for n, i in enumerate(self.moves): + if i == 'R': + self.moves[n] = 'Right' + if n != len(self.moves)-1: + if i != self.moves[n+1]: + if self.moves[n+1] == 'D': + self.moves.insert(n+1, 'Turn Down') + if self.moves[n+1] == 'U': + self.moves.insert(n+1, 'Turn Up') + if self.moves[n+1] == 'L': + self.moves.insert(n+1, 'Turn Left') + else: + self.move(dx=-1, direction='Right') + if i == 'L': + self.moves[n] = 'Left' + if n != len(self.moves)-1: + if i != self.moves[n+1]: + if self.moves[n+1] == 'D': + self.moves.insert(n+1, 'Turn Down') + if self.moves[n+1] == 'U': + self.moves.insert(n+1, 'Turn Up') + if self.moves[n+1] == 'R': + self.moves.insert(n+1, 'Turn Right') + if i == 'D': + self.moves[n] = 'Down' + if n != len(self.moves)-1: + if i != self.moves[n+1]: + if self.moves[n+1] == 'R': + self.moves.insert(n+1, 'Turn Right') + if self.moves[n+1] == 'U': + self.moves.insert(n+1, 'Turn Up') + if self.moves[n+1] == 'L': + self.moves.insert(n+1, 'Turn Left') + if i == 'U': + self.moves[n] = 'Up' + if n != len(self.moves)-1: + if i != self.moves[n+1]: + if self.moves[n+1] == 'D': + self.moves.insert(n+1, 'Turn Down') + if self.moves[n+1] == 'R': + self.moves.insert(n+1, 'Turn Right') + if self.moves[n+1] == 'L': + self.moves.insert(n+1, 'Turn Left') + print(self.moves) @@ -220,4 +241,21 @@ class Grenade(pg.sprite.Sprite): self.rect.x = self.x * TILESIZE self.rect.y = self.y * TILESIZE +class Wall(pg.sprite.Sprite): + def __init__(self, game, x, y): + self.groups = game.all_sprites, game.walls + pg.sprite.Sprite.__init__(self, self.groups) + self.game = game + #self.image = pg.Surface((TILESIZE, TILESIZE)) + self.image = pg.image.load('images/wall.bmp') + #self.image.fill(YELLOW) + self.image = pg.transform.scale(self.image, (TILESIZE, TILESIZE)) + self.rect = self.image.get_rect() + self.x = x + self.y = y + + def update(self): + self.rect.x = self.x * TILESIZE + self.rect.y = self.y * TILESIZE + \ No newline at end of file