LevelAnimated
LevelAnimated MapIndex, LevelIndex
 
Parameters:

    MapIndex = The Index of the Map you wish to set a levels render mode
    LevelIndex = The index of the level you wish to set to Animated
Returns: NONE
 
LevelAnimated sets a levels rendering mode to Animated.

When set to animated mode, any tiles within the level with their Hi Hit set (bit 31, or in Hex $8000000) will be treated as animations, rather than block indexes. So the DrawMap command will draw this animation sequences current frame, rather than a normal block.



FACTS:


* Animation mode can be combined with Solid or Transparent mode.




Mini Tutorial:

This example builds a map structure, some block graphics as well as a block animation and level. It then displays this animated level at the mouse pointers position.

  
; Set Width & Height variables of the Map tiles
  TileWidth=16
  Tileheight=16
  
; Get a free Map index
  MyMap=GetFreeMap()
  
; Create a map with provision for 5 levels
  CreateMap MyMap,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
  
; Get the levels width and height
  w=GetLevelWidth(mymap,1)
  h=GetLevelHeight(mymap,1)
  
  
; 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,w,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,h,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: CreateLevel | CreateMap | CreateMapAnim | DrawMap | LevelSolid | LevelTransparent :
 


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