PasteLevel
PasteLevel SrcMapIndex, SrcLevelIndex, DestMapIndex, DestLevelIndex, DestX, DestY, TransparentBlock
 
Parameters:

    SrcMapIndex = The Index of the Src Map you wish to paste level data from
    SrcLevelIndex = The source index of the level you wish to paste
    DestMapIndex = The Index of the Map you wish to paste level data to
    DestLevelIndex = The destination index of the level you wish to paste to.
    DestX = The Dest X (top left) coord in the dest level map
    DestY = The Dest Y (top left) coord in the dest level map
    TransparentBlock = The block index you wish exclude.
Returns: NONE
 

      PasteLevel will copy/paste level tile data onto another level. The copy will paste the source level much like as if it was a sprite.

      Mode Values:

           0 = Copy as is
           1 = Transparent Copy



FACTS:


      * The pasted region will be automatically clipped to the destination levels size.



Mini Tutorial:


      This example shows how to first create a Map & Level. Then while displaying the the level the mouse position (much like a sprite) it uses PasteLevel to copy the source level data onto another level and display with.

  
; 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 9
   ; 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 level 1 within MyMap
  CreateLevel MyMap,1,20,20
  
; Create level 2 within MyMap
  CreateLevel MyMap,2,32,25
  
  xdir=1
  ydir=1
  
; Start of Do/Loop
  Do
     
   ; Clear the screen
     Cls RGB(30,50,20)
     
   ; Fill the Copy corner of this level with
   ; random tiles
     For ylp =0 To GetLevelHeight(MyMap,1)
        For xlp =0 To GetLevelWidth(MyMap,1)
           PokeLevelTile MyMap,1,xlp,ylp,Rnd(9)
        Next
     Next
     
   ; Clear Level #2
     ClearLevel Mymap,2,0
     
   ; Paste the Tiles data from level #1 onto level 2
     PasteLevel MyMap,1,MyMap,2,Xpos,ypos,0
     
   ; update the paste position for the pasted level
     xpos+=xdir
     ypos+=ydir
     
   ; rebound the movement directions if their out of bounds
     If xpos<0 Or xpos>GetLevelWidth(MyMap,2Then Xdir=-xdir
     If ypos<0 Or ypos>GetLevelHeight(MyMap,2Then Ydir=-Ydir
     
     
   ; Draw Level #1 of MyMap to the screen at mouses position
     DrawMap MyMap,1,MouseX(),MouseY()
     
   ; Draw Level #2 of MyMap to 100x,100y
     DrawMap MyMap,2,100,100
     
     
   ; Display a Message
     Print "Paste Level Example"
     
   ; Display the screen and loop back to the DO
     Sync
     
  Loop
  
  
  
  


This example would output.

  
  no Text Output
  

 
Related Info: ClearLevel | CloneLevel | CopyLevel | CreateLevel | FillLevel | PeekLevelTile | PokeLevelTile | ResizeLevel :
 


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