diff options
| author | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-01-13 11:15:32 +0000 |
|---|---|---|
| committer | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-01-13 11:15:32 +0000 |
| commit | ea245b969d1864441b41d25c7631beccfb39d874 (patch) | |
| tree | 68fb62ef99cdd90f5dd4ec8edf11e7bb54b7f953 /src/game/g_mapres_col.cpp | |
| parent | 906ece7894927983b8ac69e37dd3cb82cfe7aad1 (diff) | |
| download | zcatch-ea245b969d1864441b41d25c7631beccfb39d874.tar.gz zcatch-ea245b969d1864441b41d25c7631beccfb39d874.zip | |
new mapformat in place. continued the cleanup. some effects are gone, gonna be redone so no biggie. CTF isn't working now.
Diffstat (limited to 'src/game/g_mapres_col.cpp')
| -rw-r--r-- | src/game/g_mapres_col.cpp | 79 |
1 files changed, 0 insertions, 79 deletions
diff --git a/src/game/g_mapres_col.cpp b/src/game/g_mapres_col.cpp deleted file mode 100644 index 64a240bf..00000000 --- a/src/game/g_mapres_col.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ -#include <engine/e_system.h> -#include <game/g_vmath.h> -#include <game/g_math.h> -#include <math.h> -#include "../engine/e_interface.h" -#include "g_mapres_col.h" -#include "g_mapres.h" - -/* - Simple collision rutines! -*/ -struct collision -{ - int w, h; - unsigned char *data; -}; - -static collision col; -static int global_dividor; - -int col_width() -{ - return col.w; -} - -int col_height() -{ - return col.h; -} - -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]; -} - -// TODO: rewrite this smarter! -bool col_intersect_line(vec2 pos0, vec2 pos1, vec2 *out) -{ - float d = distance(pos0, pos1); - - for(float f = 0; f < d; f++) - { - float a = f/d; - vec2 pos = mix(pos0, pos1, a); - if(col_check_point((int)pos.x, (int)pos.y)) - { - if(out) - *out = pos; - return true; - } - } - if(out) - *out = pos1; - return false; -} |