+ if(reader.read_int("slope-type", data)) {
+ attributes |= SOLID | SLOPE;
+ }
+
+ parse_images(reader.read_lisp("images"));
+ reader.read_string("editor-images", editor_imagefile);
+}
+
+void
+Tile::parse_images(lisp_object_t* list)
+{
+ while(!lisp_nil_p(list)) {
+ lisp_object_t* cur = lisp_car(list);
+ if(lisp_string_p(cur)) {
+ imagespecs.push_back(ImageSpec(lisp_string(cur), Rectangle(0, 0, 0, 0)));
+ } else if(lisp_cons_p(cur) && lisp_symbol_p(lisp_car(cur))) {
+ lisp_object_t* sym = lisp_car(cur);
+ lisp_object_t* data = lisp_cdr(cur);
+
+ if (strcmp(lisp_symbol(sym), "region") == 0) {
+ float x = lisp_integer(lisp_list_nth(data, 1));
+ float y = lisp_integer(lisp_list_nth(data, 2));
+ float width = lisp_integer(lisp_list_nth(data, 3));
+ float height = lisp_integer(lisp_list_nth(data, 4));
+ imagespecs.push_back(ImageSpec(lisp_string(lisp_car(data)),
+ Rectangle(x, y, x+width, y+height)));
+ } else {
+ std::cerr << "Tile: Type mismatch, should be '(region \"somestring\" x y w h)'" << std::endl;
+ continue;
+ }
+ } else {
+ std::cerr << "Expected string or list in images tag.\n";
+ continue;
+ }
+
+ list = lisp_cdr(list);
+ }
+}
+
+void
+Tile::load_images()
+{
+ assert(images.size() == 0);
+ for(std::vector<ImageSpec>::iterator i = imagespecs.begin(); i !=
+ imagespecs.end(); ++i) {
+ const ImageSpec& spec = *i;
+ Surface* surface;
+ std::string file
+ = get_resource_filename(std::string("images/tilesets/") + spec.file);
+ if(spec.rect.get_width() <= 0) {
+ surface = new Surface(file, true);
+ } else {
+ surface = new Surface(file,
+ (int) spec.rect.p1.x,
+ (int) spec.rect.p1.y,
+ (int) spec.rect.get_width(),
+ (int) spec.rect.get_height(), true);