diff options
| author | Magnus Auvinen <magnus.auvinen@gmail.com> | 2007-05-22 15:03:32 +0000 |
|---|---|---|
| committer | Magnus Auvinen <magnus.auvinen@gmail.com> | 2007-05-22 15:03:32 +0000 |
| commit | 73aa9b71c1d8b5c5065d1e474f13601da3ca6b20 (patch) | |
| tree | 88b6a0a4a2ebdd33a88f4a25682581d329d33f6b /src/game/mapres_col.cpp | |
| download | zcatch-73aa9b71c1d8b5c5065d1e474f13601da3ca6b20.tar.gz zcatch-73aa9b71c1d8b5c5065d1e474f13601da3ca6b20.zip | |
started the major restructure of svn
Diffstat (limited to 'src/game/mapres_col.cpp')
| -rw-r--r-- | src/game/mapres_col.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/game/mapres_col.cpp b/src/game/mapres_col.cpp new file mode 100644 index 00000000..0cf71986 --- /dev/null +++ b/src/game/mapres_col.cpp @@ -0,0 +1,44 @@ +#include <baselib/system.h> +#include "../interface.h" +#include "mapres_col.h" +#include "mapres.h" + +/* + Simple collision rutines! +*/ +struct collision +{ + int w, h; + unsigned char *data; +}; + +static collision col; +static int global_dividor; + +int col_init(int dividor) +{ + mapres_collision *c = (mapres_collision*)map_find_item(MAPRES_COLLISIONMAP,0); + if(!c) + { + dbg_msg("mapres_col", "failed!"); + return 0; + } + col.w = c->width; + col.h = c->height; + global_dividor = dividor; + col.data = (unsigned char *)map_get_data(c->data_index); + return col.data ? 1 : 0; +} + +int col_check_point(int x, int y) +{ + int nx = x/global_dividor; + int ny = y/global_dividor; + if(nx < 0 || nx >= col.w || ny >= col.h) + return 1; + + if(y < 0) + return 0; // up == sky == free + + return col.data[ny*col.w+nx]; +} |