CopyLevel
CopyLevel SrcMapIndex, SrcLevelIndex, X1, Y1, X2, Y2, DestMapIndex, DestLevelIndex, DestX, DestY
 
Parameters:

    SrcMapIndex = The Index of the Src Map you wish to copy level data from
    SrcLevelIndex = The source index of the level you wish to copy from.
    X1 = The Starting X (top left) coord in the level map
    Y1 = The Starting Y (top left) coord in the level map
    X2 = The Ending X (bottom right) coord in the level map
    Y2 = The Ending Y (bottom right) coord in the level map
    DestMapIndex = The Index of the Map you wish to copy the level data to
    DestLevelIndex = The destination index of the level you wish to copy 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
Returns: NONE
 

      CopyLevel copies a rectangular portion of the source level to another level.



FACTS:


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

      * CopyLevel does not support coping of overlapping regions (within the same level)



Mini Tutorial:


      This example shows how to first create a Map and Level. Then while displaying the the level the mouse position (much like a sprite) it uses CopyLevel to transfer the top left section of the level to the bottom right section of the level.


  
  
; 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
  CreateLevel MyMap,1,20,20
  
; 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 9
        For xlp =0 To 9
           PokeLevelTile MyMap,1,xlp,ylp,Rnd(9)
        Next
     Next
     
   ; Copy the top left hand portion of the level
   ; To the bottom right hand corner of the level
     CopyLevel MyMap,1,0,0,10,10,MyMap,1,11,11
     
     
     PokeLevelTile MyMap,1,0,0,Rnd(9)
     
   ; Draw Level #1 of MyMap to the screen at mouses position
     DrawMap MyMap,1,MouseX(),MouseY()
     
   ; Display a Message
     Print "Copy Level Example"
     
   ; Display the screen and loop back to the DO
     Sync
  Loop
  
  
  


This example would output.

  
  no Text Output
  

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


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