[bb] 2D Mountain Generation by Subirenihil [ 1+ years ago ]

Started by BlitzBot, June 29, 2017, 00:28:42

Previous topic - Next topic

BlitzBot

Title : 2D Mountain Generation
Author : Subirenihil
Posted : 1+ years ago

Description : Generates random 2D mountains (like for old style tank games, which is exatly what I used this method for).  I had been using 15 year old BASIC programming language until 3 years ago when I upgraded to BlitzBasic (I upgraded to Blitz3D in December of 2005).  This code is the BlitzBasic version of the code.

Code :
Code (blitzbasic) Select
Global w=1024,h=768,d=32;Modify for your system.
Graphics w,h,d,1
SetBuffer BackBuffer()
Cls

SeedRnd MilliSecs()

y=Rnd(100,h-1)
sy=Rnd(-2,2)
For x=0 to w-1
    py=y
    y=py+Rnd(-1,1)+sy
    If y<100 Then y=100
    If y>h-1 Then y=h-1
    sy=y-py
    If Abs(sy)>2 Then sy=Sgn(sy)*2
    Line x,y,x,h-1
Next

Flip
WaitKey()
End


Comments : none...