MapAnimQuantity
MapAnimQuantity MapIndex, NumbOfAnims
 
Parameters:

    MapIndex = The Index Identifier of the Map that you wish to create.
    NumbOfAnims = The Number of levels you like to setup within this map
Returns: NONE
 

      MapAnimQuantity lets you expand or contract the number of Block Animations a map currently has provision for. The command is sensitive to the any existing data, allowing you to expand the block animations table without lose. Of course, if you shrink the table, then care should be taken to ensure your not deleting Animations you need.


      [ What Are Block Animations ? ]

      Block animations are basically arrays of blocks. These arrays, collections can contain arrange in any sequence of block indexes you wish. To use them in a level, we poke the animation index into the level. Once a tile in the level is set to animation rather than just a normal block index, the DrawMap command will automatically calculate that block to be display from this animation sequence.

      Animations are updated using the UpdateMapAnims command. This command will update all the map animations that current active at once. This ensure they stay in perfect synchronization with each other. It should be noted though that animations are only valid for the map their attached too.




FACTS:


      * When shrinking the number of tile animations, MapAnimQuantity will delete all the tile animation data associated with those removed animations.



Mini Tutorial:


      This example will create a map with provision for 10 levels and 50 animations. It builds one animation and level and the displays this elvel at the mouses position.

  
; Set Width & Height variables of the Map tiles
  TileWidth=16
  Tileheight=16
  
; Create a map with provision for 5 levels
  MyMap=NewMap(5)
  
; Create some empty graphics blocks for MyMAP
  CreateMapGFX MyMap,TileWidth,TileHeight,10,RGB(0,0,0)
  
  For lp=1 To 10
   ; draw a randomly coloured box
     BoxC 0,0,TileWidth-1,TileHeight-1,1,RndRGB()
   ; Copy the box image into MyMap
     GetMapBlk MyMap, lp, 0,0
  Next
  
  
; Create Room for 50 Block Animations with this map
  MapAnimQuantity MyMap,50
  
; Create ANim 15.. with space for 10 frames in the anim
  CreateMapAnim MyMap,15,10
  
; Poke some random  frames into the Anim 15
  For lp=0 To 10
     PokeMapAnim MyMap,15,lp,Rnd(10)
  Next
  
  
; Create level 1
  CreateLevel MyMap,1,20,20
  
; Enable Animation for this level
  LevelAnimated MyMap,1
  
  
; Randomly Fill the level with Tiles
  For Ylp=0 To GetLevelWidth(myMap,1)
     For Xlp=0 To GetLevelWidth(myMap,1)
        PokeLevelTile MyMap,1,Xlp,Ylp,RndRange(1,10)
     Next
  Next
  
  
; Fill The Top/Bottom Edges of the level with our ANIM #15
  For Ylp=0 To GetLevelHeight(myMap,1)
     PokeLevelTile MyMap,1,0,Ylp,15+$80000000
     PokeLevelTile MyMap,1,GetLevelWidth(mymap,1),Ylp,15+$80000000
  Next
  
; Fill The Top/Bottom Edges of the level with our ANIM #15
  For xlp=0 To GetLevelWidth(myMap,1)
     PokeLevelTile MyMap,1,xlp,0,15+$80000000
     PokeLevelTile MyMap,1,xlp,GetLevelHeight(mymap,1),15+$80000000
  Next
  
  
; Start of Do/Loop
  Do
   ; clear the screen to black
     Cls RGB(30,50,20)
     
     
   ; Draw Level #1 of MyMap to the screen at mouses position
     DrawMap MyMap,1,MouseX(),MouseY()
     
     
   ; Update the Map animations
     UpdateMapAnims MyMap
     
   ; Display a Message
     Print "Animated Map Example"
     
   ; Display the screen and loop back to the DO
     Sync
  Loop
  
  



This example would output.

  
  no Text Output
  

 
Related Info: CreateMap | CreateMapAnim | GetMapAnimSize | GetMapAnimStatus | GetMapAnimType | UpdateMapAnims :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com