liblashgame

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

pathcheckmodifier.c (1467B)


      1 // check modifier check
      2 
      3 #include <stdlib.h>
      4 #include <stdio.h>
      5 #include <time.h>
      6 #include "../lash_game_path_simple.h"
      7 #include "../lash_game_map.h"
      8 
      9 int main() {
     10 	clock_t test_clock_total = 0.f;
     11 	clock_t begin;
     12 	unsigned int w = 29;
     13 	unsigned int h = 21;
     14 	lash_path_simple_obstacle_t *o = (lash_path_simple_obstacle_t*)malloc(sizeof(lash_path_simple_obstacle_t)*3);
     15 	o->val = 1;
     16 	o->modifier = LASH_GAME_PATH_SIMPLE_OBSTACLE_MODIFIER_FULL;
     17 	(o+1)->val = 2;
     18 	(o+1)->modifier = LASH_GAME_PATH_SIMPLE_OBSTACLE_MODIFIER_HALF;
     19 	
     20 	lash_map_simple_t map;
     21 	lash_mapSimpleInit(&map, &w, &h);
     22 	lash_mapSimpleLayerPoke(map.layer_path, 10, 1);
     23 	lash_mapSimpleLayerPoke(map.layer_path, 20, 2);
     24 	lash_mapSimpleLayerPoke(map.layer_path, 30, 3);
     25 	
     26 	float r;
     27 	
     28 	begin = clock();
     29 	r = lash_pathSimpleCheckModifier(&(map.layer_path + 10)->val, o, 2);
     30 	test_clock_total += clock() - begin;
     31 	printf("Check idx 10 content 1: %f\n", r);
     32 	
     33 	begin = clock();
     34 	r = lash_pathSimpleCheckModifier(&(map.layer_path + 20)->val, o, 2);
     35 	test_clock_total += clock() - begin;
     36 	printf("Check idx 20 content 2: %f\n", r);
     37 	
     38 	begin = clock();
     39 	r = lash_pathSimpleCheckModifier(&(map.layer_path + 30)->val, o, 2);
     40 	test_clock_total += clock() - begin;
     41 	printf("Check idx 30 content 3: %f\n", r);
     42 	
     43 	test_clock_total /= 3;
     44 	
     45 	printf("Total checktime (avg of 3): %lu ticks @ %li pr sec = %.7f secs\n\n", (long)test_clock_total, CLOCKS_PER_SEC, ((double)test_clock_total / CLOCKS_PER_SEC));
     46 	
     47 	return 0;
     48 }