liblashgame

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

cartesianfloat.c (726B)


      1 // cartesian to float
      2 
      3 #include <stdio.h>
      4 #include <stdlib.h>
      5 #include "liblashgame/lash_game_standard.h"
      6 
      7 int main(int argc, char *argv[]) {
      8 	if (argc < 5) {
      9 		printf("Usage: %s x y w h", argv[0]);
     10 		return 1;
     11 	}
     12 	unsigned int w, h;
     13 	lash_game_coords_t coords_c;
     14 	lash_game_coords_float_t coords_f;
     15 	coords_c.x = atoi(argv[1]);
     16 	coords_c.y = atoi(argv[2]);
     17 	w = atoi(argv[3]);
     18 	h = atoi(argv[4]);
     19 	if (coords_c.x < 0 || coords_c.x > w || coords_c.y < 0 || coords_c.y > h) {
     20 		printf("X and Y must be within W and H\n");
     21 		return 1;
     22 	}
     23 	lash_cartesianToFloat(&coords_f, &w, &h, &coords_c);
     24 	printf("Cartesian: x%d,y%d\nDimensions: w%d,h%d\nFloat x%f,y%f\n", coords_c.x, coords_c.y, w, h, coords_f.x, coords_f.y);
     25 	return 0;
     26 }