|  | 
 
 Tiles are basically small images that you have created and stored in a graphics file, and can use them to create all manor of graphic situations. These take up less space, as you're not using a full sized bitmap for every background in your game. Tilemaps are an essential part of any game, be it a background for the game, the ground the player walks on, a scrolling background/playfield, the bricks for your breakout game, etc. The uses are endless. 
 Firstly you will need to create your tile set in a paint package. It's always a good idea to leave the first tile blank; this makes it easier for deleting tiles and displaying the map without a pictured background. I would then save them to a sub folder for your game called gfx, just so it makes it easier to have all of your graphics for that particular game in one place/folder. I have created one for you for this tutorial. 
 I tend to use tiles of 32x32 but it's up to you what sizes you prefer to design. 
So say you want to design 10 tiles, which are 32 pixels across & 32 pixels down.
 Next you will need to breakdown the graphics file into the appropriate sizes. Going by the above example: You know you've got 10 tiles (frames) in your tileset, and that they are 32 by 32.To load them, and use them in our editor. Our first bit of code would be: 
 The above code sets the screen resolution to 640 by 480. Then using a global variable to tell blitz to load the tileset each time it's called, and lastly makes all the drawing to the screen invisible until we tell it to Flip the screen to the front. 
 We now need to work out how many tiles can fit across and down the screen, with the sizes of the tiles and the resolution of the screen. 
So that would be:
 So now we can create a function to draw the entire map, with the correct sizes. This also tells us where to stop the cursor from going out of bounds off the screen, so we don't get errors such as, illegal memory errors and crashes. So adding to the code. We can define our map size using a DIM variable to store the data. So underneath the GLOBALS we can add: 
 This tells blitz that the map size is 20 tiles across (x) and 15 tiles down (y) The routine (function) to display the map would be. Not forgetting that the map to start with will be blank, until later on we start adding tiles to it. In the global section at the top of the code we need to add some more variables. So type in the following variables: 
 These variables will be used to draw the tiles apart from each other, in the correct positions. 
 What this does is by using FOR Y=0 to 15 and FOR X=0 to 20, this will only draw the tiles we need down the screen and will only draw the correct amount across the screen. By using IF MAP(X,Y)<=10 AND MAP(X,Y)>0. This tells the routine to only draw if the tile is it's between 0 and 10. And is to make sure it doesn't display anything else. We are next telling blitz that we should draw the tiles at the right postions,in increments of 32, by using this simple bit of maths. GX=X*32 and GY=Y*32, (e.g. if x equals 3 and y equals 2, then we would draw at position 96,64, and not at position 3,2). The final bit of code draws the tiles on the screen at the corresponding locations, and the correct image: DRAWIMAGE GRAPHICSFILE,GX,GY,MAP(X,Y). Then it goes through displaying all of the tiles, before ending the routine. 
 I'm now going to speed things up a little by giving you the entire functions and routines, the globals to add, and a description of what's happening. As im sure you'll be wanting to code the editor and start creating maps. Underneath the command SETBUFFER BACKBUFFER(), if you were to add the following lines of code. This is for our program loop which tells Blitz to use our routines/functions, and if we were to press Escape then the program will end. 
 
 
 
 
 These are for flashing the cursor box: 
 
 Now if you type in the following function below the updatemap function. I'll then tell you what it does. 
 
 
 |