X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fobject%2Ftilemap.cpp;h=a3e11eabacb0e7f1809255c753cc00e4a78e4211;hb=75acd4b141f45e851a492f089aa9ad24a9552409;hp=d24cacab97a4a346383757066d6ec3383f20b837;hpb=b4b8af638ac4ed8dbe0f081b453f568f585899de;p=supertux.git diff --git a/src/object/tilemap.cpp b/src/object/tilemap.cpp index d24cacab9..a3e11eaba 100644 --- a/src/object/tilemap.cpp +++ b/src/object/tilemap.cpp @@ -95,16 +95,26 @@ TileMap::TileMap(const lisp::Lisp& reader) if(width < 0 || height < 0) throw std::runtime_error("Invalid/No width/height specified in tilemap."); - if(!reader.get_vector("tiles", tiles)) + if(!reader.get("tiles", tiles)) throw std::runtime_error("No tiles in tilemap."); if(int(tiles.size()) != width*height) { throw std::runtime_error("wrong number of tiles in tilemap."); } - // make sure all tiles used on the tilemap are loaded - for(Tiles::iterator i = tiles.begin(); i != tiles.end(); ++i) + bool empty = true; + + // make sure all tiles used on the tilemap are loaded and tilemap isn't empty + for(Tiles::iterator i = tiles.begin(); i != tiles.end(); ++i) { + if(*i != 0) { + empty = false; + } + tileset->get(*i); + } + + if(empty) + log_info << "Tilemap '" << name << "', z-pos '" << z_pos << "' is empty." << std::endl; } TileMap::TileMap(const TileSet *new_tileset, std::string name, int z_pos, @@ -128,14 +138,14 @@ TileMap::write(lisp::Writer& writer) { writer.start_list("tilemap"); - writer.write_int("z-pos", z_pos); + writer.write("z-pos", z_pos); - writer.write_bool("solid", solid); - writer.write_float("speed", speed_x); - writer.write_float("speed-y", speed_y); - writer.write_int("width", width); - writer.write_int("height", height); - writer.write_int_vector("tiles", tiles); + writer.write("solid", solid); + writer.write("speed", speed_x); + writer.write("speed-y", speed_y); + writer.write("width", width); + writer.write("height", height); + writer.write("tiles", tiles); writer.end_list("tilemap"); } @@ -182,7 +192,8 @@ TileMap::draw(DrawingContext& context) float trans_x = roundf(context.get_translation().x); float trans_y = roundf(context.get_translation().y); - context.set_translation(Vector(trans_x * speed_x, trans_y * speed_y)); + context.set_translation(Vector(int(trans_x * speed_x), + int(trans_y * speed_y))); /** if we don't round here, we'll have a 1 pixel gap on screen sometimes. * I have no idea why */