Landscape Generator

Post Reply
DrChip
Posts: 167
Joined: Wed Oct 22, 2014 3:26 pm
My devices: iPhone 4 to 6+,iPad mini to iPad air 2

Landscape Generator

Post by DrChip »

Code: Select all

REM Landscape Generator
REM iPhone 6 plus / 8.3 b3
REM Enjoy...


init:
graphics
graphics clear 0,0,0
sw=screen_width()
sh=screen_height()



Landscape:

draw = 0
draw color 0,0,0
graphics clear 0,0,0


REM Data
lWidth = rnd(50)+60
lHeight = rnd(50)+60
scaleX = rnd(5)+2
scaleY = rnd(3)+2
nrHotspots = rnd(450)+100
originalHeight = rnd(200)+100
XAngle = rnd(110)-55
smoothing = rnd(13)+5

dim l(lWidth+1,lHeight+1)
REM ---Prints landscape information---
draw color 1,1,200/255
draw text  "Landscape data" at 10,10
draw text  "-----------------------" at 10,20
draw text  "Width: " & str$(lWidth) at 10,40
draw text  "Height: " & str$(lHeight) at 10,60
draw text  "ScaleX: " & str$(scaleX) at 10,80
draw text  "ScaleY: " & str$(scaleY) at 10,100
draw text  "Hotspots: " & str$(nrHotspots) at 10,120
draw text  "Hotspot height: " & str$(originalHeight) at 10,140
draw text  "XAngle: " & str$(XAngle) at 10,160
draw text  "Smoothing: " & str$(smoothing) at 10,180

draw color 1,1,1
draw text "Generating hotspots......." at 10,250
REM ---Generate Hotspots---

for i=1 to nrHotspots
  x = rnd(lWidth-8)+4
  y = rnd(lHeight-8)+4
  l(x,y) = originalHeight
  procentDone = (i/nrHotspots)*100
next i 
fill color 0,0,0
fill rect 10,230 to sw,270
draw color 1,1,1
draw text "Generating hotspots.......100% completed" at 10,250



startDrawX = sw/2-((lWidth*scaleX)/2)-(XAngle*1.5)
startDrawY = sh/2-((lHeight*scaleY)/2)

procentDone = 0

draw color 1,1,1
draw text "Smoothing.......loading" at 10,270

for i=1 to smoothing
 for y = 1 to lHeight-1
  for x = 1 to lWidth-1
   l(x,y) = (l(x+1,y)+l(x+1,y+1)+l(x,y+1)+l(x-1,y+1)+l(x-1,y)+l(x-1,y-1)+l(x,y-1)+l(x+1,y+1))*0.125
  next x
 next y
 procentDone = (i/smoothing)*100
 fill color 0,0,1
 fill rect 0,sh-20 to sw,sh
 draw color 1,1,1
 draw text "Smoothing......." & str$(procentDone) & "% " at 10,sh-20
next i

fill color 0,0,1
fill rect 0,sh-20 to sw,sh
draw color 1,1,1
draw text "Smoothing.......100%" at 10,sh-20

REM Let's Draw the landscape
fill color 0,0,110/255
fill rect 0,0 to sw,sh
incXAngle = XAngle/lHeight

for y = 1 to lHeight-1
 for x = 1 to lWidth-1
   x1 = startDrawX+x*scaleX+XAngle
   y1 = startDrawY+y*scaleY
   x2 = x1+scaleX
   y2 = y1+scaleY-(l(x,y)*3)
   if l(x,y) >= 50 then
    fill color (l(x,y)+50)/255,(l(x,y)+50)/255,(l(x,y)+50)/255
    fill rect x1,y1 to x2,y2
   endif
   if l(x,y) < 50 and l(x,y) > 40 then
    fill color l(x,y)/255,l(x,y)/255,l(x,y)/255
    fill rect x1,y1 to x2,y2
   end if

   if l(x,y) <= 40 and l(x,y) > 6 then 
    fill color 0,(l(x,y)+30)/255,0
    fill rect x1,y1 to x2,y2
   endif
   if l(x,y) <= 6 then 
    fill color 0,(l(x,y)*10)/255,110/255
    fill rect x1,y1 to x2,y2
   endif
 next x
 XAngle=XAngle+incXAngle
next y
pause 5
goto Landscape
Attachments
image.jpg
image.jpg (115.06 KiB) Viewed 1273 times
image.jpg
image.jpg (223.8 KiB) Viewed 1273 times
image.jpg
image.jpg (226.71 KiB) Viewed 1273 times
image.jpg
image.jpg (197.8 KiB) Viewed 1273 times
image.jpg
image.jpg (120.56 KiB) Viewed 1273 times
Last edited by DrChip on Fri Sep 04, 2015 2:35 am, edited 1 time in total.

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: Landscape Generator

Post by Mr. Kibernetik »

Good start for a game...

Post Reply