def __init__(self): pygame.init() pygame.display.set_caption("My Pong Game") self.screen = pygame.display.set_mode((800, 600)) self.running = True self.clock = pygame.time.Clock() self.walls = [Wall((10, 10), 780, 10), Wall((10, 580), 780, 10)] # Position and dimensions of walls self.background = pygame.Surface((800, 600)) self.background.fill(pygame.Color("#000000")) self.ball = Ball((400, 300)) self.font = pygame.font.Font(None, 50) control_scheme_1 = ControlScheme() control_scheme_1.up = pygame.K_w control_scheme_1.down = pygame.K_s control_scheme_2 = ControlScheme() control_scheme_2.up = pygame.K_UP control_scheme_2.down = pygame.K_DOWN self.bats = [ Bat((10, 200), 10, 100, control_scheme_1), Bat((780, 200), 10, 100, control_scheme_2) ] # Position and dimensions of paddles, their respective control schemes self.score = Score(self.font)
def __init__(self, screen_rect): self.wall_group = list() rect = pygame.rect.Rect((0, 0), (10, screen_rect.h)) rect.topright = screen_rect.topright self.wall_group.append(Wall(rect)) rect = pygame.rect.Rect((0, 0), (screen_rect.w, 10)) rect.bottomleft = screen_rect.bottomleft self.wall_group.append(Wall(rect)) rect = pygame.rect.Rect((0, 0), (10, screen_rect.h)) rect.topleft = screen_rect.topleft self.wall_group.append(Wall(rect)) rect = pygame.rect.Rect((0, 0), (screen_rect.w, 10)) rect.topleft = screen_rect.topleft self.wall_group.append(Wall(rect)) self.ball_group = list() for i in range(50): b = Ball((random.randint(0, screen_rect.w), random.randint(0, screen_rect.h))) if not any(Physics.is_circle_collision(b, ball) for ball in self.ball_group): self.ball_group.append(b) self.physics = Physics() self.physics.solids.extend(self.wall_group) self.physics.mobiles.extend(self.ball_group)
def __init__(self): random.seed(time.time()) random.seed(123) pygame.init() pygame.font.init() self.font = pygame.font.SysFont('Comic Sans MS', 200) self.window = pygame.display.set_mode( (self.WINDOW_LENGTH, self.WINDOW_HEIGHT)) self.clock = pygame.time.Clock() self.running = True self.piecesName = [] self.objects = [] self.objects.append( Player(self.PLAYER1_NAME, self.PLAYER1_START_POS, self.PLAYER1_KEYS, self.PLAYER1_COLOR, self)) self.objects.append( Player(self.PLAYER2_NAME, self.PLAYER2_START_POS, self.PLAYER2_KEYS, self.PLAYER2_COLOR, self)) self.piecesName = [] self.generatePieces() self.objects.append(Wall("LEFT", self.piecesName, self)) self.objects.append(Wall("RIGHT", self.piecesName, self))
def create_chamber(self, chamber): # make top and bottom walls for i in xrange(0, chamber.length): # syntactic sugar fst = chamber.start[0] + i snd = chamber.start[1] wall = Wall(fst * TILE_SIZE, snd * TILE_SIZE) self.walls[fst][snd] = 1 self.wall_list.add(wall) fst = chamber.start[0] + i snd = chamber.start[1] + chamber.height - 1 wall = Wall(fst * TILE_SIZE, snd * TILE_SIZE) self.walls[fst][snd] = 1 self.wall_list.add(wall) # make side walls for i in xrange(0, chamber.height): fst = chamber.start[0] snd = chamber.start[1] + i wall = Wall(fst * TILE_SIZE, snd * TILE_SIZE) self.walls[fst][snd] = 1 self.wall_list.add(wall) fst = chamber.start[0] + chamber.length - 1 snd = chamber.start[1] + i wall = Wall(fst * TILE_SIZE, snd * TILE_SIZE) self.walls[fst][snd] = 1 self.wall_list.add(wall) # fill in floor for x in xrange(1, chamber.length - 1): for y in range(1, chamber.height - 1): self.floor[chamber.start[0] + x][chamber.start[1] + y] = 1
def draw_room_from_point(self, grid, x, y, size): len = size for i in range(len): grid.place_agent(Wall(i, self), (x + i, y)) grid.place_agent(Wall(i, self), (x + i, y - len)) grid.place_agent(Wall(i, self), (x, y - i)) grid.place_agent(Wall(i, self), (x + len, y - i))
def makeMaze(mazeColumn, mazeRow): grid = [[0] * mazeColumn for _ in range(mazeRow)] for r in range(0, mazeRow): for c in range(0, mazeColumn): top, left = Wall(), Wall() if r != 0: top = grid[r - 1][c].getWalls()[2] if c != 0: left = grid[r][c - 1].getWalls()[1] grid[r][c] = Cell([top, Wall(), Wall(), left]) for wall in grid[r][c].getWalls(): wall.addOwner(grid[r][c]) maze = [] wallsToDo = [] random.random() randomCell = grid[random.randint(0, mazeRow - 1)][random.randint(0, mazeColumn - 1)] maze.append(randomCell) for i in range(0, 4): wallsToDo.append(randomCell.getWalls()[i]) while len(maze) < mazeColumn * mazeRow: randomWall = random.choice(wallsToDo) if len(randomWall.owner) > 1 and (maze.count(randomWall.owner[0]) == 0 or maze.count(randomWall.owner[1]) == 0): randomWall.breakWall() newOwner = randomWall.owner[0 if maze.count(randomWall.owner[0]) == 0 else 1] maze.append(newOwner) for i in range(0, 4): if newOwner.getWalls()[i].exists: wallsToDo.append(newOwner.getWalls()[i]) wallsToDo.remove(randomWall) if len(wallsToDo) == 0: print("GOT STUCK") return makeMaze(mazeColumn, mazeRow) return grid
def play(self): """ Sets up our scene and executes the game loop. """ self.is_running = True self.is_building_wall = False self.balls = [] color = (255, 255, 255) self.walls = [Wall((1, 1), (self.width-1, 1), color), # ceiling Wall((1, 1), (1, self.height-1), color), # left wall Wall((1, self.height-1), (self.width-1, self.height-1), color), # floor Wall((self.width-1, 1), (self.width-1, self.height-1), color)] # right wall last_frame_time = time.time() while self.is_running: time_remaining = 1. / self.frames_per_second - (time.time() - last_frame_time) if time_remaining > 0: time.sleep(time_remaining) current_frame_time = time.time() dt = current_frame_time - last_frame_time dt = max(0.00001, min(dt, 0.1)) last_frame_time = current_frame_time self.event_handler() self.update(dt) self.render()
def open_door(self, player, current_room): if player.rect.x - door[0] > -100: #Door opens if player comes close self.wall_list = None self.wall_list = py.sprite.Group() block = copy.deepcopy(walls) #makes deep copy block.append(secret) #adds secret door #Add list of walls to wall_list from superclass Room for item in block: wall = Wall(item[0], item[1], item[2], item[3], item[4]) self.wall_list.add(wall) #Declare door open self.door_open = True if len(current_room.enemies ) <= 1: #Secret door opens after two orc killed self.wall_list = None self.wall_list = py.sprite.Group() block = copy.deepcopy(walls) #makes deep copy #Add list of walls to wall_list from superclass Room for item in block: wall = Wall(item[0], item[1], item[2], item[3], item[4]) self.wall_list.add(wall) #Declare door open self.secret_open = True
def create_wall(self, player_number): """ Creates a new wall that the players cannot cross based on the last position that the player turned and the players current position. :param player_number: The index of the player who the wall is being created from. :return: a new Wall object. """ horizontal = self.wall_start[player_number][1] == self.characters[ player_number].get_y_pos() if horizontal: if self.wall_start[player_number][0] < self.characters[ player_number].get_x_pos(): new_wall = Wall(horizontal, self.wall_start[player_number][0], self.characters[player_number].get_x_pos(), self.characters[player_number].get_y_pos(), self.characters[player_number].get_color()) else: new_wall = Wall(horizontal, self.characters[player_number].get_x_pos(), self.wall_start[player_number][0], self.characters[player_number].get_y_pos(), self.characters[player_number].get_color()) else: if self.wall_start[player_number][1] < self.characters[ player_number].get_y_pos(): new_wall = Wall(horizontal, self.wall_start[player_number][0], self.wall_start[player_number][1], self.characters[player_number].get_y_pos(), self.characters[player_number].get_color()) else: new_wall = Wall(horizontal, self.wall_start[player_number][0], self.characters[player_number].get_y_pos(), self.wall_start[player_number][1], self.characters[player_number].get_color()) return new_wall
def __create_walls(self): self.__walls = [] for x in range(self.width()): self.__walls.append(Wall(x, 0)) self.__walls.append(Wall(x, self.height() - 1)) for y in range(1, self.height()): self.__walls.append(Wall(0, y)) self.__walls.append(Wall(self.width() - 1, y))
def create_initial_walls(self): """ Creates walls around the border of the map. :return: None """ self.walls.append(Wall(True, 0, 1280, 0, 'black')) self.walls.append(Wall(True, 0, 1280, 707, 'black')) self.walls.append(Wall(False, 0, 0, 720, 'black')) self.walls.append(Wall(False, 1280, 0, 720, 'black'))
def __init__(self, grid, wall_inverse_ratio=10): self.width = grid.get_width() self.height = grid.get_height() self.grid = grid self.vertical_walls = [[ Wall(0, wall_inverse_ratio) for i in range(self.width + 1) ] for j in range(self.height)] self.horizontal_walls = [[ Wall(1, wall_inverse_ratio) for i in range(self.width) ] for j in range(self.height + 1)]
def generation_room(x_initial, y_initial, room): x = x_initial y = y_initial for i in range(len(room)): for j in range(len(room[0])): if room[i][j] == "f": pf = Floor(x, y, random.randint(0,5)) layer_0.add(pf) if room[i][j] == "w": pf = Wall(x, y, 4) layer_1.add(pf) if room[i][j] == "d": pf = Wall(x, y, 1) layer_2.add(pf) if room[i][j] == "v": pf = Wall(x, y, 2) layer_2.add(pf) if room[i][j] == "x": pf = Wall(x, y, 0) layer_0.add(pf) wall.append(pf) if room[i][j] == "u": pf = Wall(x, y, 3) layer_1.add(pf) r = random.randint(0, 100) if r <= 5: torch = Torch(x, y, 3) layer_1.add(torch) if room[i][j] == "c": r = random.randint(3, 10) if r >= 5: pf = Floor(x, y, 6) layer_0.add(pf) pf = Chest(x, y-6, random.randint(1, 2)) layer_1.add(pf) chest.append(pf) else: pf = Floor(x, y, 6) layer_0.add(pf) if room[i][j] == "z": pf = Monster_spawn(x, y) layer_0.add(pf) r = random.randint(2, 5) for i in range(r): x_ = random.randint(pf.rect.x-32, pf.rect.x+64) y_ = random.randint(pf.rect.y-32, pf.rect.y+64) pf = Monster(x_, y_, random.randint(1, 4)) layer_1.add(pf) layer_monster.add(pf) layer_all_monster_and_layer.add(pf) x += 32 x = x_initial y += 32
def make_walls(self): self.obstacles.append( Wall(Point2D(0, 0), Point2D(self.minuature_width, 0))) self.obstacles.append( Wall(Point2D(0, 0), Point2D(0, self.minuature_height))) self.obstacles.append( Wall(Point2D(self.minuature_width, self.minuature_height), Point2D(self.minuature_width, 0))) self.obstacles.append( Wall(Point2D(self.minuature_width, self.minuature_height), Point2D(0, self.minuature_height)))
def setup(self, score=0, level=1): # SETUP GAME OBEJCTS self.paddle = Paddle(game.keyboard, game.window.width / 2 - 50, 40, width=100, height=20, speed=400) self.ball = Ball(game.window.width / 2 - 8, 200, width=16, height=16, speed=200, direction=(0, -1)) self.wall_w = Wall(0, 0, width=10, height=game.window.height) self.wall_e = Wall(game.window.width - 10, 0, width=10, height=game.window.height) self.wall_n = Wall(0, game.window.height - 10, width=game.window.width, height=10) self.wall_s = Wall(0, 0, width=game.window.width, height=10) self.walls = [self.wall_w, self.wall_n, self.wall_e, self.wall_s] self.score = score self.lblScore.text = "Score: " + str(self.score) self.level = level self.lblLevel.text = "Level: " + str(self.level) # bricks setup BRICK_WIDTH = 60 BRICK_HEIGHT = 40 MARGIN = 10 self.bricks = [] brickX = MARGIN brickY = game.window.height - MARGIN - BRICK_HEIGHT while brickY > game.window.height / 2: while brickX + BRICK_WIDTH < game.window.width - MARGIN: self.bricks.append( Brick(brickX, brickY, BRICK_WIDTH, BRICK_HEIGHT)) brickX += BRICK_WIDTH + MARGIN brickX = MARGIN brickY -= MARGIN + BRICK_HEIGHT
def addRegularShape(center, radius, nSides): angleToTurn = 360 / nSides points = [] radiusVector = Vector(radius, 0) for x in range(nSides): point = center + radiusVector points.append(point) radiusVector = radiusVector.rotate(radians(angleToTurn)) for i in range(len(points)-1): walls.append(Wall(points[i], points[i+1], colour=BLACK, width=1)) walls.append(Wall(points[-1], points[0], colour=BLACK, width=1))
def __init__(self, memoryFile): self.nCycles = 0 # Used to hold number of clock cycles spent executing instructions # Fetch self.PCMux = Mux() self.ProgramC = PC(long(0xbfc00200)) self.InstMem = InstructionMemory(memoryFile) self.IFadder = Add() self.JMux = Mux() self.IFaddconst = Constant(4) self.IF_ID_Wall = Wall() self.fetchgroup = {} # Decode self.register = RegisterFile() self.signext = SignExtender() self.control = ControlElement() self.jmpCalc = JumpCalc() self.ID_EX_Wall = Wall() # Execute self.EXadder = Add() self.shiftL = LeftShifter() self.ALogicUnit = ALU() self.ALUSrcMux = Mux() self.RegDstMux = Mux() self.ALUctrl = AluControl() self.EX_MEM_Wall= Wall() # Memory self.storage = DataMemory(memoryFile) self.brnch = Branch() self.MEM_WB_Wall= Wall() # Write Back self.WBmux = Mux() self.ProgramC self.elements1 = [self.InstMem, self.IFaddconst, self.IFadder, self.PCMux, self.JMux] self.elements2 = [self.control, self.register, self.signext, self.jmpCalc] self.elements3 = [self.shiftL, self.ALUSrcMux, self.RegDstMux, self.ALUctrl, self.ALogicUnit, self.EXadder] self.elements4 = [self.brnch, self.storage] self.elementsboot = [self.IFaddconst, self.IFadder, self.InstMem, self.IF_ID_Wall, self.register, self.signext, self.control, self.jmpCalc, self.ID_EX_Wall, self.RegDstMux, self.shiftL, self.EXadder, self.ALUSrcMux, self.ALUctrl, self.ALogicUnit, self.EX_MEM_Wall, self.brnch, self.storage, self.MEM_WB_Wall, self.WBmux, self.PCMux, self.JMux] self.walls = [self.MEM_WB_Wall, self.EX_MEM_Wall, self.ID_EX_Wall, self.IF_ID_Wall] self._connectCPUElements()
def create_map1(MainGame): for i in [-1, 0, 1]: wall = Wall("img/wall/walls.gif", SCREEN_WIDTH / 2 - 30 + i * 60, SCREEN_HEIGHT - 120, 1) MainGame.wall_list.append(wall) for i in [-1, 1]: wall = Wall("img/wall/walls.gif", SCREEN_WIDTH / 2 - 30 + 60 * i, SCREEN_HEIGHT - 60, 1) MainGame.wall_list.append(wall) walls_list = [] list1 = [1, 3, 5, 7, 9, 11] list2 = [4, 4, 3, 3, 4, 4] list3 = [1, 1, 2.5, 2.5, 1, 1] wall1 = Wall("img/wall/wall_net_h.gif", 0, SCREEN_HEIGHT / 2, 0) wall2 = Wall("img/wall/wall_net_h.gif", SCREEN_WIDTH - 60, SCREEN_HEIGHT / 2, 0) for i in range(2): wall = Wall("img/wall/walls.gif", 120 + 60 * i, SCREEN_HEIGHT / 2, 1) MainGame.wall_list.append(wall) for i in range(2): wall = Wall("img/wall/walls.gif", SCREEN_WIDTH - 240 - 60 * i, SCREEN_HEIGHT / 2, 0) MainGame.wall_list.append(wall) for i in range(6): wall_list = create_wall(70 * list1[i], 0, list2[i]) walls_list.extend(wall_list) for i in range(6): wall_list = create_wall(70 * list1[i], SCREEN_HEIGHT - 60 * 4 - 60 * list3[i], 4) walls_list.extend(wall_list) wall3 = Wall("img/wall/walls_net.gif", 6 * 70, 120, 0) wall4 = Wall("img/wall/walls.gif", SCREEN_WIDTH / 2 - 30, SCREEN_HEIGHT / 2 + 30, 1) walls_list.extend([wall1, wall2, wall3, wall4]) MainGame.wall_list.extend(walls_list)
def __init__(self, width, height, color=(28, 28, 28)): self.wall_thickness = 15 self.width = width self.height = height self.color = color self.elements = [ Wall(0, 0, self.width, self.wall_thickness), # top Wall(self.width - self.wall_thickness, 0, self.wall_thickness, self.height), # right Wall(0, self.height - self.wall_thickness, self.width, self.wall_thickness), # bottom Bar(), Ball() ]
def add_wall(self, horizontal, vertical): if horizontal: x = self.x y = self.y + Tile.heightTile height = 7 width = Tile.widthTile self.walls.append(Wall(x, y, width, height, True)) if vertical: x = self.x + Tile.widthTile y = self.y height = Tile.heightTile width = 7 self.walls.append(Wall(x, y, width, height, False))
def add_wall(self, horizontal, vertical): # add a new object wall that it's a rectangle to the tile if horizontal: x = self.x y = self.y + int(Tile.heightTile) height = 7 width = int(Tile.widthTile) self.walls.append(Wall(x,y,width,height,True)) if vertical: x = self.x + int(Tile.widthTile) y = self.y height = int(Tile.heightTile) width = 7 self.walls.append(Wall(x,y,width,height,False))
def __create_random_walls(self): random_walls_return = {} reserved_spaces = [[1, 1], [1, 2], [2, 1], [1, 6], [1, 7], [2, 7], [12, 1], [13, 1], [13, 2], [13, 6], [13, 7], [12, 7], [7, 4]] x = 1 y = 1 n = 0 n_walls = 25 model_wall = self.__model_wall[2] while True: x = randint(1, 13) y = randint(1, 7) if x % 2 == 1 or y % 2 == 1: # fixes walls if [x, y] not in reserved_spaces: n += 1 reserved_spaces.append([x, y]) wall = Wall( 0, [x * Server.wall_factor, y * Server.wall_factor], model_wall.get_id(), [55, 55], 255, self.__create_random_gift()) random_walls_return[wall.get_id()] = wall if n == n_walls: break return random_walls_return
def __init__(self, config): self.empty = 'empty' self.brick = 'brick' self.rang = 'rang' self.concrete = 'concrete' self.fire_item = 'fire' self.config = config self.width = config['width'] self.height = config['height'] self.size_x = self.config['size_x'] self.size_y = self.config['size_y'] self.tk = Tk() self.coordinates = [[self.empty] * config['height'] for i in range(config['width'])] self.canvas = Canvas() self.create_rectangle(0, 0, self.config['width'], self.config['height'], fill=config['bg']) self.canvas.pack(fill=BOTH, expand=1) self.wall = Wall(self) self.ladder = Ladder(self) self.fire = Fire(self) self.human = Human(self)
def setup_game(self, filename: str) -> None: """ Set up a game with walls, player, food, monsters, and powerUp food on the screen """ # open data file to initialize the game screen with open(os.path.join("images", filename)) as f: data = [line.split() for line in f] w = len(data[0]) h = len(data) + 1 self._actors = [] self.stage_width, self.stage_height = w, h - 1 self.size = (w * ICON_SIZE, h * ICON_SIZE) # loop though each line to the file and set up the game for i in range(len(data)): for j in range(len(data[i])): # initialize all objects in the file and add them to the _actors attribute legend = data[i][j] if legend == 'P': # P is player object player = Player("player.png", j, i) self.player = player self._actors.append(player) elif legend == 'X': # X is a wall object self._actors.append(Wall("wall.png", j, i)) elif legend == 'M': # M is a monster object self._actors.append(Monster("monster.png", j, i)) elif legend == 'O': # O is a food object self._actors.append(Food("food.png", j, i)) elif legend == 'U': # U is a powerup object self._actors.append(PowerUp("powerUp.png", j, i))
def setup(): size(600, 600) # Set up some inner walls for i in range(5): x1 = random_uniform(width, 0) x2 = random_uniform(width, 0) y1 = random_uniform(height, 0) y2 = random_uniform(height, 0) walls.append(Wall(x1, y1, x2, y2)) # outer walls walls.append(Wall(0, 0, width, 0)) walls.append(Wall(width, 0, width, height)) walls.append(Wall(width, height, 0, height)) walls.append(Wall(0, height, 0, 0))
def parseInput(self, resp): info = {} info['timeLeft'] = resp[0] info['gameNum'] = resp[1] info['tickNum'] = resp[2] info['maxWalls'] = int(resp[3]) info['wallPlacementDelay'] = resp[4] info['boardSizeX'] = int(resp[5]) info['boardSizeY'] = int(resp[6]) info['currentWallTimer'] = resp[7] info['hunter'] = Coordinate(resp[8], resp[9], resp[10], resp[11]) info['prey'] = Coordinate(resp[12], resp[13]) info['numWalls'] = int(resp[14]) info['walls'] = [] for i in range(0, info['numWalls']): info['walls'].append( Wall(int(resp[15 + i * 4]), int(resp[16 + i * 4]), int(resp[17 + i * 4]), int(resp[18 + i * 4]))) return info
def removePlayer(self, player): if abs(self.findDistance(player)) < self._wallSize: if abs(self.getSlope()) >= 1: changeInY = player.getPosition()[1] - self.getPoints()[1][1] player.setPosition( self.__nextWarp.getPoints()[0][0] + changeInY / self.getSlope(), self.__nextWarp.getPoints()[0][1] + changeInY) else: changeInX = player.getPosition()[0] - self.getPoints()[1][0] player.setPosition( self.__nextWarp.getPoints()[0][0] + changeInX, self.__nextWarp.getPoints()[0][1] + self.getSlope() * changeInX) wall = Wall(self.__nextWarp.getPoints()[0][0], self.__nextWarp.getPoints()[0][1], self.__nextWarp.getPoints()[1][0], self.__nextWarp.getPoints()[1][1]) wall.isEnabled(True) wall.removePlayer(player) player.move() wall.isEnabled(False) self.__thisRoom.unloadRoom() # Reloading the room fixes bugs with items being present when they shouldn't be self.__thisRoom.loadRoom() self.__thisRoom.unloadRoom() self.__nextRoom.loadRoom()
def __init__(self): super().__init__() # Make walls (x, y, width, height) global door, walls door = [305, 350, 10, 90, self.brown] walls = [ [20, 20, 20, 580, self.white], [20, 20, 850, 20, self.white], [20, 580, 850, 20, self.white], [850, 20, 20, 450, self.white], [850, 450, 60, 20, self.white], [850, 570, 20, 10, self.white], [850, 560, 60, 20, self.white], [300, 20, 20, 330, self.white], [300, 440, 20, 140, self.white], [300, 330, 200, 20, self.white], [700, 330, 150, 20, self.white], ] block = copy.deepcopy(walls) #makes deep copy block.append(door) #adds door #Add list of walls to wall_list from superclass Room for item in block: wall = Wall(item[0], item[1], item[2], item[3], item[4]) self.wall_list.add(wall) #Door closed self.door_open = False
def update(self): for _ in range(self.epoch): for gachi in self.gachis: gachi.update(self.dt, self.walls[0]) for i, gachi in enumerate(self.gachis): if not gachi.alive: self.dead_gachis.append(self.gachis.pop(i)) if not self.gachis: self.walls = [ Wall(self.assets.nolyuolan, 600 + (i * 500)) for i in range(3) ] Genetics.next_generation(self) for wall in self.walls: wall.update() for i in range(len(self.walls)): tWall = self.walls[i] right_side = tWall.x + tWall.width if right_side < 0: tWall.reset() tWall.x = self.walls[-2].x + 500 elif right_side < 215: self.walls.append(self.walls.pop(i))
def buildLevel(self, descr): y = self.starty ny = 0 self.map = dict() for row in descr: self.map[str(ny)] = dict() x = self.startx nx = 0 for el in row: # self.map[str(ny)][str(nx)] = 0 if el == ' ' else 1 self.set_map(nx, ny, 1 if el == '-' else 0) if el == '-': wall = Wall(x, y, self.game) self.wallsGroup.add(wall) self.entities.add(wall, layer=self.LAYER_POINTS) elif el == 'f': food = Food(x, y, self.game) self.foodGroup.add(food) self.entities.add(food, layer=self.LAYER_FOODS) elif el == ' ': point = Point(x, y) self.entities.add(point, layer=self.LAYER_FOODS) self.foodGroup.add(point) x += self.game.block_size nx += 1 y += self.game.block_size ny += 1