Giter Site home page Giter Site logo

a-star-pathfinder's Introduction

A-Star-PathFinder

A星寻路算法 for cocos2dx-lua

寻路的时候需要传入开始坐标,目标坐标以及存放所有地块格子的table。

1.关于地块格子(block)的划分方式

每个block为一个table

local block = {}

block.w = w --在整个地图划分中所处的行

block.h = h --在整个地图划分中所处的列

block.pos = pos --格子的中心点在地图中的坐标		

block.couldCross = true --表示该格子是否是可以通过的

然后将block以键值string.format("%d_%d",block.w,block.h) 存入blocks中

2.关于路径的缓存 为了提高效率,完成一次寻路后会把相关路径信息缓存到aster.cachedPaths中,在地图变化时需要手动调用astar.clear_cached_paths清除缓存信息

a-star-pathfinder's People

Contributors

zhaotianze avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.