View Single Post
Old 12-01-2004, 02:13 PM
Iceplug's Avatar
Iceplug Iceplug is offline

Retired Moderator
* Guru *
Join Date: Aug 2001
Location: Iowa, USA
Posts: 16,583
Lightbulb Quick example of a Tile Map

(And history repeats itself)

Anyway, I have attached an example of a tile map (this seems to be question of the month).

Note how the map is set up as a two-dimensional array of integers,
there is a bitmap for the tilesets, and the
GFX object draws onto the Backup bitmap object.

Backup = New Bitmap(304, 304)
'Backup will be initialzed to an empty bitmap
(There's no significance to the 304 in the example, either...
but it has to be large enough to accommodate the map.)

The map is drawn like:
        For LY = 0 To 7
            For LX = 0 To 7

                Thisindex = Map(LX, LY)
                'Get the index from the map.

                Tile = New Rectangle(Thisindex * Tilesize, 0, Tilesize, Tilesize)
                'Get the rectangle defining the tile.

                GFX.DrawImage(Tileset, LX * Tilesize, LY * Tilesize, Tile, GraphicsUnit.Pixel)
                'And then draw the tile onto the backup.

And the project (in .NET 2003), although you only need the .vb file and the pictures, and you can make a new project in .NET 2002 that does the same.
Attached Files
File Type: zip (15.9 KB, 417 views)

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote