labyrinth

diff src/level.h @ 0:8ba79034e8a6

labyrinth example initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 15 Jan 2015 14:59:38 +0200
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/level.h	Thu Jan 15 14:59:38 2015 +0200
     1.3 @@ -0,0 +1,36 @@
     1.4 +#ifndef LEVEL_H_
     1.5 +#define LEVEL_H_
     1.6 +
     1.7 +#define MAX_LEVEL_SIZE	64
     1.8 +
     1.9 +struct level {
    1.10 +	int cells[MAX_LEVEL_SIZE][MAX_LEVEL_SIZE];
    1.11 +	int num_cells[2];
    1.12 +	float cell_size;	/* in meters */
    1.13 +	float cell_height;	/* in meters */
    1.14 +	int start_pos[2];
    1.15 +
    1.16 +	float goal_pos[2];
    1.17 +
    1.18 +	unsigned int floor_tex, wall_tex, ceil_tex;
    1.19 +	float floor_tex_scale, wall_tex_scale, ceil_tex_scale;
    1.20 +};
    1.21 +
    1.22 +void level_init(struct level *lvl);
    1.23 +int level_load(struct level *lvl, const char *fname);
    1.24 +
    1.25 +/* convert from cell coords to world space pos and back */
    1.26 +void level_pos_to_cell(struct level *lvl, float x, float y, int *res_cx, int *res_cy);
    1.27 +void level_cell_to_pos(struct level *lvl, int cx, int cy, float *resx, float *resy);
    1.28 +
    1.29 +int level_cell(struct level *lvl, int cx, int cy);
    1.30 +int level_cell_at(struct level *lvl, float x, float y);
    1.31 +
    1.32 +int level_obj_pos(struct level *lvl, int objname, float *resx, float *resy);
    1.33 +
    1.34 +/* direction parameters are in-out */
    1.35 +int level_collide(struct level *lvl, float rad, float x, float y, float *dx, float *dy);
    1.36 +
    1.37 +void level_draw(struct level *lvl);
    1.38 +
    1.39 +#endif	/* LEVEL_H_ */