/* call-seq: new new(tilesets) new(tile, tile2, tile3, tileset, ...) Creates a new map, either from an array containing tilesets' name, or from arguments being either a tileset's name or tiles. */ VALUE GameMap_initialize(int argc, VALUE *argv, VALUE self) { GameMap *ptr = getPtr<GameMap>(self); if (argc >= 1) { if (TYPE(argv[0]) == T_ARRAY) { int size = RARRAY_LEN(argv[0]); for (int i = 0; i < size; ++i) { VALUE val = rb_ary_entry(argv[0], i); ptr->addTileset(StringValuePtr(val)); } } else { for (int i = 0; i < argc; ++i) { argv[i] = rb_obj_as_string(argv[i]); ptr->addTileset(StringValuePtr(argv[i])); } } } return Qnil; }
/* call-seq: new new(tilesets) new(tile, tile2, tile3, tileset, ...) Creates a new map, either from an array containing tilesets' name, or from arguments being either a tileset's name or tiles. */ VALUE wrap<GameMap>(int argc, VALUE *argv, VALUE info) { GameMap *ptr = new GameMap; if (argc >= 1) { if (TYPE(argv[0]) == T_ARRAY) { int size = RARRAY_LEN(argv[0]); for (int i = 0; i < size; ++i) { VALUE val = rb_ary_entry(argv[0], i); ptr->addTileset(StringValuePtr(val)); } } else { for (int i = 0; i < argc; ++i) ptr->addTileset(StringValuePtr(argv[i])); } } VALUE tdata = Data_Wrap_Struct(info, 0, wrapped_free<GameMap>, ptr); return tdata; }