Open Map Viewport
Creates a viewport and a canvas from a map. Syntax
Open Map Viewport canvas,mapLayer,x1,y1 to x2,y2 Description
This command opens a tile scrolling canvas with the effective size of the total map, but an actual size of only just a little larger than the viewport. This means that as far as you are concerned you have a large canvas to scroll around, however, in terms of memory it only opens a small canvas. The map used is the currently loaded map. If the canvas is open, it is closed and reopened to be just larger than the viewport size. This canvas is managed by the viewport, you can draw on the canvas yourself, but your changes will just be erased whenever you scroll enough for the map to be redrawn. If you change the tiles on the map with the 'set map tile' command then the tiles will be updated in the viewport. If you change the currently loaded map then the viewport will redraw with the new map. Tile Scrolling When doing tile scrolling, you open a canvas just a little larger than the viewport and then scroll only by a few pixels before resetting the scroll back to zero and redrawing the map tiles 1 tile over. This allows a huge map to be scrolled without having to open a canvas as big as the map. Using a map viewport is a lot easier than doing tile scrolling yourself, TNT Basic takes care of all the map redrawing and scrolling offset for you, you just treat the canvas as a huge canvas the size of the map. You can position your sprites anywhere on the map without having to worry about doing the same coordinate transforms you'd have to perform if doing manual tile scrolling. The viewport can be removed from the display with the function Close Viewport and scrolled using Set Viewport Offset.
Table of contents