> how-to's > how to display a game mapDo you want to display a game map on your screen? For example, you plan a game like Soko92, a civilization clone, or whatever. Only problem is that you need a powerful map display function. Ok, we'll explain to you, how to display it, fast!
* A spritetable (SPRMAKER, or our SpriteEditor from Wizard).
* A PutSprite routine (also availabel in one of these packages)
* A map ;-)
So first of all, we need a defined mapsize. The routine gets the mapsizes (X_SIZE, Y_SIZE) in the registers d0, d1. Then we need two relative coordinates (relative_x, relative_y) in d2, d3. Then the number of sprites in one y and x line in a predefined constant called SPRITES_PER_X_LINE, SPRITES_PER_Y_LINE. The routine will display the map in the upper left corner. Last but not least the routine needs a pointer to the map
Notice: The routine doesn't check the relative coordinates
The spritesize will be 16x16
So, now we define a pseudo code
MAP_ADDRESS = MAP_POINTER + X_SIZE * RELATIVE_Y + RELATIVE_X
CURRENT_X = CURRENT_Y = 0 Needed for the putsprite routine
CURRENT_SPRITE = *MAP_ADDRESS
Draw the sprite
CURRENT_X = CURRENT_X + 16
WHILE NOT SPRITES_PER_Y_LINE ARE DRAWN
MAP_ADDRESS = MAP_ADDRESS + X_SIZE - SPRITES_PER_XLINE
CURRENT_Y = CURRENT_Y + 16
CURRENT_X = 0
WHILE NOT SPRITES_PER_X_LINE ARE DRAWN
The parameters of the putsprite routine are explained later!
So this is our pseudocode, and now we need the 68k routine.
so this is one of an important routine for a game, we hope it'll help you.
powered by ticalc.org,
last update on 12.12.1999