PokeLevelTile
PokeLevelTile MapIndex, LevelIndex, TileXpos, TileYpos, BlockIndex
 
Parameters:

    MapIndex = The Index Identifier of the Map you wish to poke this level in.
    LevelIndex = The index of the level you wish to write to.
    TileXpos = The X coordinate in the level map
    TileYpos = The Y coordinate in the level map
    BlockIndex = The Index of the Block Gfx that you wish to place at this X & Y position
Returns: NONE
 

      The PokelevelTile() function will store either Tiles Index or Animation Index directly into a level array.


      Animation Note: When PlayBASIC draws a level, it distinguishes between normal block and animation indexes tiles by performing a Bit TEST on value. Normal block indexes should be stored as positives values (from 0 to the number of blocks this map has). To store an Animation index, the index needs to be OR'd with the PBMapAnim_Mask constant. This will appropriately tag this value as animation index, rather than a block index.



I.e. Poking an animation index into a level.

  
  PokeLevelTile MyMap,MyLevel,TileXpos,TileYpos, MyAnimationIndex Or pbmapanim_mask
  





FACTS:


      * Levels can not be drawn until the maps graphics tiles have been loaded/created.

      * The TileXpos parameter is in TILES not pixels.

      * The TileYpos parameter is in TILES not pixels.

      * Animation indexes require the High Bit the set. To set it, we Or the Animation Index with the PBMapAnim_Mask constant. Eg PokeLevelTile THisMap,ThisLevel,X,Y, AnimIndex or PBMapAnim_Mask





Mini Tutorial:


      This example creates a map with tile graphics and a level map the size opf the display. The user can draw tiles onto the blank map by Poking them withthe mouse.


  
; Set Width & Height variables of the Map tiles
  TileWidth=32
  Tileheight=32
  
; Create a map with provision for 5 levels
  MyMap=NewMap(5)
  
; Create some empty graphics blocks for MyMAP
  CreateMapGFX MyMap,TileWidth,TileHeight,2,RGB(0,0,0)
  
; draw a Green Box
  BoxC 0,0,TileWidth,TileHeight,1,RGB(0,255,0)
  
; Copy the green box to MyMap as Tile #1
  GetMapBlk MyMap, 10,0
  
; Create level 1
  CreateLevel MyMap,1,100,100
  
  
; Start of Do/Loop
  Do
   ; clear the screen to black
     Cls RGB(0,0,0)
     
   ; Calculate the Tile coords the mouse is currently over
     TileX=MouseX()/TileWidth
     TileY=MouseY()/TileHeight
     
   ;  Check if the mouse button is pressed then
   ; poke this Tile with a Tile #1..
     If MouseButton()
        PokeLevelTile MyMap,1,TileX,TileY,1
     EndIf
     
     
   ; Draw Level #1 of MyMap to the screen at xpos 0, Ypos 0
     DrawMap MyMap,1,0,0
     
     
   ; Read This Tile Back.
     Print "Press Mouse Button to Draw Tile"
     Print "Current Tile Number Under Mouse:"+Str$(PeekLevelTile(MyMap,1,TileX,TileY))
     
     
   ; Display the screen and loop back to the DO
     Sync
  Loop
  
  



This example would output.

  
  no Text output.
  

 
Related Info: LevelAnimated | LevelDrawMode | LevelSolid | LevelTransparent | LevelTransparentTile | Maps | PBMapAnim_Mask | PeekLevelTile :
 


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