diff options
| author | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-09-23 14:38:13 +0000 |
|---|---|---|
| committer | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-09-23 14:38:13 +0000 |
| commit | c94b1f22ab5d1522abfcedef8cf3a62848c370c1 (patch) | |
| tree | 4eb58340a78bd605d722d951b307bf1a7b476b2c /src/game/collision.cpp | |
| parent | 815c55c4ce58995dcc34627bcbed956d1a1bc4dd (diff) | |
| download | zcatch-c94b1f22ab5d1522abfcedef8cf3a62848c370c1.tar.gz zcatch-c94b1f22ab5d1522abfcedef8cf3a62848c370c1.zip | |
added non-hookable tile
Diffstat (limited to 'src/game/collision.cpp')
| -rw-r--r-- | src/game/collision.cpp | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/game/collision.cpp b/src/game/collision.cpp index 6d63091b..2747b22f 100644 --- a/src/game/collision.cpp +++ b/src/game/collision.cpp @@ -21,6 +21,24 @@ int col_init() width = layers_game_layer()->width; height = layers_game_layer()->height; tiles = (TILE *)map_get_data(layers_game_layer()->data); + + for(int i = 0; i < width*height; i++) + { + int index = tiles[i].index; + + if(index > 128) + continue; + + if(index == TILE_DEATH) + tiles[i].index = COLFLAG_DEATH; + else if(index == TILE_SOLID) + tiles[i].index = COLFLAG_SOLID; + else if(index == TILE_NOHOOK) + tiles[i].index = COLFLAG_SOLID|COLFLAG_NOHOOK; + else + tiles[i].index = 0; + } + return 1; } @@ -42,7 +60,7 @@ int col_is_solid(int x, int y) // TODO: rewrite this smarter! -bool col_intersect_line(vec2 pos0, vec2 pos1, vec2 *out) +int col_intersect_line(vec2 pos0, vec2 pos1, vec2 *out) { float d = distance(pos0, pos1); @@ -54,10 +72,10 @@ bool col_intersect_line(vec2 pos0, vec2 pos1, vec2 *out) { if(out) *out = pos; - return true; + return col_get((int)pos.x, (int)pos.y); } } if(out) *out = pos1; - return false; + return 0; } |