From 13d579fa45aacad4dc21ba8603026ca70091a1e3 Mon Sep 17 00:00:00 2001 From: DylanVsn <43576618+DylanVsn@users.noreply.github.com> Date: Wed, 13 Nov 2019 11:28:29 +0100 Subject: [PATCH] =?UTF-8?q?s=C3=A9ance=20TD=20+=20g=C3=A9n=C3=A9rer=20cart?= =?UTF-8?q?e=20depuis=20image=20-=20mod=C3=A8le=20Gimp=20pr=C3=A9sent=20-?= =?UTF-8?q?=20instructions=20couleurs=20(lel)=20pr=C3=A9sente=20-=20todo:?= =?UTF-8?q?=20pareil=20avec=20padots=20-=20facile,=20maintenant=20on=20pou?= =?UTF-8?q?rra=20collisions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- iteration_2_voulue_par_prof.txt | 3 + pacmap.xcf | Bin 0 -> 923 bytes pacmap_empty.png | Bin 0 -> 571 bytes pacmap_maze1.png | Bin 0 -> 12025 bytes pacmap_maze1.xcf | Bin 0 -> 1785 bytes pacmap_rule.txt | 9 +++ src/carte.py | 118 -------------------------------- src/pacman.py | 27 ++++---- src/pacmap.py | 45 ++++++++++-- src/test_load_picture.py | 13 ++++ 10 files changed, 79 insertions(+), 136 deletions(-) create mode 100644 iteration_2_voulue_par_prof.txt create mode 100644 pacmap.xcf create mode 100644 pacmap_empty.png create mode 100644 pacmap_maze1.png create mode 100644 pacmap_maze1.xcf create mode 100644 pacmap_rule.txt delete mode 100644 src/carte.py mode change 100644 => 100755 src/pacman.py create mode 100755 src/test_load_picture.py diff --git a/iteration_2_voulue_par_prof.txt b/iteration_2_voulue_par_prof.txt new file mode 100644 index 0000000..d50e3a4 --- /dev/null +++ b/iteration_2_voulue_par_prof.txt @@ -0,0 +1,3 @@ +1- afficher pacman dans fenêtre +2- gérer déplacements sans sortir de la fenêtre (sans forcément être dans le labyrinthe) - + des murs autour avec notre gestion de collision diff --git a/pacmap.xcf b/pacmap.xcf new file mode 100644 index 0000000000000000000000000000000000000000..1ae31ed02a6521fdc4a20108b85acfe8ddee7357 GIT binary patch literal 923 zcmb7C%}#?r7~Dl`vHqvl#H5L<)}%dP$`crU3~!VIl2B-%YCYjIXyV#50RfYw$xastl^(r}1~p$})>Y;qHMB1@uh*lTqCz)hkg72TOwX)tg^|F}Ox zg|W-29!dulrD|UMY^ZdajU6|P17WMZ5Z+XUWoBK*;Y5V7d*NkNpZI>}O}<``s^_C3 z`Cdxrpn>0O56bG7uzs4R;oDQ{S>wowX$74!VF{!gkl;S~lUt0qC6IEuwdK-7*n#G0 z2UM+!c`X7}Z!aC$706o;a`is;zVTxcp7CIZ%X)F|( z@lr8|$aq(I&aYWbwo2ywndSVP)n$`OSp(;_E^~gz+H#liKhtD}-o2C)~ literal 0 HcmV?d00001 diff --git a/pacmap_empty.png b/pacmap_empty.png new file mode 100644 index 0000000000000000000000000000000000000000..1aa671ecf840daef0de08f42a331fc4489b8f865 GIT binary patch literal 571 zcmV-B0>u4^P)EX>4Tx04R}tkv&MmKpe$iTcv)qI@m$PAwzYtAS&XhRVYG*P%E_RU~=gfG-*gu zTpR`0f`cE6RR%KKJJcD>;(^K7n|a>4rtTK|H-_ z>74h8BdjPX#OK6g23?T&k?XR{Z=4Gb`*~)>NT=qBBg8_Xjpa6GMMEW?B91DmM*04X z%L?Z$&T6^Jn)l={4CSWO9|j z$gzM5R7j2={11M2Yvv~>+@w$(=zOv5j}aia3p8rB{e5iPjT0d73|wg~f29u0e3D*k zY0)E~e;c^CZfWu!aJd5vKIxJnIZ}Y8Kc5HQ&*+=7z`!lgv*z~J+{ftykfyGZH^9Lm zFj}DOb&q#pF2XskI zMF-;x4GApBX?Qr$K`THKKHUeFF;p4LHOuYdHV_002ov JPDHLkV1o2T^r!#; literal 0 HcmV?d00001 diff --git a/pacmap_maze1.png b/pacmap_maze1.png new file mode 100644 index 0000000000000000000000000000000000000000..503e9b941b93768c767e76ca646138a8aa94dbea GIT binary patch literal 12025 zcmV zaB^>EX>4U6ba`-PAZ2)IW&i+q+Qpn{ax6Q}W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g4?u{n&6Quc;zI1T%`C+IZrvm5Wr`LpTyJG)m`T>x}+Ks#g=kbr1>KiJ(A{3A|aUG zGgI40x`#8Dwu&O5(t3ZDb=VkTNJRalESw}=umVEoXc!s@gUQqc=jvDNu%vz>$W`^D zZ~un+m2tWC{rfuE()vthy>tp+julh5*wSiZxF{uoXhLElQSs->EZga_vAf%J7gDY; z@f~~#AHqxDhy+2#@9gfhODW)KzB%8VIe&Au<9dFd51lSQXf&G)vH(0H0{H<{fI+sLeV;MyH+02w9IHPFyIxONf$a;}SP_`r+T7&X0k-#Cv|xF@ z?F!2scpY*>y#iZ`;=`WcQP}f3%jKo6>x8{QGD3#Mj{?HNYR%~spVoQ&0#(_8(+kB z$Bu0^AE&iG^n3h33?eTK)@ry%jf=nuJ7{;Uw)6g#wOU(mms={ZUFN(M+b*Y%u~vOK z^t$ye8hd@ii=%BZcxU_lo~X80Iex7bxLzHS1ilu58}C)y&zt|_{n6`?^Rt^$zZLl8 z`!O!HgHa;;4aq-^1K`|v(Og-*sh`hRhqPA4^P*Abq}a}F6wSYv3jQm;-Txx|etcN( z2QE3$n;@A1=)FkbG4b_pSn;L+vg1F`%#1^^YK~J8@*yb$it`+w&GFkgekaH8f>S*u zB@oI*`JZMSiY*eC5a=g4uHL-56OKsqH>plmH4u905dCYalU1FO{kyV%Uenp4aev9YZ boolean: - """ - This method will verify if a given map is valid or not - Return True if correct else False - - we will assume - there are only: - - 1 ghost door - - 4 big pac-dots - - 240 pac-dots - - Each ground tile must have at least 2 ground tile neighboors because - there is no dead-end tile in pac-man - Each dot must be on a ground tile (not even a teleporter one) - """ - - if not (len(phys_map) == len(dots_map) == 31): - return False - - for i in range(len(phys_map)): - if not (len(phys_map[i]) == len(dots_map[i]) == 28): - return False - - # 1 ghost door verification - if sum(sub_arr.count(PhysTile.GSD) for sub_arr in phys_map) != 1: - return False - - # # 4 big pac dots - if sum(sub_arr.count(DotTile.BPD) for sub_arr in dots_map) != 4: - return False - - # # 240 small pac-dots - if sum(sub_arr.count(DotTile.SPD) for sub_arr in dots_map) != 240: - return False - - # dots are only in ground tile - for row in range(len(phys_map)): - for col in range(len(phys_map[0])): - if dots_map[row][col] and phys_map[row][col]: # no dot = 0; ground = 0 - return False - - # odd number of teleporter tiles - teleporter_count = sum(sub_arr.count(PhysTile.TPT) for sub_arr in phys_map) - if teleporter_count % 2: - return False - - edges = phys_map[0][1:] + phys_map[height-1][1:] + [sub[0] for sub in phys_map] + [sub[width-1] for sub in phys_map][1:-1] - - # must verify teleporters are on edges - teleporter_count -= edges.count(PhysTile.TPT) - if teleporter_count: # not all teleporters are on edges - return False - - ### ATTENTION - we need to verify teleporters are in front of the other - - # no ground tile on border - if any(PhysTile.GRD in edges): - return False - - # now we have to verify there is no dead-end ground tile - for col in range(1, width-1): - for row in range(1, height-1): - cpt = 0 - for x, y in ((0, 1), (1, 0), (-1, 0), (0, -1)): - if list[row+y][col+x] in (PhysTile.GRD, PhysTile.TPT, PhysTile.BPD, PhysTile.SPD): - cpt += 1 - if cpt == 2: - break - if cpt < 2: - return False - # we have to verify if there is only 1 connexity component of (PhysTile.GRD, PhysTile.TPT, PhysTile.BPD, PhysTile.SPD) - - return True diff --git a/src/pacman.py b/src/pacman.py old mode 100644 new mode 100755 index 900a5e3..d3dabe1 --- a/src/pacman.py +++ b/src/pacman.py @@ -13,7 +13,7 @@ class Direction(IntEnum): D = 1 R = 2 L = 3 - + class FruitType(IntEnum): A = 0 @@ -31,6 +31,7 @@ class Pacman: self.next_direction = Direction.R self.super_power = 0 # Counter of super pacdots in effect (> 0 means super power is active) self.ghost_combo = 0 + self.size = (1.8, 1.8) # size related to tile size def matrix_position(self): return (int(self.position[0]), int(self.position[1])) @@ -38,16 +39,18 @@ class Pacman: def has_super_power(self): return self.super_power > 0 - def eat_pacdot(self, map): + def eat_pacdot(self, dot_map): global score global pacdot_counter - map.dots_map[self.matrix_position()[0]][self.matrix_position()[1]] = pacmap.DotTile.NDT + dot_map.dots_map[self.matrix_position()[0]][self.matrix_position()[1]] = pacmap.DotTile.NDT pacdot_counter -= 1 score += 10 + if pacdot_counter == 0: + game_over("win") - def eat_super_pacdot(self, map): + def eat_super_pacdot(self, dot_map): global score - map.dots_map[self.matrix_position()[0]][self.matrix_position()[1]] = pacmap.DotTile.NDT + dot_map.dots_map[self.matrix_position()[0]][self.matrix_position()[1]] = pacmap.DotTile.NDT score += 50 self.super_power += 1 @@ -62,26 +65,26 @@ class Pacman: self.ghost_combo = 0 #os._exit(0) - def eat_fruit(self, fruit, map): + def eat_fruit(self, fruit, dot_map): global score - map.dots_map[self.matrix_position()[0]][self.matrix_position()[1]] = pacmap.DotTile.NDT + dot_map.dots_map[self.matrix_position()[0]][self.matrix_position()[1]] = pacmap.DotTile.NDT score += fruit.score def eat_ghost(self, ghost): global score ghost.despawn_and_respawn() self.ghost_combo += 1 - score += (2 ^ self.ghost_combo) * 100 + score += (2 ** self.ghost_combo) * 100 - def get_eaten(self, map): + def get_eaten(self, dot_map): global lives #TODO score loss ? - self.position = map.spawn_point #TODO + self.position = dot_map.spawn_point #TODO lives -= 1 - if lives <= 0: + if lives < 0: # à vérifier game_over() -def game_over(): +def game_over(status = "lose"): #TODO pass diff --git a/src/pacmap.py b/src/pacmap.py index 0207823..afc93f3 100755 --- a/src/pacmap.py +++ b/src/pacmap.py @@ -1,18 +1,23 @@ #!/usr/bin/env python3 from enum import IntEnum from copy import deepcopy +from PIL import Image +import os class DotTile(IntEnum): NDT = 0 # no dot SPD = 1 # small pac-dot BPD = 2 # big pac-dot + FRT = 3 # fruit class PhysTile(IntEnum): GRD = 0 # ground WAL = 1 # wall GSD = 2 # ghost door - TPT = 3 # teleporter tile - FIT = 4 # fully inaccessible tile + GWL = 3 # ghost cell wall + GCF = 4 # ghost cell floor + TPT = 5 # teleporter tile + FIT = 6 # fully inaccessible tile # ghost-cell ground as FIT ? verify no pac-dot here class Map: @@ -20,11 +25,11 @@ class Map: Pacman maps size is 28×31 """ - width = 28 - height = 31 - tile_size = 16 # tile subdivision for dynamic movement + width = 28 * 2 + 1 + height = 31 * 2 + 1 + # tile_size = 16 # tile subdivision for dynamic movement - def __init__(self, phys_map = [], dots_map = []): + def __init__(self, phys_map = [], dots_map = [], maze_img_file=""): """ physic_map is the array containing elements: 0: ground tile @@ -40,6 +45,11 @@ class Map: 1: small pac-dot 2: big pac-dot """ + if maze_img_file and os.path.isfile(maze_img_file): + try: + self.phys_map = decode_map(maze_img_file) + except Exception as e: + raise e self.phys_map = phys_map # in the first part we assume phys_map is correct and no need to verify self.dots_map = dots_map self.intersect_map = [] # TODO - the layer which contains intersections pre-calculated @@ -158,3 +168,26 @@ def connex(matrix, x=-1, y=-1): if any(tile in (PhysTile.GRD, PhysTile.TPT) for row in temp for tile in row): return False return True + +def decode_map(img_file): + img = Image.open(img_file) + dictionnary = { + (0 , 0, 0): PhysTile.GRD, + (255, 0, 255): PhysTile.GCF, + (0 , 0, 255): PhysTile.WAL, + (0 , 255, 0): PhysTile.GSD, + (0 , 255, 255): PhysTile.GWL, + (255, 0, 0): PhysTile.TPT, + (255, 255, 0): PhysTile.FIT, + } + data = list(img.getdata()) + matrix = [] + for row in range(img.height): + matrix.append([]) + for col in range(img.width): + try: + tile = dictionnary[data[col + row*img.width][:3]] # avoid alpha component + except: + raise ValueError("Pixel " + str(col) + "," + str(row) + " is invalid") + matrix[-1].append(tile) + return matrix \ No newline at end of file diff --git a/src/test_load_picture.py b/src/test_load_picture.py new file mode 100755 index 0000000..4266aef --- /dev/null +++ b/src/test_load_picture.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python3 +from pacmap import decode_map +import sys + +if __name__ == '__main__': + if len(sys.argv) > 1: + matrix = decode_map(sys.argv[1]) + else: + matrix = decode_map("../pacmap_maze1.png") + for row in matrix: + print() + for el in row: + print(el.value, end=' ') \ No newline at end of file