- int v = (int)pbase.height / 16;
- int h = (int)pbase.width / 16;
-
- if(issolid(pbase.x + 1, pbase.y + 1) ||
- issolid(pbase.x + pbase.width -1, pbase.y + 1) ||
- issolid(pbase.x +1, pbase.y + pbase.height -1) ||
- issolid(pbase.x + pbase.width -1, pbase.y + pbase.height - 1))
- return true;
-
- for(int i = 1; i < h; ++i)
- {
- if(issolid(pbase.x + i*16,pbase.y + 1))
- return true;
- }
-
- for(int i = 1; i < h; ++i)
- {
- if( issolid(pbase.x + i*16,pbase.y + pbase.height - 1))
- return true;
- }
-
- for(int i = 1; i < v; ++i)
- {
- if( issolid(pbase.x + 1, pbase.y + i*16))
- return true;
- }
- for(int i = 1; i < v; ++i)
- {
- if( issolid(pbase.x + pbase.width - 1, pbase.y + i*16))
+ if(!World::current())
+ return false;
+
+ const Level& level = *World::current()->get_level();
+ TileManager& tilemanager = *TileManager::instance();
+
+ // we make the collision rectangle 1 pixel smaller
+ int starttilex = int(base.x+1) / 32;
+ int starttiley = int(base.y+1) / 32;
+ int max_x = int(base.x + base.width);
+ int max_y = int(base.y + base.height);
+
+ for(int x = starttilex; x*32 < max_x; ++x) {
+ for(int y = starttiley; y*32 < max_y; ++y) {
+ Tile* tile = tilemanager.get(level.get_tile_at(x, y));
+ if(tile && tile->solid)