def new_game(): """ Makes new game by deleting old data and making new data """ global CURRENT_FLOOR, TURN_COUNT, MAP_INFO, CAMERA, PATHFINDING, PLAYER, GAME_DATA, FOV CURRENT_FLOOR = 1 # Save this TURN_COUNT = 0 # Save this MAP_INFO = gamemap.MapInfo() CAMERA = camera.Camera(MAP_INFO) PATHFINDING = pathfinding.Graph() PATHFINDING.make_graph(MAP_INFO) PATHFINDING.neighbour() # Save this PLAYER = entity_generator.generate_player(MAP_INFO.map_tree, "knight") # Save this GAME_DATA = game_data.GameData() FOV = fov.new_fov(MAP_INFO) PARTICLE_LIST = []
def initialize_pathfinding(): """ Initializes pathfinding for config.MAP_INFO """ config.PATHFINDING = pathfinding.Graph() config.PATHFINDING.make_graph(config.MAP_INFO) config.PATHFINDING.neighbour()
def isLegal(board): # starts at 4th col, with row based on gHeight colStart = 4 colGoal = len(board[0]) - 5 start = None goal = None for row in range(len(board)): if start is None: if board[row][colStart] != 0: start = (row - 1, colStart) #first point of collision if goal is None: if board[row][colGoal] != 0: goal = (row - 1, colGoal) graph = pathfinding.Graph(board) path = pathfinding.aStarSearch(graph, start, goal) if path is not None: global_data.data.solvedPath = path return True else: return False
def findPath(self): # updates shortest path to level finish but currently only works without # game physics taken into account # a* however does take game physics into account board = self.screenObjList # starts at 4th col, with row based on gHeight colStart = 4 colGoal = len(board[0]) - 5 start = None goal = None for row in range(len(board)): if start is None: if board[row][colStart] != 0: start = (row - 1, colStart) #first point of collision if goal is None: if board[row][colGoal] != 0: goal = (row - 1, colGoal) graph = pathfinding.Graph(board) path = pathfinding.aStarSearch(graph, start, goal) if path is not None: global_data.data.solvedPath = path
SURFACE_MAIN = pygame.display.set_mode(RESOLUTION, pygame.RESIZABLE) CLOCK = pygame.time.Clock() # Load in all the sprites SPRITE = sprite.GameSprites() # Save this CURRENT_FLOOR = 1 # Save this TURN_COUNT = 0 # Save this MAP_INFO = gamemap.MapInfo() CAMERA = camera.Camera(MAP_INFO) PATHFINDING = pathfinding.Graph() PATHFINDING.make_graph(MAP_INFO) PATHFINDING.neighbour() # Save this PLAYER = entity_generator.generate_player(MAP_INFO.map_tree, "knight") # Save this GAME_DATA = game_data.GameData() FOV = fov.new_fov(MAP_INFO) PARTICLE_LIST = [] WALL_HACK = False