[Super-tux-commit] supertux/src sector.cpp,1.39,1.40 sector.h,1.23,1.24
Brought to you by:
wkendrick
From: Matze B. <mat...@us...> - 2004-11-22 23:48:03
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28925/src Modified Files: sector.cpp sector.h Log Message: properly implement invisible blocks Index: sector.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/sector.h,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- sector.h 22 Nov 2004 21:35:04 -0000 1.23 +++ sector.h 22 Nov 2004 23:47:49 -0000 1.24 @@ -153,6 +153,8 @@ GameObjects gameobjects; private: + void fix_old_tiles(); + /// container for newly created objects, they'll be added in Sector::action GameObjects gameobjects_new; Index: sector.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/sector.cpp,v retrieving revision 1.39 retrieving revision 1.40 diff -u -d -r1.39 -r1.40 --- sector.cpp 22 Nov 2004 21:35:04 -0000 1.39 +++ sector.cpp 22 Nov 2004 23:47:49 -0000 1.40 @@ -44,6 +44,7 @@ #include "math/aatriangle.h" #include "object/coin.h" #include "object/block.h" +#include "object/invisible_block.h" #include "object/platform.h" #include "trigger/door.h" #include "object/bullet.h" @@ -121,6 +122,7 @@ return 0; } solids = tilemap; + fix_old_tiles(); } return tilemap; } else if(name == "particles-snow") { @@ -275,31 +277,7 @@ solids = tilemap; add_object(tilemap); - // hack for now... - for(size_t x=0; x < solids->get_width(); ++x) { - for(size_t y=0; y < solids->get_height(); ++y) { - const Tile* tile = solids->get_tile(x, y); - - if(tile->attributes & Tile::COIN) { - Coin* coin = new Coin(Vector(x*32, y*32)); - add_object(coin); - solids->change(x, y, 0); - } else if(tile->attributes & Tile::FULLBOX) { - BonusBlock* block = new BonusBlock(Vector(x*32, y*32), tile->data); - add_object(block); - solids->change(x, y, 0); - } else if(tile->attributes & Tile::BRICK) { - Brick* brick = new Brick(Vector(x*32, y*32), tile->data); - add_object(brick); - solids->change(x, y, 0); - } else if(tile->attributes & Tile::GOAL) { - SequenceTrigger* trigger = new SequenceTrigger(Vector(x*32, y*32), - "endsequence"); - add_object(trigger); - solids->change(x, y, 0); - } - } - } + fix_old_tiles(); } if(reader.read_int_vector("background-tm", tiles)) { @@ -364,6 +342,35 @@ } void +Sector::fix_old_tiles() +{ + // hack for now... + for(size_t x=0; x < solids->get_width(); ++x) { + for(size_t y=0; y < solids->get_height(); ++y) { + const Tile* tile = solids->get_tile(x, y); + Vector pos(x*32, y*32); + + if(tile->id == 112) { + add_object(new InvisibleBlock(pos)); + solids->change(x, y, 0); + } else if(tile->attributes & Tile::COIN) { + add_object(new Coin(pos)); + solids->change(x, y, 0); + } else if(tile->attributes & Tile::FULLBOX) { + add_object(new BonusBlock(pos, tile->data)); + solids->change(x, y, 0); + } else if(tile->attributes & Tile::BRICK) { + add_object(new Brick(pos, tile->data)); + solids->change(x, y, 0); + } else if(tile->attributes & Tile::GOAL) { + add_object(new SequenceTrigger(pos, "endsequence")); + solids->change(x, y, 0); + } + } + } +} + +void Sector::write(LispWriter& writer) { writer.write_string("name", name); |