AMOS code, simple tile-based level routine for a game
Posted 05-10-2011 at 03:52 PM by Damiga
Ok so first is a procedure that contains the actual level data, for now it's just numbers that refers to what bob to paste, 1=wood or something that the player can't move into, 2=a safe location like a town, 3=road, 4=enemy
Procedure SHIREMAP
For Y=1 To MAPHEIGHT
For X=1 To MAPWIDTH
Read MAPLOCATION(X,Y)
Data 3,3,3,1,1,3,3,3,3,4
Data 1,1,3,1,1,3,1,1,1,2
Data 1,1,2,3,3,3,3,1,1,1
Data 1,1,1,1,1,1,3,1,1,1
Data 1,1,1,1,1,1,3,3,3,5
Data 1,1,1,1,1,1,1,1,1,1
Next X
Next Y
End Proc
Next procedure puts the level on screen, every tile is 16x16 pixels.
Procedure DISPLAYMAP
Screen 1
For Y=1 To MAPHEIGHT
For X=1 To MAPWIDTH
Paste Bob X*16,Y*16,MAPLOCATION(X,Y)
Next X
Next Y
End Proc
Very simple, but I aim to add more features, another array similar to MAPLOCATION that can contain events, items etc.
Procedure SHIREMAP
For Y=1 To MAPHEIGHT
For X=1 To MAPWIDTH
Read MAPLOCATION(X,Y)
Data 3,3,3,1,1,3,3,3,3,4
Data 1,1,3,1,1,3,1,1,1,2
Data 1,1,2,3,3,3,3,1,1,1
Data 1,1,1,1,1,1,3,1,1,1
Data 1,1,1,1,1,1,3,3,3,5
Data 1,1,1,1,1,1,1,1,1,1
Next X
Next Y
End Proc
Next procedure puts the level on screen, every tile is 16x16 pixels.
Procedure DISPLAYMAP
Screen 1
For Y=1 To MAPHEIGHT
For X=1 To MAPWIDTH
Paste Bob X*16,Y*16,MAPLOCATION(X,Y)
Next X
Next Y
End Proc
Very simple, but I aim to add more features, another array similar to MAPLOCATION that can contain events, items etc.
Total Comments 1
Comments
-
Some tips: Change the Paste Bob command to Paste Icon and it will go faster since it doesn't need to mask the blit.
Also, storing as data statements uses 4 bytes per cell. Since an Icon Bank can only hold 4096 images maximum, you'll only need 2 bytes per cell and still have 4 bits left over for flags. If you use Deek and Doke to read addresses from a work bank, it will use half the memory and be twice as fast on 16-bit Amigas.
For an example of how to load a file into a work bank see the last example in this thread. It uses a Print$ command to print it as text but you can replace it with your tile printing loop.Posted 05-10-2011 at 06:30 PM by SamuraiCrow







