liblashgame

Pathfinder and path decision making library for 2D tile game
git clone git://holbrook.no/liblashgame.git
Info | Log | Files | Refs

lash_game_path_simple.h (3762B)


      1 #ifndef LASH_GAME_PATH_SIMPLE_H_
      2 #define LASH_GAME_PATH_SIMPLE_H_
      3 
      4 #include "liblashgame/lash_game_standard.h"
      5 #include "liblashgame/lash_game_map.h"
      6 #include "liblash/lash_tree3.h"
      7 
      8 #define LASH_GAME_PATH_SIMPLE_SCORE_STRAIGHT 10
      9 #define LASH_GAME_PATH_SIMPLE_SCORE_DIAGONAL 14
     10 
     11 // Defines amount of RESISTANCE
     12 // Divide map value with modifier for resistance "NONE" = number to be multiplied by velocity
     13 // Restistance NONE (192) = 192 / 192 = 1.0 of original movement
     14 // Resistance TWOTHIRDS (64) = 64 / 192 = 0.3333 of original movement
     15 #define LASH_GAME_PATH_SIMPLE_OBSTACLE_MODIFIER_NONE 192
     16 #define LASH_GAME_PATH_SIMPLE_OBSTACLE_MODIFIER_QUARTER 144
     17 #define LASH_GAME_PATH_SIMPLE_OBSTACLE_MODIFIER_THIRD 128
     18 #define LASH_GAME_PATH_SIMPLE_OBSTACLE_MODIFIER_HALF 96
     19 #define LASH_GAME_PATH_SIMPLE_OBSTACLE_MODIFIER_TWOTHIRDS 64
     20 #define LASH_GAME_PATH_SIMPLE_OBSTACLE_MODIFIER_THREEQUARTER 48
     21 #define LASH_GAME_PATH_SIMPLE_OBSTACLE_MODIFIER_FULL 0
     22 
     23 #define LASH_GAME_PATH_SIMPLE_OBSTACLE_DEFAULT_COUNT 2
     24 
     25 typedef struct lash_path_simple_obstacle_t lash_path_simple_obstacle_t;
     26 
     27 struct lash_path_simple_obstacle_t {
     28 	lash_map_simple_layer_item_t val;
     29 	unsigned char modifier;
     30 };
     31 
     32 typedef struct lash_path_simple_space_t lash_path_simple_space_t;
     33 
     34 struct lash_path_simple_space_t {
     35 	lash_tree_key_t f;
     36 	unsigned char g;
     37 	unsigned int h;
     38 	lash_path_simple_space_t *parent;
     39 	lash_game_map_index_t index;
     40 };
     41 
     42 typedef struct lash_path_simple_t lash_path_simple_t;
     43 
     44 struct lash_path_simple_t {
     45 	unsigned int *w;
     46 	unsigned int *h;
     47 	lash_tree_t *opentree;
     48 	lash_tree_t *closedtree;
     49 	lash_path_simple_space_t *spaces;
     50 	unsigned int space_count;
     51 	unsigned int space_capacity;
     52 	lash_game_map_index_t source;
     53 	lash_game_map_index_t target;
     54 };
     55 
     56 //lash_path_simple_obstacle_t _lash_path_default_obstacles[2];
     57 lash_path_simple_obstacle_t *_lash_path_default_obstacles;
     58 
     59 #ifdef __cplusplus 
     60 extern "C" {
     61 #endif
     62 
     63 int lash_pathSimpleInit(void);
     64 void lash_pathSimpleFinish(void);
     65 lash_path_simple_t * lash_pathSimpleNew(lash_path_simple_t *path, lash_map_simple_t *map, const lash_game_map_index_t offsetindex, const lash_game_map_index_t targetindex);
     66 lash_path_simple_space_t * lash_pathSimpleNext(lash_path_simple_t *path, lash_path_simple_space_t **space);
     67 float lash_pathSimpleCheckModifier(const lash_map_simple_layer_item_t *layeritem, const lash_path_simple_obstacle_t *obstacleslist, const unsigned char obstaclescount);
     68 unsigned int lash_pathSimpleStepProcess(lash_path_simple_t *path, lash_map_simple_t *map, lash_path_simple_space_t *center, lash_path_simple_obstacle_t *obstacleslist, unsigned char obstaclescount);
     69 void lash_pathSimpleFree(lash_path_simple_t *path);
     70 
     71 lash_path_simple_t * _lash_pathSimpleUpdateSpace(lash_path_simple_t *path, lash_path_simple_space_t *currentspace, lash_path_simple_space_t *parent, const lash_game_map_index_t currentindex, const unsigned int g);
     72 lash_path_simple_space_t * _lash_pathSimpleAddSpace(lash_path_simple_t *path);
     73 lash_path_simple_space_t * _lash_pathSimpleFindIndexInTree(lash_tree_t *tree, lash_game_map_index_t index);
     74 int _lash_pathSimpleClose(lash_path_simple_t *path, lash_path_simple_space_t *space);
     75 
     76 int lash_pathSimpleCompileFreeSpaces(unsigned int **freeindices, const unsigned int freeindices_capacity, lash_map_simple_layer_t *sourcelayer, unsigned int sourcelayer_count, lash_path_simple_obstacle_t *obstacleslist, unsigned char obstaclescount);
     77 int lash_pathSimpleCompileMaxObstructedSpaces(unsigned int **freeindices, const unsigned int freeindices_capacity, lash_map_simple_layer_t *sourcelayer, unsigned int sourcelayer_count, lash_path_simple_obstacle_t *obstacleslist, unsigned char obstaclescount, const float modifier_threshold);
     78 
     79 #ifdef __cplusplus 
     80 }
     81 #endif
     82 
     83 #endif //LASH_GAME_PATH_SIMPLE_H_