; ----------------------------------------------------- ; --------->> SET UP <<------------ ; ----------------------------------------------------- SetFPS 75 ; create the random map from some circles Map,Level=Build_Random_Map(32,32) ; make a backdrop picture BackDrop=NewImage(800,600) RenderToImage Backdrop c1=RndRGB() c2=RndRGB() ShadeBox 0,0,800,600,c1,c1,c2,c2 RenderToScreen ; ----------------------------------------------------- ; --------->> MAIN LOOP OF PROGRAM <<------------ ; ----------------------------------------------------- Do ; set the capture depth of the next item to a depth of ; 100 units DrawImage BackDrop,0,0,false ; draw the map level DrawMap map,Level,0,0 ; check if the SPACE key was pressed If SpaceKey() ; If so, toggle Debug mode on the map MapDebug Map,1-GetMapDebug(Map) FlushKeys EndIf SetCursor 0,0 Ink $ffffff Print "Space to Toggle Debug Mode" Sync Loop ; ----------------------------------------------------- ; ------------->> Build Random Map Scene <<------------ ; ----------------------------------------------------- Function Build_Random_Map(BlockWidth,BlockHeight) BackdropColour=$008f00 screen=NewFXImage(2400,1600) RenderToImage screen Cls BackdropColour CircleC 800,400,400,true,$8f8f8f CircleC 1700,400,400,true,$0f8faf For lp=0 To 150 EllipseC Rnd(2400),Rnd(1600),RndRange(50,150),RndRange(10,50),true, BackdropColour Next Map=NewMap(50) ; Create 1024 FX BLocks for this map CreateMapGFX Map,BlockWidth,BlockHeight,1024,BackdropColour,2 BlocksX=GetSurfaceWidth()/BlockWidth BlocksY=GetSurfaceHeight()/BlockWidth Level=NewLevel(Map,BlocksX,BlocksY) LevelTransparent Map,Level,0 GetMapBlk Map,Tile,0,0 Tile=1 For ylp=0 To GetLevelHeight(map,level)-1 Ypos=ylp*BlockHeight If Ypos+BlockHeight<=GetSurfaceHeight() For xlp=0 To GetLevelWidth(map,level)-1 Xpos=xlp*BlockWidth GetMapBlk Map,Tile,Xpos,ypos If GetMapBlockTransparent(Map,Tile)>-1 PokeLevelTile Map,Level,xlp,ylp,tile tile++ EndIf If Tile=>GetMapBlocks(Map) Then ExitFor ylp Next EndIf Next RenderToScreen ;Turn Debug Mode On MapDebug Map,on EndFunction Map,Level |