November 30, 2020, 02:40:27 AM

Author Topic: [bb] 2D Mountain Generation by Subirenihil [ 1+ years ago ]  (Read 631 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
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
  1. Global w=1024,h=768,d=32;Modify for your system.
  2. Graphics w,h,d,1
  3. SetBuffer BackBuffer()
  4. Cls
  5.  
  6. SeedRnd MilliSecs()
  7.  
  8. y=Rnd(100,h-1)
  9. sy=Rnd(-2,2)
  10. For x=0 to w-1
  11.     py=y
  12.     y=py+Rnd(-1,1)+sy
  13.     If y<100 Then y=100
  14.     If y>h-1 Then y=h-1
  15.     sy=y-py
  16.     If Abs(sy)>2 Then sy=Sgn(sy)*2
  17.     Line x,y,x,h-1
  18. Next
  19.  
  20. Flip
  21. WaitKey()
  22. End


Comments : none...

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal