This shows you the differences between two versions of the page.
| — |
pathfinding-for-orx-scroll [2022/09/01 12:43] (current) sausage created |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Pathfinding for games in Orx ====== | ||
| + | If you are interested in pathfinding for games written in Orx (intended mainly for orx/ | ||
| + | |||
| + | You can get a copy here: | ||
| + | https:// | ||
| + | |||
| + | The path-finding is loosely based on [[https:// | ||
| + | |||
| + | There' | ||
| + | |||
| + | {{ : | ||
| + | |||
| + | The source code is well commented to help you understand what you need to do. It should be fairly trivial to apply the '' | ||
| + | |||
| + | As this is not a full blown tutorial, I'll just point out the basic usage of the code. | ||
| + | |||
| + | ===== Room map configuration ===== | ||
| + | |||
| + | Here is an example of one of the defined rooms located in config: | ||
| + | |||
| + | <code ini> | ||
| + | [Room] | ||
| + | Cells = O # O # X # X # X # X # X # O # | ||
| + | O # O # O # O # O # O # O # O # | ||
| + | X # X # X # O # X # X # O # O # | ||
| + | X # O # O # O # X # X # O # O # | ||
| + | X # O # O # O # O # O # O # O # | ||
| + | O # O # X # X # O # O # O # O # | ||
| + | O # O # X # X # O # X # X # O # | ||
| + | O # O # X # X # O # X # X # O | ||
| + | </ | ||
| + | |||
| + | '' | ||
| + | '' | ||
| + | |||
| + | Start and end positions are not defined in the map, because these can be set at any time. | ||
| + | |||
| + | ===== Basic usage ===== | ||
| + | |||
| + | <code cpp> | ||
| + | Room *room = new Room(cellsAcross, | ||
| + | </ | ||
| + | |||
| + | This creates a new room, how many expected cells in both the horizontal and vertical directions, the the name of the room map to load from the config file. | ||
| + | |||
| + | <code cpp> | ||
| + | room-> | ||
| + | room-> | ||
| + | </ | ||
| + | |||
| + | Set the start and end cells. This represents the positions where a character will start walking from and where it will end up. | ||
| + | |||
| + | <code cpp> | ||
| + | room-> | ||
| + | </ | ||
| + | |||
| + | This builds the actual path ready to use. | ||
| + | |||
| + | <code cpp> | ||
| + | BuildTiles(); | ||
| + | </ | ||
| + | |||
| + | This is for debugging and creates a grid of grey tiles to represent the room and the path. This should only be run once. | ||
| + | |||
| + | <code cpp> | ||
| + | ColourTiles(); | ||
| + | </ | ||
| + | |||
| + | This is for debugging and uses both the cell and path data to represent the room and the path in colour. | ||
| + | |||
| + | <code cpp> | ||
| + | DumpPathData(); | ||
| + | DumpCellData(); | ||
| + | </ | ||
| + | |||
| + | These two dump functions log out path or cell data though only useful if you want to make changes to the code. | ||
| + | |||
| + | Any additional uses of '' | ||
| + | |||
| + | ===== Controls ===== | ||
| + | |||
| + | There' | ||
| + | |||
| + | The '' | ||
| + | |||
| + | ===== Have fun ===== | ||
| + | |||
| + | That's it have fun, and expand this code to suit your game. Eventually this might form a library for importing into an orx/Scroll game. | ||