diff --git a/README.md b/README.md index 7337969..d0ca61f 100644 --- a/README.md +++ b/README.md @@ -41,12 +41,12 @@ guard without all the objects, he dies (according to the evolution theory). * [x] Initialize a Git repo on Github * [x] Create the labyrinth without the graphical user interface * [x] Start the graphical interface with PyGame - * [ ] Represent the guard, _McGyver_ and the objects in your program + * [x] Represent the guard, _McGyver_ and the objects in your program and placed them at the beginning of the game 2. Animate the character * [ ] The only moving element is _McGyver_, create classes methods for animation and finding the exit - * [ ] make a simplified version of the game in which _McGyver_ wins + * [x] make a simplified version of the game in which _McGyver_ wins when he arrives in front of the goalkeeper 3. Recovering objects * [ ] Add object management diff --git a/main.py b/main.py index b1844ed..429eb8f 100644 --- a/main.py +++ b/main.py @@ -24,7 +24,10 @@ MAZE_ELEMENTS_TILES = { 'wall': 'img/transp-30.png', 'exit': 'img/g-orange-transp-30.png', 'plyr': 'img/player-30.png', - 'void': 'img/blue-white-30.png' + 'void': 'img/blue-white-30.png', + 'tube': 'img/1-blue-transp-30.png', + 'needle': 'img/2-blue-transp-30.png', + 'ether': 'img/3-blue-transp-30.png', } BACKGROUND_IMG = 'img/brick-800.png' UNKNOWN_TILE = 'img/unknown-30.png' diff --git a/map.py b/map.py index b83e704..56fc2b0 100644 --- a/map.py +++ b/map.py @@ -6,18 +6,33 @@ Licence: `GNU GPL v3` GNU GPL v3: http://www.gnu.org/licenses/ This file is part of [_ocp3_ project](https://github.com/freezed/ocp3) """ import os +import random # CONFIGURATION # Error message ERR_MAP = "ERR_MAP: «{}»" +ELEMENT_LIST = [ + {'symbol': 'n', 'name': 'needle', 'cross': True, 'ressurect': False, 'collect': True, 'tile': 'img/3-blue-transp-30.png'}, + {'symbol': 't', 'name': 'tube', 'cross': True, 'ressurect': False, 'collect': True, 'tile': 'img/1-blue-transp-30.png'}, + {'symbol': 'e', 'name': 'ether', 'cross': True, 'ressurect': False, 'collect': True, 'tile': 'img/2-blue-transp-30.png'}, + {'symbol': 'E', 'name': 'exit', 'cross': True, 'ressurect': False, 'collect': False, 'tile': 'd'}, + {'symbol': ' ', 'name': 'void', 'cross': True, 'ressurect': True, 'collect': False, 'tile': 'e'}, + {'symbol': '.', 'name': 'wall', 'cross': False, 'ressurect': False, 'collect': False, 'tile': 'f'}, + {'symbol': 'X', 'name': 'player', 'cross': False, 'ressurect': False, 'collect': False, 'tile': 'g'}, + {'symbol': '\n', 'name': 'nlin', 'cross': False, 'ressurect': False, 'collect': False, 'tile': 'h'}, +] + MAZE_SIZE = 15 MAZE_ELEMENTS = {'wall': '.', 'exit': 'E', 'plyr': 'X', 'nlin': '\n', + 'needle': 'n', + 'tube': 't', + 'ether': 'e', 'void': ' '} # Issue possible d'un mouvement, garder le OK toujours en fin de liste @@ -85,6 +100,12 @@ class Map: # Element under player at start self._element_under_player = MAZE_ELEMENTS['void'] + # Place collectables on the map + void_symbol = [element['symbol'] for element in ELEMENT_LIST if element['name'] == 'void'][0] + collectables = (element['symbol'] for element in ELEMENT_LIST if element['collect'] == True) + for symbol_to_place in collectables: + position = random.choice([idx for (idx, value) in enumerate(self._map_in_a_string) if value == void_symbol]) + self.place_element(symbol_to_place, pos=position) self.status = True self.status_message = MSG_START_GAME