def move(self, direction): nearpos = self.player.pos + direction farpos = nearpos + direction near = self.tm.at(nearpos) far = self.tm.at(farpos) if near == '#': return if near in 'xX' and far in '#xX': return else: # move possible moves = MoveGroup() self.player.add_move(direction) moves.add(self.player) if near in 'xX': # crate moved floor = near=='x' and '.' or '*' insert = far=='*' and 'X' or 'x' moves.add(MapMove(self.tm, nearpos, direction, 1, floor_tile=floor, insert_tile=insert)) wait_for_move(moves, self.screen, self.draw, 0.01) self.tm.cache_map() self.draw() self.check_complete()
def move(self, direction): nearpos = self.player.pos + direction near = self.tm.at(nearpos) if near == '#': return self.player.add_move(direction) wait_for_move(self.player, self.screen, self.draw, 0.01) self.check_player_square()
def move(self, direction): start = self.gap - direction if self.tm.at(start) == '#': return move = MapMove(self.tm, start, direction, 2) wait_for_move(move, self.screen, self.tm.draw, 0.01) self.gap = start self.check_complete()
screen = Screen(Vector(800,550), 'data/background.png') frame = Frame(screen, Rect(64, 64, 320, 320)) tile_factory = TileFactory('data/tiles.conf') frutris = FrutrisBox(frame, tile_factory, LEVEL) screen.clear() frutris.draw() pygame.display.update() time.sleep(0.5) frutris.level.insert(Vector(4, 5), 'd') frutris.level.draw() pygame.display.update() time.sleep(0.5) for i in range(3): frutris.level.remove_fruit() wait_for_move(frutris, screen, frutris.draw) frutris.level.drop_bricks() wait_for_move(frutris, screen, frutris.draw) # test diamond frutris.insert_diamond(2) for i in range(10): frutris.moving.drop() wait_for_move(frutris, screen, frutris.draw) # test fruit pair frutris.insert_fruit_pair('a', 'b') frutris.moving.drop() wait_for_move(frutris, screen, frutris.draw) frutris.moving.drop() wait_for_move(frutris, screen, frutris.draw) for i in range(4): frutris.moving.left_shift()