Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- `make a few arrays
- DIM grid (100,100)
- DIM scanner (100,100)
- `create a nice viewport AND set the romantic mood
- make camera 1
- position camera 1,0,0,180
- POINT camera 1,0,0,100
- color backdrop 1,rgb (0,0,0)
- make light 1
- color light 1, rgb(255,50,0)
- position light 1,50,0,200
- make light 2
- color light 2, rgb(0,50,255)
- position light 2,-50,0,200
- `set the size of the maze
- DATA 13,10
- ` set the maze
- DATA 1,1,1,1,1,1,1,1,1,1,1,1,1
- DATA 1,3,0,0,0,0,0,0,0,1,2,0,1
- DATA 1,1,1,1,1,1,1,1,0,1,1,0,1
- DATA 1,0,0,0,0,0,0,0,0,1,1,0,1
- DATA 1,0,1,1,1,1,1,1,1,0,1,0,1
- DATA 1,0,0,0,0,0,0,0,0,0,1,0,1
- DATA 1,0,1,1,1,1,0,1,1,1,1,0,1
- DATA 1,1,0,0,0,1,0,1,0,1,0,0,1
- DATA 1,0,0,1,0,0,0,0,0,0,0,0,1
- DATA 1,1,1,1,1,1,1,1,1,1,1,1,1
- `READ the maze size
- READ maxx
- READ maxy
- `READ the maze into an array
- FOR yt = 1 TO maxy
- FOR xt = 1 TO maxx
- an=an+1
- READ griddata
- grid(xt,yt) = griddata
- ypos = 45+(maxy)-(yt*10)
- xpos = 57+(maxx)-(xt*10)
- `make the objects AND position them
- IF griddata = 1 THEN make object cube an,10 : position object an, xpos,ypos,90:color object an, rgb(145,57,144)
- IF griddata = 2 THEN make object sphere 400,9: position object 400,xpos,ypos,90: color object 400, rgb(0,0,255)
- IF griddata = 3 THEN make object sphere 401,9: position object 401,xpos,ypos,90: color object 401, rgb(255,0,0)
- `find start AND END of maze
- IF griddata=2 THEN startcoordx=xt
- IF griddata=2 THEN startcoordy=yt
- IF griddata=3 THEN stopcoordx=xt
- IF griddata=3 THEN stopcoordy=yt
- NEXT xt
- NEXT yt
- sync
- `this does stuff
- searchx=startcoordx
- searchy=startcoordy
- `CALLS the pathfinding FUNCTION (it's recursive)
- scannert(searchx,searchy,99)
- `some more stuff
- upcount=scanner(stopcoordx,stopcoordy)
- coordx=stopcoordx
- coordy=stopcoordy
- `main LOOP
- DO
- `make a 150 ms pause between each LOOP TO keep stuff visible
- SLEEP 150
- value=scanner(coordx,coordy)
- newvalue=scanner(coordx+1,coordy)
- gridvar=grid(coordx+1,coordy)
- IF value < newvalue AND gridvar =0 THEN t=t+1:coordx=coordx+1:makeamark(coordx,coordy,maxx,maxy,t)
- value=scanner(coordx,coordy)
- newvalue=scanner(coordx-1,coordy)
- gridvar=grid(coordx-1,coordy)
- IF value < newvalue AND gridvar =0 THEN t=t+1:coordx=coordx-1:makeamark(coordx,coordy,maxx,maxy,t)
- value=scanner(coordx,coordy)
- newvalue=scanner(coordx,coordy+1)
- gridvar=grid(coordx,coordy+1)
- IF value < newvalue AND gridvar =0 THEN t=t+1:coordy=coordy+1:makeamark(coordx,coordy,maxx,maxy,t)
- value=scanner(coordx,coordy)
- newvalue=scanner(coordx,coordy-1)
- gridvar=grid(coordx,coordy-1)
- IF value < newvalue AND gridvar =0 THEN t=t+1:coordy=coordy-1:makeamark(coordx,coordy,maxx,maxy,t)
- value=scanner(coordx,coordy)
- IF value > 99 THEN GOTO theend
- sync
- LOOP
- theend:
- DO:LOOP
- FUNCTION makeamark(x,y,maxx,maxy,t)
- `makes a square when it finds the right path
- ypos = 45+(maxy)-(y*10)
- xpos = 57+(maxx)-(x*10)
- make object cube t+500,10: color object t+500,rgb(0,255,0)
- position object t+500, xpos,ypos,90
- endfunction
- FUNCTION scannert(x,y,distance)
- `the pathfinder
- scanner(x, y) = distance ` set the distance TO current location
- ` scan left
- gridvar = grid(x-1, y)
- scanvar = scanner(x-1, y)
- IF scanvar < distance AND gridvar <> 1 THEN scannert(x-1, y, distance - 1)
- ` scan right
- gridvar = grid(x+1, y)
- scanvar = scanner(x+1, y)
- IF scanvar < distance AND gridvar <> 1 THEN scannert(x+1, y, distance - 1)
- ` scan up
- gridvar = grid(x, y-1)
- scanvar = scanner(x, y-1)
- IF scanvar < distance AND gridvar <> 1 THEN scannert(x, y-1, distance - 1)
- ` scan down
- gridvar = grid(x, y+1)
- scanvar = scanner(x, y+1)
- IF scanvar < distance AND gridvar <> 1 THEN scannert(x, y+1, distance - 1)
- endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement