diff options
| author | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-09-23 14:10:05 +0000 |
|---|---|---|
| committer | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-09-23 14:10:05 +0000 |
| commit | 815c55c4ce58995dcc34627bcbed956d1a1bc4dd (patch) | |
| tree | ae33fb8915f06865369208c5402122555b90d905 /src/game/collision.cpp | |
| parent | 8f9e2031dcd562e72ac7e5ec9c00b8aed10b53a6 (diff) | |
| download | zcatch-815c55c4ce58995dcc34627bcbed956d1a1bc4dd.tar.gz zcatch-815c55c4ce58995dcc34627bcbed956d1a1bc4dd.zip | |
added death tile
Diffstat (limited to 'src/game/collision.cpp')
| -rw-r--r-- | src/game/collision.cpp | 62 |
1 files changed, 13 insertions, 49 deletions
diff --git a/src/game/collision.cpp b/src/game/collision.cpp index c1e08441..6d63091b 100644 --- a/src/game/collision.cpp +++ b/src/game/collision.cpp @@ -7,6 +7,7 @@ #include <engine/e_common_interface.h> #include <game/mapitems.hpp> #include <game/layers.hpp> +#include <game/collision.hpp> static TILE *tiles; static int width = 0; @@ -24,19 +25,22 @@ int col_init() } -int col_is_solid(int x, int y) +int col_get(int x, int y) { - int nx = x/32; - int ny = y/32; - if(nx < 0 || nx >= width || ny >= height) - return 1; - - if(y < 0) - return 0; // up == sky == free + int nx = clamp(x/32, 0, width-1); + int ny = clamp(y/32, 0, height-1); - return tiles[ny*width+nx].index == TILE_SOLID; + if(tiles[ny*width+nx].index > 128) + return 0; + return tiles[ny*width+nx].index; +} + +int col_is_solid(int x, int y) +{ + return col_get(x,y)&COLFLAG_SOLID; } + // TODO: rewrite this smarter! bool col_intersect_line(vec2 pos0, vec2 pos1, vec2 *out) { @@ -57,43 +61,3 @@ bool col_intersect_line(vec2 pos0, vec2 pos1, vec2 *out) *out = pos1; return false; } - -/* - 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; -} - -*/ |