GetLevelTile
BlockIndex = GetLevelTile(MapIndex, LevelIndex, Xpos, Ypos)
 
Parameters:

    MapIndex = The index of the map you wish to query a level within
    LevelIndex = The index of the level you wish to check
    Xpos = The X position (in pixels) of where to check
    Ypos = The Y position (in pixels) of where to check
Returns:

    BlockIndex = The index of the block that is under this point
 

The GetLevelTile function returns the Block or Animation Index from a level that a point is over. The test points position is in pixels, not tiles.



FACTS:


* GetLevelTile expects the point your checking to be in the levels space. If not, it'll return a illegal tile index runtime error.




Mini Tutorial:


This example creates an map and level, then uses the GetLevelTile to detect what block index is under the mouse pointer.


  
  
; Get a free Map index
  MyMap=GetFreeMap()
  
; Create a map with provision for 5 levels
  CreateMap MyMap,1
  
; Create some coloured blocks for this map
  CreateMapGFX MyMap,25,25,10,RGB(0,0,0)
  For lp=1 To GetMapBlocks(MyMap)
     BoxC 0,0,30,30,1,RndRGB()
     GetMapBlk MyMap,lp,0,0
  Next
  
; Request a free level index from this map
  MyLevel=GetFreeMapLevel(MyMap)
  
; create the level
  CreateLevel Mymap,MyLevel, 25,20
  
  w=GetLevelWidth(MyMap,MyLevel)
  h=GetLevelHeight(MyMap,MyLevel)
  
; Fill the Level edges with blocks
  For Ylp=0 To GetLevelHeight(MyMap,mylevel)
     For Xlp=0 To GetLevelWidth(MyMap,mylevel)
        PokeLevelTile Mymap,MyLevel,xlp,ylp,Rnd(GetMapBlocks(myMap))
     Next
  Next
  
  
; Start a Do / Loop
  Do
   ; Clear the screen
     Cls RGB(0,0,0)
     
   ; Draw the map to the screen
     DrawMap MyMap,MyLevel,0,0
     
   ; The levels absoluet Width/Height in pixels
     w=GetLevelABSWidth(mymap,mylevel)
     h=GetLevelABSHeight(mymap,mylevel)
     
   ; Check if the mouse is over the level
     If MouseInBox(0,0,w,h)
      ; get the tile the ouse is over
        Block=GetLevelTile(MyMap,MyLevel,MouseX(),MouseY())
     Else
        Block=-1
     EndIf
     
   ; Display what block the mouse is over, if any
     If BLock=-1
        Print "Mouse Not Over LEvel"
     Else
        Print "Move Over Block:"+Str$(block)
     EndIf
     
   ; Display the screen
     Sync
   ; Loop back to the do statement
  Loop
  
  




This example would output.

  
  no Text Output
  

 
Related Info: GetLevelABSHeight | GetLevelABSWidth | GetMapBlockHeight | GetMapBlockWidth | PeekLevelTile :
 


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