X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;ds=inline;f=src%2Fobject%2Ftilemap.cpp;h=fb0cb63d7a4bc245bb7d87c9656562e839e6246f;hb=e3bb6e46812f108f093e9ad0751a945c34b18cd3;hp=fd6c74dd4453ae296c66543024a96135db1169a4;hpb=ef57479f613b900b73eba8e8f4d026aae0de25cc;p=supertux.git diff --git a/src/object/tilemap.cpp b/src/object/tilemap.cpp index fd6c74dd4..fb0cb63d7 100644 --- a/src/object/tilemap.cpp +++ b/src/object/tilemap.cpp @@ -33,6 +33,7 @@ #include "app/globals.h" #include "lisp/lisp.h" #include "lisp/writer.h" +#include "object_factory.h" TileMap::TileMap() : solid(false), speed(1), width(0), height(0), layer(LAYER_TILES), @@ -144,7 +145,9 @@ TileMap::draw(DrawingContext& context) /** if we don't round here, we'll have a 1 pixel gap on screen sometimes. * I have no idea why */ float start_x = roundf(context.get_translation().x); + if(start_x < 0) start_x = 0; float start_y = roundf(context.get_translation().y); + if(start_y < 0) start_y = 0; float end_x = std::min(start_x + screen->w, float(width * 32)); float end_y = std::min(start_y + screen->h, float(height * 32)); start_x -= int(start_x) % 32; @@ -275,3 +278,5 @@ TileMap::change_at(const Vector& pos, uint32_t newtile) { change(int(pos.x)/32, int(pos.y)/32, newtile); } + +IMPLEMENT_FACTORY(TileMap, "tilemap");