Parses the collision map and sets the tile states as necessary.
775976
def parse_collisions(self):
        """"""
        fs = open(self.collisionmap_path, "r")
        self.collisionmap = fs.readlines()
        fs.close()

        x_index = 0
        y_index = 0
        for line in self.collisionmap:
            if line[0] is "#":
                continue
            for char in line:
                if char is "":
                    continue
                #An empty character is the same as collision type 0
                elif char is " ":
                    char = "0"
                elif char is "s":
                    #Placing the start location
                    self.start_location = self.tiles_to_pixels(Vector2(x_index, y_index))
                    char = "0"
                elif not (char in self.tile_bindings):
                    continue

                self.tiles[y_index][x_index].binding_type = self.tile_bindings[char]
                x_index += 1

            x_index = 0
            y_index += 1
966819
function() {
		var spriteIndex = this.currentSprite << 2,
			y = this.oam2[ spriteIndex ],
			tileIndex = this.oam2[ spriteIndex + 1 ],
			attributes = this.oam2[ spriteIndex + 2 ],
			x = this.oam2[ spriteIndex + 3 ],
			baseTable = this.baseTable,
			tile = 0,
			flipX = attributes & 0x40,
			flipY = 0,
			fineY = 0;

		flipY = attributes & 0x80;
		fineY = ( this.ppu.scanline - y ) & ( this.spriteSize - 1 );
		// (the '& spriteSize' is needed because fineY can overflow due
		// to uninitialized tiles in secondary OAM)

		if ( this.spriteSize === 16 ) {
			// big sprite, select proper nametable and handle flipping
			baseTable = ( tileIndex & 1 ) ? 0x1000 : 0;
			tileIndex = tileIndex & ~1;

			if ( fineY > 7 ) {
				fineY -= 8;
				if ( !flipY ) {
					tileIndex++;
				}
			} else if ( flipY ) {
				tileIndex++;
			}
		}

		if ( flipY ) {
			fineY = 8 - fineY - 1;
		}

		tile = this.memory.cartridge.readTile( baseTable, tileIndex, fineY );

		if ( flipX ) {
			tile = bitmap.reverseTile( tile );
		}

		if ( this.currentSprite < this.nextSpriteCount ) {
			this.renderTile( x, tile, attributes );
		}

		this.currentSprite += 1;
	}
1325363
function(tile) {
        tile.unload();
        tile.events.un({
            "loadstart": tile.onLoadStart,
            "loadend": tile.onLoadEnd,
            "unload": tile.onLoadEnd,
            "loaderror": tile.onLoadError,
            scope: this
        });
    }
575044
private void update(Collision collision,
                        double x,
                        double y,
                        int width,
                        int height,
                        Map<Collision, Rectangle> cacheRectRender)
    {
        if (boxs.containsKey(collision))
        {
            final Rectangle rectangle = boxs.get(collision);
            rectangle.set(x, y, width, height);
            cacheRectRender.get(collision).set(x, y, width, height);
        }
        else
        {
            final Rectangle rectangle = new Rectangle(x, y, width, height);
            cacheColls.add(collision);
            cacheRect.add(rectangle);
            cacheRectRender.put(collision, new Rectangle(x, y, width, height));
            boxs.put(collision, rectangle);
        }
    }
653388
function() {
        var buffer = this.buffer + 1;
        while(true) {
            var tlTile = this.grid[0][0];
            var tlViewPort = {
                x: tlTile.position.x +
                    this.map.layerContainerOriginPx.x,
                y: tlTile.position.y +
                    this.map.layerContainerOriginPx.y
            };
            var ratio = this.getServerResolution() / this.map.getResolution();
            var tileSize = {
                w: Math.round(this.tileSize.w * ratio),
                h: Math.round(this.tileSize.h * ratio)
            };
            if (tlViewPort.x > -tileSize.w * (buffer - 1)) {
                this.shiftColumn(true, tileSize);
            } else if (tlViewPort.x < -tileSize.w * buffer) {
                this.shiftColumn(false, tileSize);
            } else if (tlViewPort.y > -tileSize.h * (buffer - 1)) {
                this.shiftRow(true, tileSize);
            } else if (tlViewPort.y < -tileSize.h * buffer) {
                this.shiftRow(false, tileSize);
            } else {
                break;
            }
        }
    }
662398
private void updateTile(Tile tile, Tile neighbor, Circuit circuit)
    {
        final Iterator<TileRef> iterator = getTiles(circuit).iterator();
        while (iterator.hasNext())
        {
            final TileRef newTile = iterator.next();
            if (mapGroup.getGroup(newTile).equals(mapGroup.getGroup(tile)))
            {
                map.setTile(map.createTile(newTile.getSheet(), newTile.getNumber(), neighbor.getX(), neighbor.getY()));
                break;
            }
        }
    }
734989
public void applyToTiles (Rectangle region, TileOp op)
    {
        // determine which tiles intersect this region: this is going to
        // be nearly incomprehensible without some sort of diagram; i'll
        // do what i can to comment it, but you'll want to print out a
        // scene diagram (docs/miso/scene.ps) and start making notes if
        // you want to follow along

        // obtain our upper left tile
        Point tpos = MisoUtil.screenToTile(_metrics, region.x, region.y, new Point());

        // determine which quadrant of the upper left tile we occupy
        Point spos = MisoUtil.tileToScreen(_metrics, tpos.x, tpos.y, new Point());
        boolean left = (region.x - spos.x < _metrics.tilehwid);
        boolean top = (region.y - spos.y < _metrics.tilehhei);

        // set up our tile position counters
        int dx, dy;
        if (left) {
            dx = 0;
            dy = 1;
        } else {
            dx = 1;
            dy = 0;
        }

        // if we're in the top-half of the tile we need to move up a row,
        // either forward or back depending on whether we're in the left
        // or right half of the tile
        if (top) {
            if (left) {
                tpos.x -= 1;
            } else {
                tpos.y -= 1;
            }
            // we'll need to start zig-zagging the other way as well
            dx = 1 - dx;
            dy = 1 - dy;
        }

        // these will bound our loops
        int rightx = region.x + region.width, bottomy = region.y + region.height;

// Log.info("Preparing to apply [tpos=" + StringUtil.toString(tpos) +
// ", left=" + left + ", top=" + top +
// ", bounds=" + StringUtil.toString(bounds) +
// ", spos=" + StringUtil.toString(spos) +
// "].");

        // obtain the coordinates of the tile that starts the first row
        // and loop through, applying to the intersecting tiles
        MisoUtil.tileToScreen(_metrics, tpos.x, tpos.y, spos);
        while (spos.y < bottomy) {
            // set up our row counters
            int tx = tpos.x, ty = tpos.y;
            _tbounds.x = spos.x;
            _tbounds.y = spos.y;

// Log.info("Applying to row [tx=" + tx + ", ty=" + ty + "].");

            // apply to the tiles in this row
            while (_tbounds.x < rightx) {
                op.apply(tx, ty, _tbounds);

                // move one tile to the right
                tx += 1;
                ty -= 1;
                _tbounds.x += _metrics.tilewid;
            }

            // update our tile coordinates
            tpos.x += dx;
            dx = 1 - dx;
            tpos.y += dy;
            dy = 1 - dy;

            // obtain the screen coordinates of the next starting tile
            MisoUtil.tileToScreen(_metrics, tpos.x, tpos.y, spos);
        }
    }
888385
private void subsection(TileBasedMap map, Space space, ArrayList spaces) {
		if (!clear(map, space)) {
			float width2 = space.getWidth()/2;
			float height2 = space.getHeight()/2;
			
			if ((width2 < smallestSpace) && (height2 < smallestSpace)) {
				return;
			}
			
			subsection(map, new Space(space.getX(), space.getY(), width2, height2), spaces);
			subsection(map, new Space(space.getX(), space.getY()+height2, width2, height2), spaces);
			subsection(map, new Space(space.getX()+width2, space.getY(), width2, height2), spaces);
			subsection(map, new Space(space.getX()+width2, space.getY()+height2, width2, height2), spaces);
		} else {
			spaces.add(space);
		}
	}
415810
private void updateTile(Collection<Tile> resolved,
                            Collection<Tile> toResolve,
                            Tile tile,
                            Tile neighbor,
                            Transition transition)
    {
        final Iterator<TileRef> iterator = getTiles(transition).iterator();
        if (iterator.hasNext())
        {
            final TileRef ref = iterator.next();
            final Tile newTile = map.createTile(ref.getSheet(), ref.getNumber(), neighbor.getX(), neighbor.getY());
            map.setTile(newTile);
            resolved.add(newTile);
        }
        else
        {
            final Tile newTile = map.createTile(tile.getSheet(), tile.getNumber(), neighbor.getX(), neighbor.getY());
            final String groupA = mapGroup.getGroup(tile);
            final String groupB = mapGroup.getGroup(neighbor);

            // Used to fix transitions not found
            if (!neighbor.equals(newTile)
                && (!isCenter(neighbor)
                    || groupA.equals(groupB)
                    || groupLinks.contains(new GroupTransition(groupA, groupB))))
            {
                map.setTile(newTile);
                toResolve.add(newTile);
            }
            resolved.add(newTile);
        }
    }
992502
void validateState() {
        if (frames == null || coroutine == null) {
            throw new IllegalStateException("Bad state");
        }

        for (int i = 0; i < frames.length; i++) {
            if (frames[i] == null) {
                throw new IllegalStateException("Bad state");
            }
            frames[i].validateState();
        }
    }
1266647
function () {

            if (this.animatedTilesets === undefined) {
                this.animatedTilesets = [];
            }

            if (this.tilesets) {
                var tileset = this.tilesets.tilesets;
                for (var i = 0; i < tileset.length; i++) {
                    if (tileset[i].isAnimated) {
                        this.animatedTilesets.push(tileset[i]);
                    }
                }
            }

            this.isAnimated = this.animatedTilesets.length > 0;

            // Force pre-render off when tileset animation is used
            if (this.isAnimated) {
                this.preRender = false;
            }

            // Resize the bounding rect
            var bounds = this.getRenderer().getBounds(this);
            this.getBounds().resize(bounds.width, bounds.height);

            // if pre-rendering method is use, create an offline canvas/renderer
            if ((this.preRender === true) && (!this.canvasRenderer)) {
                this.canvasRenderer = new me.CanvasRenderer(
                    me.video.createCanvas(this.width, this.height),
                    this.width, this.height,
                    { transparent : true }
                );
            }
        }
1175852
private void checkTransitives(Tile neighbor, String group, GroupTransition current, TileRef ref)
    {
        if (!group.equals(current.getOut())
            && TransitionType.CENTER == mapTransition.getTransition(ref, current.getOut()).getType())
        {
            map.setTile(map.createTile(ref.getSheet(), ref.getNumber(), neighbor.getX(), neighbor.getY()));
        }
    }
944918
function(done) {
    var self = this;
    this.fire('updated');
    this.fire('loading');
    var map = this.options.map;

    this.getTiles(function(urls, err) {
      if(urls) {
        self.tilejson = urls;
        self.setUrl(self.tilejson.tiles[0]);
        // manage interaction
        self._reloadInteraction();
        self.ok && self.ok();
        done && done();
      } else {
        self.error && self.error(err);
        done && done();
      }
    });
  }
747551
function (tileset) {
            var i = 0;
            // first gid

            // tile properties (collidable, etc..)
            this.TileProperties = [];

            // hold reference to each tile image
            this.imageCollection = [];

            this.firstgid = this.lastgid = +tileset.firstgid;

            // check if an external tileset is defined
            if (typeof(tileset.source) !== "undefined") {
                var src = tileset.source;
                var ext = me.utils.file.getExtension(src);
                if (ext === "tsx" || ext === "json") {
                    // load the external tileset (TSX/JSON)
                    tileset = me.loader.getTMX(me.utils.file.getBasename(src));
                    if (!tileset) {
                        throw new Error(src + " external TSX/JSON tileset not found");
                    }
                }
            }

            this.name = tileset.name;
            this.tilewidth = +tileset.tilewidth;
            this.tileheight = +tileset.tileheight;
            this.spacing = +tileset.spacing || 0;
            this.margin = +tileset.margin || 0;

            // set tile offset properties (if any)
            this.tileoffset = new me.Vector2d();

            /**
             * Tileset contains animated tiles
             * @public
             * @type Boolean
             * @name me.TMXTileset#isAnimated
             */
            this.isAnimated = false;

            /**
             * true if the tileset is a "Collection of Image" Tileset
             * @public
             * @type Boolean
             * @name me.TMXTileset#isCollection
             */
            this.isCollection = false;

            /**
             * Tileset animations
             * @private
             * @type Map
             * @name me.TMXTileset#animations
             */
            this.animations = new Map();

            /**
             * Remember the last update timestamp to prevent too many animation updates
             * @private
             * @type Map
             * @name me.TMXTileset#_lastUpdate
             */
            this._lastUpdate = 0;

            var tiles = tileset.tiles;
            for (i in tiles) {
                if (tiles.hasOwnProperty(i)) {
                    if ("animation" in tiles[i]) {
                        this.isAnimated = true;
                        this.animations.set(+i + this.firstgid, {
                            dt      : 0,
                            idx     : 0,
                            frames  : tiles[i].animation,
                            cur     : tiles[i].animation[0]
                        });
                    }
                    // set tile properties, if any (XML format)
                    if ("properties" in tiles[i]) {
                        this.setTileProperty(+i + this.firstgid, tiles[i].properties);
                    }
                    if ("image" in tiles[i]) {
                        var image = me.loader.getImage(tiles[i].image);
                        if (!image) {
                            throw new Error("melonJS: '" + tiles[i].image + "' file for tile '" + (+i + this.firstgid) + "' not found!");
                        }
                        this.imageCollection[+i + this.firstgid] = image;
                    }
                }
            }

            this.isCollection = this.imageCollection.length > 0;

            var offset = tileset.tileoffset;
            if (offset) {
                this.tileoffset.x = +offset.x;
                this.tileoffset.y = +offset.y;
            }

            // set tile properties, if any (JSON format)
            var tileInfo = tileset.tileproperties;
            if (tileInfo) {
                for (i in tileInfo) {
                    if (tileInfo.hasOwnProperty(i)) {
                        this.setTileProperty(+i + this.firstgid, tileInfo[i]);
                    }
                }
            }

            // if not a tile image collection
            if (this.isCollection === false) {

                // get the global tileset texture
                this.image = me.loader.getImage(tileset.image);

                if (!this.image) {
                    throw new Error("melonJS: '" + tileset.image + "' file for tileset '" + this.name + "' not found!");
                }

                // create a texture atlas for the given tileset
                this.texture = me.video.renderer.cache.get(this.image, {
                    framewidth : this.tilewidth,
                    frameheight : this.tileheight,
                    margin : this.margin,
                    spacing : this.spacing
                });
                this.atlas = this.texture.getAtlas();

                // calculate the number of tiles per horizontal line
                var hTileCount = +tileset.columns || ~~(this.image.width / (this.tilewidth + this.spacing));
                var vTileCount = ~~(this.image.height / (this.tileheight + this.spacing));
                // compute the last gid value in the tileset
                this.lastgid = this.firstgid + (((hTileCount * vTileCount) - 1) || 0);
                if (tileset.tilecount && this.lastgid - this.firstgid + 1 !== +tileset.tilecount) {
                    console.warn(
                        "Computed tilecount (" + (this.lastgid - this.firstgid + 1) +
                        ") does not match expected tilecount (" + tileset.tilecount + ")"
                    );
                }
            }
        }
262297
private static Collection<TileRef> getTiles(Map<Transition, Collection<TileRef>> transitions, Transition transition)
    {
        if (!transitions.containsKey(transition))
        {
            transitions.put(transition, new HashSet<TileRef>());
        }
        return transitions.get(transition);
    }
1174404
def _parse_tile_part_bit_stream(self, fptr, sod_marker, tile_length):
        """"""
        read_buffer = fptr.read(tile_length)
        # The tile length could possibly be too large and extend past
        # the end of file.  We need to be a bit resilient.
        count = min(tile_length, len(read_buffer))
        packet = np.frombuffer(read_buffer, dtype=np.uint8, count=count)

        indices = np.where(packet == 0xff)
        for idx in indices[0]:
            try:
                if packet[idx + 1] == 0x91 and (idx < (len(packet) - 5)):
                    offset = sod_marker.offset + 2 + idx
                    length = 4
                    nsop = packet[(idx + 4):(idx + 6)].view('uint16')[0]
                    if sys.byteorder == 'little':
                        nsop = nsop.byteswap()
                    segment = SOPsegment(nsop, length, offset)
                    self.segment.append(segment)
                elif packet[idx + 1] == 0x92:
                    offset = sod_marker.offset + 2 + idx
                    length = 0
                    segment = EPHsegment(length, offset)
                    self.segment.append(segment)
            except IndexError:
                continue
602386
function(options) {
        OpenLayers.Util.extend(this, options);
        this.maps = [];
        this.tileQueueId = {};
        this.tileQueue = {};
        this.tileCache = {};
        this.tileCacheIndex = [];
    }