3D Maze Maker by Webber12th Feb 2011 0:48
|
---|
Summary Massive 3D maze creator. It makes maze making easy. Description This program can make detailed 50 by 50 3D mazes using only the mouse. Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com `Project: 3D Maze Maker `Author: The Game Guy LV = 1 MazeMaker: `start of the maze maker set display mode 640,480,32 sync on : sync rate 100 : autocam off : set camera range 0,.1,100000 color backdrop RGB(100,133,153) : fog on : fog distance 500 : fog color RGB(100,133,153) show mouse : set text font "modern" : set text to bold : set text size 20 dim Wall(50,50) `Maze Data Array Wall(2,49) = 2 : Wall(49,2) = 3`Places a Start and End points Draw = 1 `starts with the wall drawing tool Rem Loads Level 1 if it exist Gosub Load_Level Rem Loop for creating the maze/mazes do MX# = Mousex() : MY# = Mousey() `Mouse position Variables MMZ# = MouseMoveZ() `Mouse Move Z Variable Rem Changes the tool when the user moves the z-axis on the mouse if MMZ# > 0 or mouseclick() = 2 then Draw = Draw + 1 while mouseclick() = 2 : endwhile if MMZ# < 0 then Draw = Draw - 1 if Draw > 3 then Draw = 0 if Draw < 0 then Draw = 3 Rem Creates the background for the maze maker ink RGB(0,96,96),0 : Box 120,40,528,448 : ink RGB(0,128,128),0 : Box 122,42,526,446 ink RGB(0,0,128),0 : Box 124,44,524,444 Rem Maze Maker Loops for y = 1 to 50 for x = 1 to 50 Rem Draws all of the boxes if Wall(x,y) = 1 ink RGB(128,128,128),0 : Box 116+(x*8),36+(y*8),124+(x*8),44+(y*8) endif if Wall(x,y) = 2 ink RGB(0,255,0),0 : Box 116+(x*8),36+(y*8),124+(x*8),44+(y*8) endif if Wall(x,y) = 3 ink RGB(255,0,0),0 : Box 116+(x*8),36+(y*8),124+(x*8),44+(y*8) endif Rem Change colors of boxes if Draw = 0 then ink RGB(0,0,128),0 if Draw = 1 then ink RGB(128,128,128),0 if Draw = 2 then ink RGB(0,255,0),0 if Draw = 3 then ink RGB(255,0,0),0 if MX# > 115+(x*8) and MX# < 124+(x*8) if MY# > 35+(y*8) and MY# < 44+(y*8) box 116+(x*8),36+(y*8),124+(x*8),44+(y*8) `locks the box to the grid near the mouse if Draw = 0 and Wall(x,y) <> 2 and Wall(x,y) <> 3 and mouseclick() = 1 then Wall(x,y) = 0 `eraser if Draw = 1 and Wall(x,y) <> 2 and Wall(x,y) <> 3 and mouseclick() = 1 then Wall(x,y) = 1 `boxs if Draw = 2 and mouseclick() = 1 and Wall(x,y) <> 3 `Positions the start point for y2 = 1 to 50 for x2 = 1 to 50 if Wall(x2,y2) = 2 then Wall(x2,y2) = 0 next x2 next y2 Wall(x,y) = 2 endif if Draw = 3 and mouseclick() = 1 and Wall(x,y) <> 2 `Positions the end point for y2 = 1 to 50 for x2 = 1 to 50 if Wall(x2,y2) = 3 then Wall(x2,y2) = 0 next x2 next y2 Wall(x,y) = 3 endif endif : endif next x next y Rem The Tool Button L = 1 if MX#>10 and MY#>10 and MX#<70 and MY#<70 L = 2 if mouseclick() = 1 then Draw = Draw + 1 while mouseclick() = 1 : endwhile endif ink RGB(0,96,96),0 : Box 6,6,74,74 ink RGB(0,128,128),0 : Box 8,8,72,72 if Draw = 0 : ink RGB(0,0,128/L),0 : Tex$ = "Eraser" : endif if Draw = 1 : ink RGB(128/L,128/L,128/L),0 : Tex$ = "Wall" : endif if Draw = 2 : ink RGB(0,254/L,0),0 : Tex$ = "Start" : endif if Draw = 3 : ink RGB(254/L,0,0),0 : Tex$ = "Exit" : endif Box 10,10,70,70 ink rgb(255,255,255),0 : center text 40,30,Tex$ Rem The Fill Button M = 1 if MX#>10 and MY#>90 and MX#<70 and MY#<116 M = 2 if mouseclick() = 1 and Draw <> 2 and Draw <> 3 for y = 1 to 50 for x = 1 to 50 if Draw = 0 and Wall(x,y) <> 2 and Wall(x,y) <> 3 then Wall(x,y) = 0 `eraser if Draw = 1 and Wall(x,y) <> 2 and Wall(x,y) <> 3 then Wall(x,y) = 1 `boxs next x next y endif while mouseclick() = 1 : endwhile endif ink RGB(0,96,96),0 : Box 6,86,74,120 : ink RGB(0,128,128),0 : Box 8,88,72,118 ink RGB(128/M,128/M,128/M),0 : Box 10,90,70,116 Rem The Save Button N = 1 if MX#>10 and MY#>140 and MX#<70 and MY#<166 N = 2 if mouseclick() = 1 Gosub Save `saves the new level CLS : ink rgb(255,255,255),0 set text size 72 : Center Text 320,180,"SAVEING" : set text size 20 : sync : sleep 500 endif while mouseclick() = 1 : endwhile endif ink RGB(0,96,96),0 : Box 6,126,74,160 : ink RGB(0,128,128),0 : Box 8,128,72,158 ink RGB(128/N,128/N,128/N),0 : Box 10,130,70,156 Rem The Level Button Left O = 1 if MX#>10 and MY#>170 and MX#<40 and MY#<196 O = 2 if mouseclick() = 1 LV = LV - 1 if LV < 1 then LV = 100 for y = 1 to 50 : for x = 1 to 50 Wall(x,y) = 0 next x : next y Gosub Load_Level `loads the level endif while mouseclick() = 1 : endwhile endif ink RGB(0,96,96),0 : Box 6,166,74,200 : ink RGB(0,128,128),0 : Box 8,168,72,198 ink RGB(128/O,128/O,128/O),0 : Box 10,170,40,196 Rem The Level Button Right P = 1 if MX#>40 and MY#>170 and MX#<70 and MY#<196 P = 2 if mouseclick() = 1 LV = LV + 1 if LV > 100 then LV = 1 for y = 1 to 50 : for x = 1 to 50 Wall(x,y) = 0 : next x : next y Gosub Load_Level `loads the level endif while mouseclick() = 1 : endwhile endif ink RGB(128/P,128/P,128/P),0 : Box 40,170,70,196 Rem The Test Level Button Q = 1 if MX#>10 and MY#>210 and MX#<70 and MY#<236 Q = 2 if mouseclick() = 1 Rem Save the level before loading Gosub Save Testing = 1 `Tests the level Goto StartGame: `Starts the game endif while mouseclick() = 1 : endwhile endif ink RGB(0,96,96),0 : Box 6,206,74,240 : ink RGB(0,128,128),0 : Box 8,208,72,238 ink RGB(128/Q,128/Q,128/Q),0 : Box 10,210,70,236 Rem The Play Game Button R = 1 if MX#>10 and MY#>250 and MX#<70 and MY#<276 R = 2 if mouseclick() = 1 Gosub Save`saves the game REM Starts level 1 LV = 1 : Testing = 0 : Goto StartGame: endif while mouseclick() = 1 : endwhile endif ink RGB(0,96,96),0 : Box 6,246,74,280 : ink RGB(0,128,128),0 : Box 8,248,72,278 ink RGB(128/R,128/R,128/R),0 : Box 10,250,70,276 Rem The Exit Button S = 1 if MX#>10 and MY#>290 and MX#<70 and MY#<316 S = 2 if mouseclick() = 1 then end endif ink RGB(0,96,96),0 : Box 6,286,74,320 : ink RGB(0,128,128),0 : Box 8,288,72,318 ink RGB(128/S,128/S,128/S),0 : Box 10,290,70,316 Rem Text for the buttons ink rgb(255,255,255),0 : center text 40,94,"Fill" : center text 40,134,"Save" Tex$ = "LV:"+Str$(LV) : center text 40,174,Tex$ center text 40,214,"Test" : center text 40,254,"Play" : center text 40,294,"Exit" sync : cls loop end `The end of the maze maker program `======================================================================================== `======================================================================================== StartGame: `The start of the maze game set display mode 640,480,32 sync on : sync rate 30 : autocam off : set camera range 0,.1,100000 color backdrop RGB(100,133,153) : fog on : fog distance 400 : fog color RGB(100,133,153) show mouse : set text font "modern" : set text to bold : set text size 12 hide mouse : set ambient light 10 Rem Loading Screen set text size 48 : ink rgb(255,255,255),0 Center text 320,170,"Loading" : Center text 320,230,"Level "+str$(LV) sync : sync : sleep 1000 Rem Loads the images for the maze load image "BlackNBlue.jpg",1 `lighting sphere load image "Checkers.bmp",2 `maze wall textures load image "Floor.JPG",3 `maze floor texture Rem Make The Sky Cube SCN = 6 `Sky Cube Object Number SLN = 7 `Sky Cube Limb Object Number (temporary object number) STN = 4 `Sky Cube Texture Start Number (1 to 6) SBI = 1 `Sky Background Images Gosub Make_SkyCube: Rem Creates the Player/Cube make object cube 1,2` : hide object 1 position object 1,0,10,0 Rem Creates the Lighting Sphere make object sphere 2,1 : texture object 2,1 set object cull 2,0 : ghost object on 2,2 make object sphere 3,2 : make object sphere 4,2.2 : ghost object on 4,2 `The Exit Object dim Wall(50,50) `Maze Data Array Rem Loads the maze level data Tex$ = "Level_"+Str$(LV) if file exist(Tex$) = 0 : LV = 1 : goto MazeMaker : endif if file exist(Tex$) = 1 Open to read 1,Tex$ for y = 1 to 50 read string 1,Tex$ for x = 1 to 50 Wall(x,y) = Val(Mid$(Tex$,x)) next x next y Close file 1 endif Rem Create all of the boxes that have collision obj = 1000 for z = 1 to 50 for x = 1 to 50 if Wall(x,z) = 1 obj = obj + 1 make object cube obj,4 : position object obj,x*4,2,-z*4 : texture object obj,2 : set object filter obj,0 endif if Wall(x,z) = 2 then position object 1,x*4,2,-z*4 if Wall(x,z) = 3 : position object 3,x*4,2,-z*4 : position object 4,x*4,2,-z*4 : endif next x next z Rem creates the floor and the walls around the maze obj = obj + 1 make object box obj,200,4,200 : position object obj,25*4+2,-2,-25*4-2 Texture object obj,3 : scale object texture obj,50,50 obj = obj + 1 : make object box obj,200,4,4 : position object obj,25*4+2,2,-204 texture object obj,2 : set object filter obj,0 : scale object texture obj,50,1 obj = obj + 1 : make object box obj,200,4,4 : position object obj,25*4+2,2,0 texture object obj,2 : set object filter obj,0 : scale object texture obj,50,1 obj = obj + 1 : make object box obj,4,4,200 : position object obj,204,2,-25*4-2 texture object obj,2 : set object filter obj,0 : scale object texture obj,50,1 obj = obj + 1 : make object box obj,4,4,200 : position object obj,0,2,-25*4-2 texture object obj,2 : set object filter obj,0 : scale object texture obj,50,1 objs = obj `variable for getting the amount of objects that have collision CAX# = 0 : CAY# = 0 `resets the angles of the camera Rem Blur effects Variables Mblur = 70`% Alpha = 256-Mblur*2.5 blur = 0`0-20 Rem sets up sprite for the blur effects set camera to image 0,1000,512,512 sprite 1000,320,240,1000 : size sprite 1000,640,480 : offset sprite 1000,320,240 : set sprite 1000,0,1 ` L OOOOO OOOOO PPPPP ` L O O O O P P ` L O O O O PPPPP ` L O O O O P ` LLLLL OOOOO OOOOO P do Rem Randomly color the exit sphere and check for collision color object 3,rgb(rnd(255),rnd(255),rnd(255)) : color object 4,rgb(rnd(255),rnd(255),rnd(255)) if object collision(1,3) `Starts the Next Level or goes back to the level editor if Testing = 1 then goto MazeMaker if Testing = 0 : LV = LV + 1 : goto StartGame : endif endif Rem Mouse controls MMX# = MouseMoveX() : MMY# = MouseMoveY() CAX# = CAX# + MMY# : CAY# = CAY# + MMX# if CAX# > 85 then CAX# = 85 if CAX# < -85 then CAX# = -85 rotate object 1,0,0,0 : turn object right 1,CAY# `turns the player rotate camera 0,CAX#,CAY#,0 `rotates the camera Rem Slow the player to a stop when the player is not moving if P1SpeedZ# > .1 then Dec P1SpeedZ#,.1 if P1SpeedZ# < -.1 then Inc P1SpeedZ#,.1 if P1SpeedX# > .1 then Dec P1SpeedX#,.1 if P1SpeedX# < -.1 then Inc P1SpeedX#,.1 if P1SpeedZ# > .01 then Dec P1SpeedZ#,.01 if P1SpeedZ# < -.01 then Inc P1SpeedZ#,.01 if P1SpeedX# > .01 then Dec P1SpeedX#,.01 if P1SpeedX# < -.01 then Inc P1SpeedX#,.01 if P1SpeedZ# > .001 then Dec P1SpeedZ#,.001 if P1SpeedZ# < -.001 then Inc P1SpeedZ#,.001 if P1SpeedX# > .001 then Dec P1SpeedX#,.001 if P1SpeedX# < -.001 then Inc P1SpeedX#,.001 if P1SpeedZ# > 0 then Dec P1SpeedZ#,.0001 if P1SpeedZ# < 0 then Inc P1SpeedZ#,.0001 if P1SpeedX# > 0 then Dec P1SpeedX#,.0001 if P1SpeedX# < 0 then Inc P1SpeedX#,.0001 if P1SpeedZ# > 0 and P1SpeedZ# < .0002 then P1SpeedZ# = 0 if P1SpeedZ# < 0 and P1SpeedZ# > -.0002 then P1SpeedZ# = 0 if P1SpeedX# > 0 and P1SpeedX# < .0002 then P1SpeedX# = 0 if P1SpeedX# < 0 and P1SpeedX# > -.0002 then P1SpeedX# = 0 Rem Control the movement of the player with the arrow keys if UpKey() = 1 then Inc P1SpeedZ#,.15 if DownKey() = 1 then Dec P1SpeedZ#,.15 if RightKey() = 1 then Inc P1SpeedX#,.15 if LeftKey() = 1 then Dec P1SpeedX#,.15 Rem Puts a limit on the players speed if P1SpeedZ# > 1 then P1SpeedZ# = 1 if P1SpeedZ# < -1 then P1SpeedZ# = -1 if P1SpeedX# > 1 then P1SpeedX# = 1 if P1SpeedX# < -1 then P1SpeedX# = -1 P1SpeedY# = P1SpeedY# -.02 `Gravity if P1SpeedY# < -2 then P1SpeedY# = -2 `Maximum Gravity speed Rem if the player is on solid ground and clicks the mouse then make the player jump if mouseclick() = 1 and Ground = 1 if Testing = 0 then P1SpeedY# = .25 if Testing = 1 then P1SpeedY# = .75 endif Ground = 0 `sets Ground to 0 so that the player cannot jump in midair Rem Moves the Player move object 1,P1SpeedZ#/2 `forwards and backwards move object right 1,P1SpeedX#/3 `right and left move object up 1,P1SpeedY# `gravity Rem positions the player at the base if the player falls off of the map if object position y(1) < -50 position object 1,100,200,-100 endif ` CCCCC OOOOO L L IIIII SSSSS IIIII OOOOO NN N ` C O O L L I S I O O N N N ` C O O L L I SSSSS I O O N N N ` C O O L L I S I O O N NN ` CCCCC OOOOO LLLLL LLLLL IIIII SSSSS IIIII OOOOO N N for i = 1001 to objs obj = i if object position x(1)+1 > (object position x(obj)-object size x(obj)/2) if object position x(1)-1 < (object position x(obj)+object size x(obj)/2) if object position y(1)+1 > (object position y(obj)-object size y(obj)/2) if object position y(1)-1 < (object position y(obj)+object size y(obj)/2) if object position z(1)+1 > (object position z(obj)-object size z(obj)/2) if object position z(1)-1 < (object position z(obj)+object size z(obj)/2) if object position y(1)+.5 > (object position y(obj)-object size y(obj)/2) if object position y(1)-.5 < (object position y(obj)+object size y(obj)/2) if object position z(1)+.5 > (object position z(obj)-object size z(obj)/2) if object position z(1)-.5 < (object position z(obj)+object size z(obj)/2) if OPX# <= object position x(obj)-object size x(obj)/2 then position object 1,object position x(obj)-object size x(obj)/2-1,object position y(1),object position z(1) if OPX# >= object position x(obj)+object size x(obj)/2 then position object 1,object position x(obj)+object size x(obj)/2+1,object position y(1),object position z(1) endif:endif:endif:endif if object position x(1)+.5 > (object position x(obj)-object size x(obj)/2) if object position x(1)-.5 < (object position x(obj)+object size x(obj)/2) if object position z(1)+.5 > (object position z(obj)-object size z(obj)/2) if object position z(1)-.5 < (object position z(obj)+object size z(obj)/2) if OPY# <= object position y(obj)-object size y(obj)/2 position object 1,object position x(1),object position y(obj)-object size y(obj)/2-1,object position z(1) P1SpeedY# = 0 endif if OPY# >= object position y(obj)+object size y(obj)/2 position object 1,object position x(1),object position y(obj)+object size y(obj)/2+1,object position z(1) P1SpeedY# = 0 if mouseclick() = 0 then Ground = 1 endif endif:endif:endif:endif if object position x(1)+.5 > (object position x(obj)-object size x(obj)/2) if object position x(1)-.5 < (object position x(obj)+object size x(obj)/2) if object position y(1)+.5 > (object position y(obj)-object size y(obj)/2) if object position y(1)-.5 < (object position y(obj)+object size y(obj)/2) if OPZ# <= object position z(obj)-object size z(obj)/2 then position object 1,object position x(1),object position y(1),object position z(obj)-object size z(obj)/2-1 if OPZ# >= object position z(obj)+object size z(obj)/2 then position object 1,object position x(1),object position y(1),object position z(obj)+object size z(obj)/2+1 endif:endif:endif:endif endif:endif:endif:endif:endif:endif next i Rem gets the old object position of object 1 OPX# = object position x(1) : OPY# = object position y(1) : OPZ# = object position z(1) position camera 0,Object position x(1),Object position y(1),Object position z(1) `positions the camera position object 2,Object position x(1),Object position y(1),Object position z(1) `positions the lighting sphere position object SCN,Object position x(1),Object position y(1),Object position z(1) `positions the sky cube gosub Blur `Updates the blur effects Rem Text Stuff set text size 12 : text 10,10,"Press 'Q' to Quit" if Testing = 1 then text 10,20,"FPS:"+str$(screen fps()) if inkey$() = "q" or inkey$() = "Q" then goto MazeMaker sync loop end ` SSSSS K K Y Y ` S K K Y Y ` SSSSS KKK Y Y ` S K K Y ` SSSSS K K Y Rem Create The Sky Cube Make_SkyCube: SkyCSize# = 10000.0 `The size of the Sky Box select SBI Case 1 `You can add more to the select case to make different sky boxes on each level load image "Cube_top02.jpg",STN : load image "Cube_north02.jpg",STN+1 load image "Cube_east02.jpg",STN+2 : load image "Cube_south02.jpg",STN+3 load image "Cube_west02.jpg",STN+4 : load image "Cube_bottom02.jpg",STN+5 endCase endselect Make Object Plain SCN,0,0 : Make Object Plain SLN,SkyCSize#,SkyCSize# : Make Mesh From Object SLN,SLN Add Limb SCN,1,SLN : Offset Limb SCN,1,0,(SkyCSize#/2),0 : Rotate Limb SCN,1,270,90,0` Top Add Limb SCN,2,SLN : Offset Limb SCN,2,0,0,(SkyCSize#/2)` Front Add Limb SCN,3,SLN : Offset Limb SCN,3,SkyCSize#/2,0,0 : Rotate Limb SCN,3,0,90,0` Right Add Limb SCN,4,SLN : Offset Limb SCN,4,0,0,(SkyCSize#/2-SkyCSize#) : Rotate Limb SCN,4,0,180,0` Back Add Limb SCN,5,SLN : Offset Limb SCN,5,(SkyCSize#/2-SkyCSize#),0,0 : Rotate Limb SCN,5,0,270,0` left Add Limb SCN,6,SLN : Offset Limb SCN,6,0,-(SkyCSize#/2),0 : Rotate Limb SCN,6,90,90,0` bottom for i = 1 to 6 `scaling and textureing the sky cube Scale Limb SCN,i,100.1,100.1,100.1 : Texture Limb SCN,i,i+STN-1 next i Delete Object SLN set object cull SCN,0 : set object filter SCN,0 set object light SCN,0 : set object ambient SCN,0 : set object fog SCN,0 Return `BBBB L U U RRRR `B B L U U R R `BBBB L U U RRRR `B B L U U R R `BBBB LLLLL UUU R R Rem Blur Effects Blur: set sprite alpha 1000,Alpha : sprite 1000,320,240,1000 set sprite alpha 1000,Alpha : paste sprite 1000,320+blur,240 set sprite alpha 1000,Alpha/2 : paste sprite 1000,320,240+blur set sprite alpha 1000,Alpha/4 : paste sprite 1000,320-blur,240 set sprite alpha 1000,Alpha/8 : paste sprite 1000,320,240-blur return `SSSSS AAAAA V V EEEEE L EEEEE V V EEEEE L `S A A V V E L E V V E L `SSSSS AAAAA V V EEEE L EEEE V V EEEE L ` S A A V V E L E V V E L `SSSSS A A V EEEEE LLLLL EEEEE V EEEEE LLLLL Rem Saves the new maze Save: Tex$ = "Level_"+Str$(LV) if file exist(Tex$) = 1 then delete file Tex$ Open to write 1,Tex$ for y = 1 to 50 Tex$ = "" for x = 1 to 50 Tex$ = Tex$+Str$(Wall(x,y)) next x write string 1,Tex$ next y Close file 1 return `L OOOOO AAAAA DDDD L EEEEE V V EEEEE L `L O O A A D D L E V V E L `L O O AAAAA D D L EEEE V V EEEE L `L O O A A D D L E V V E L `LLLLL OOOOO A A DDDD LLLLL EEEEE V EEEEE LLLLL Rem Loads the data for the levels Load_Level: Wall(2,49) = 2 : Wall(49,2) = 3`Places a Start and End points Tex$ = "Level_"+Str$(LV) if file exist(Tex$) = 1 Open to read 1,Tex$ for y = 1 to 50 read string 1,Tex$ for x = 1 to 50 Wall(x,y) = Val(Mid$(Tex$,x)) next x next y Close file 1 endif Return |