Ooops
January 21, 2021, 02:48:41 AM

Author Topic: [bb] Create 2D terrains by skn3 [ 1+ years ago ]  (Read 393 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] Create 2D terrains by skn3 [ 1+ years ago ]
« on: June 29, 2017, 12:28:38 AM »
Title : Create 2D terrains
Author : skn3
Posted : 1+ years ago

Description : Creates a nice 2D terrain. In my oppinion, perect random landscapes  

Code :
Code: BlitzBasic
  1. Graphics 1024,768,32,1
  2.  
  3. Repeat
  4.         SetBuffer BackBuffer()
  5.         Cls
  6.         CreateMap(GraphicsWidth(),GraphicsHeight())
  7.         Flip
  8.         WaitKey()
  9. Until KeyDown(1)=True
  10.  
  11.  
  12. Function CreateMap(width,height)
  13.         y2=height
  14.         y1=(height-100)/2+Rand(50,300) 
  15.         For x=0 To width
  16.                 SeedRnd MilliSecs()
  17.                 y1=y1+Cos(x)*Rand(-(Sin(x)*Rand(5)),(Sin(x)*Rand(5)))
  18.                 If y1>y2 Then y1=y2
  19.                 If y1<(height-150)/3 Then y1=(height-150)/3
  20.                 Plot x,y1
  21.         Next
  22. End Function


Comments :


Berserker [swe](Posted 1+ years ago)

 Thank you!This has surely helped me!I have made an edit to the code at: <a href="codearcs71e3.html?code=1339" target="_blank">http://www.blitzbasic.com/codearcs/codearcs.php?code=1339[/url]Hope you dont mind.


ozak(Posted 1+ years ago)

 And the simple filled terrain edition.Simply replace
Code: [Select]
Plot x,y1
with
Code: [Select]
Line x,y1,x+1,GraphicsHeight()


 

SimplePortal 2.3.6 © 2008-2014, SimplePortal