-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSimple Land Generator.bb
89 lines (83 loc) · 1.48 KB
/
Simple Land Generator.bb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
; simple land generator using rand()
Graphics 640,480,32,2
SetBuffer BackBuffer()
SeedRnd MilliSecs()
Const mapwidth = 39
Const mapheight = 29
Const tilewidth = 16
Const tileheight = 16
Dim map(mapwidth,mapheight)
While KeyDown(1) = False
Cls
makemap()
drawmap()
Flip
For i=0 To 500
If KeyDown(1) = True Then End
Delay 1
Next
Wend
WaitKey
End
Function drawmap()
For y=0 To mapheight
For x=0 To mapwidth
If map(x,y) < 5
Color 0,0,200
End If
If map(x,y)>5 And map(x,y)<8
Color 0,150,0
End If
If map(x,y)>8 And map(x,y)<10
Color 0,255,0
End If
If map(x,y) > 10
Color 200,200,200
End If
Rect x*tilewidth,y*tileheight,tilewidth,tileheight,True
Next
Next
End Function
Function makemap()
For y=0 To mapheight
For x=0 To mapwidth
map(x,y) = 0
Next
Next
For i=0 To 50 ; number of draws on random locations
x = Rand(mapwidth)
y = Rand(mapheight)
For y1=-4 To 4
For x1=-4 To 4
x2 = x+ x1
y2 = y+ y1
If x2=>0 And y2=> 0 And x2=<mapwidth And y2=<mapheight
map(x2,y2) = map(x2,y2) + 1
End If
Next
Next
For y1=-2 To 2
For x1=-2 To 2
x2 = x+ x1
y2 = y+ y1
If x2=>0 And y2=> 0 And x2=<mapwidth And y2=<mapheight
map(x2,y2) = map(x2,y2) + 1
End If
Next
Next
For y1=-1 To 1
For x1=-1 To 1
x2 = x+ x1
y2 = y+ y1
If x2=>0 And y2=> 0 And x2=<mapwidth And y2=<mapheight
map(x2,y2) = map(x2,y2) + 1
End If
Next
Next
Next
For y=0 To mapheight
For x=0 To mapwidth
DebugLog map(x,y)
Next
Next
End Function