AMOS TOME Series IV Manual  Index Prev Page Next Page 10

First Steps 3, What am I standing on ?

Being able to scroll around a map is quite handy, but is not much use in a game if you can't check to see what the player is standing on, bumping into, about to be blown up by, and so on !

TOME has a comprehensive set of functions to allow you to check tiles in the map, so that you can find out what the player is standing on, where the nearest ultra splatto blitzem bonus is, or whatever.

The easiest one to understand is called =Map Tile(x,y) and returns the tile number at co-ordinate x,y on the map (x & y are of course measured in tiles).

Try the following...

Print Map Tile(0,0)
Print Map Tile(2,3)
Print Map Tile(105,94)

Oops! the last one returned an error ! This is because the Map Tile function only allows you to check within the map itself. As this map is only 100x100 tiles in size, trying to check the tile at 105,94 is impossible, so TOME told us so !

"So hang on a minute !", you are now thinking to yourself; "how am I supposed to know what size the map is ?". Good question ! Fortunately, there is a good answer. There are two functions in TOME called =Map X and =Map Y, these return the size of the map in tiles, logically, =Map X returns the width, and =Map Y the height. So if your game is going to load in maps of different sizes, you can use the Max and Min functions to make sure that your map co-ordinates don't go off the map !

TX=Max(0,Min(MapX-1,X))
TY=Max(0,Min(MapY-1,Y))
Print
Map Tile(TX,TY)

now whatever values you put into X & Y you can't force an error !

Alternatively, the =Range function serves the same purpose as the Max & Min commands. This function is supplied as part of the Shuffle extension, and is used like this

TX=Range(X,0 To Map X-1 )

Basically, it forces the value of X into the range of 0 to Map X-1 ( If it is less than 0 it makes it 0, if it is greater than Map X-1 it makes it Map X-1). This function can be used with any set of parameters, not just map coordinates.