Tile Editor concept by Draglan22nd Jan 2012 14:51
|
---|
Summary Allows you to choose a color, place tiles, and clear the screen. Then you can either load your map back onto the screen or delete it entirely. Description Place tiles by clicking the screen. Choose a color by pressing 1, 2, 3, or 0. Delete a tile by right-clicking on the screen. Clear the screen by pressing the space key. Re-load your map by pressing the upkey or delete your map by pressing the downkey. Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com // create our map array dim WorldMap(screen width()/10, screen height()/10) // main loop do // divide the screen into 10x10 segments for x=0 to screen width()/10 for y=0 to screen height()/10 mx#=mousex() : my#=mousey() : mc=mouseclick() x1#=x*10 y1#=y*10 x2#=(x*10)+10 y2#=(y*10)+10 // check to see if the user clicks; if so, place a box at the grid location // they clicked on and enter the corresponding data into the map array if mc=1 if mx#>x1# and my#>y1# and mx#<x2# and my#<y2# and c=1 box x1#, y1#, x2#, y2# WorldMap(x, y)=1 else if mx#>x1# and my#>y1# and mx#<x2# and my#<y2# and c=2 box x1#, y1#, x2#, y2# WorldMap(x, y)=2 else if mx#>x1# and my#>y1# and mx#<x2# and my#<y2# and c=3 box x1#, y1#, x2#, y2# WorldMap(x, y)=3 else if mx#>x1# and my#>y1# and mx#<x2# and my#<y2# and c=0 box x1#, y1#, x2#, y2# WorldMap(x, y)=4 endif endif endif endif endif // check to see if the user right-clicks; if so, delete the box and delete // the corresponding data from the map array if mc=2 if mx#>x1# and my#>y1# and mx#<x2# and my#<y2# box x1#, y1#, x2#, y2#, rgb(0, 0, 0), rgb(0, 0, 0), rgb(0, 0, 0), rgb(0, 0, 0) WorldMap(x, y)=0 endif endif next y next x // clearing the screen and choosing color if spacekey()=1 then cls if inkey$()="1" ink rgb(255, 0, 0), 0 c=1 else if inkey$()="2" ink rgb(0, 255, 0), 0 c=2 else if inkey$()="3" ink rgb(0, 0, 255), 0 c=3 else if inkey$()="0" ink rgb(255, 255, 255), 0 c=0 endif endif endif endif // loading and deleting map data if upkey()=1 then LoadMap() if downkey()=1 then DeleteMap() loop end // load map function function LoadMap() for x=0 to screen width()/10 for y=0 to screen height()/10 if WorldMap(x, y)=1 ink rgb(255, 0, 0),0 x1#=x*10 y1#=y*10 x2#=(x*10)+10 y2#=(y*10)+10 box x1#, y1#, x2#, y2# else if WorldMap(x, y)=2 ink rgb(0, 255, 0),0 x1#=x*10 y1#=y*10 x2#=(x*10)+10 y2#=(y*10)+10 box x1#, y1#, x2#, y2# else if WorldMap(x, y)=3 ink rgb(0, 0, 255),0 x1#=x*10 y1#=y*10 x2#=(x*10)+10 y2#=(y*10)+10 box x1#, y1#, x2#, y2# else if WorldMap(x, y)=4 ink rgb(255, 255, 255),0 x1#=x*10 y1#=y*10 x2#=(x*10)+10 y2#=(y*10)+10 box x1#, y1#, x2#, y2# endif endif endif endif next y next x endfunction // delete map function function DeleteMap() cls for x=0 to screen width()/10 for y=0 to screen height()/10 WorldMap(x, y)=0 next y next x endfunction |