CL_Sprite get_sprite() const { if (sprite) { return sprite; } else { NetPanzerTileGroup& tilegroup = NetPanzerData::instance()->find_tilegroup(id); int dist = id - tilegroup.start; CL_Rect rect(CL_Point((dist % tilegroup.width) * 32, (dist / tilegroup.width) * 32), CL_Size(32, 32)); sprite.add_frame(tilegroup.get_surface(), rect); return sprite; } }
CL_Sprite NetPanzerData::get_tilegroup_sprite(int index) { for(TileGroups::iterator i = tilegroups.begin(); i != tilegroups.end(); ++i) { if (index == i->start) { CL_Sprite sprite; sprite.add_frame(i->get_surface(), CL_Rect(CL_Point(0, 0), CL_Size(i->get_surface().get_width(), i->get_surface().get_height()))); return sprite; } } std::cout << "NetPanzerData: Couldn't get tilegroup_sprite for '" << index << "'" << std::endl; return CL_Sprite(); }