Accessibility

Table of Contents

Tile-Based Scrolling in Director

Practical Applications of Tile-Based Scrolling in Director

Handling tiles is no problem. You store them in a dedicated castlib. The most practical way to handle the 2D table array is to use a list of lists. Each list inside the list represents the columns, and each reference in each list represents each line. It's easy to get the value of the tile, which is on the seventh column and at the fifth line, as follows:

MyTile = LevelData[7][5]

You can then create the whole level this way:

on DrawLevel
 repeat with x = 1 to count(LevelData)
    repeat with y = 1 to count(LevelData[1])
      MyTile = LevelData[x][y]
      -- Imaging Lingo code to add the tile...
    end repeat
  end repeat
end 

Use Imaging Lingo for the real-time bitmap compositing, using the copypixels() function in particular. A good way to optimize tile copying is to store their image() data in a list. Accessing this list is much faster than accessing all that data, especially in a recursive fashion.

There are several ways to do the scrolling itself. Either store the whole level image in a variable, in which you crop a rect corresponding to the current point of view, or just draw lines and columns of tiles depending on the scrolling. See Noise Crime's sample (below) for an example.

Where to Go from Here

I hope this article helps you understand this technique better. Do not hesitate to let me know your thoughts and, above all, your achievements using this technique. Here are some useful links to accompany your developments.

Director-related articles:

General tile-related articles:

Don't forget the MAME (Multiple Arcade Machine Emulator) site—an inexhaustible source of inspiration!