ArcBasicDocs

tutorials/beginner

09_skyline.abs

41 lines of ArcBasic. Words in colour that are commands link to their help page. To run it, download ArcBasic, open the file and press F5.

Download 09_skyline.absAll files in this folder

09_skyline.abs
; Arrays: one name, lots of valuesGraphics 640, 480SeedRnd MilliSecs()Dim height(15)                  ; 16 boxes: height(0) to height(15)For i = 0 To 15	height(i) = Rand(60, 300)NextClsColor 30, 20, 60Cls; draw the buildings, each 40 pixels wide, standing on the bottom of the screenFor i = 0 To 15	Color 40 + i * 5, 40, 80	Rect i * 40, 480 - height(i), 38, height(i)	; lit windows	Color 255, 220, 120	For wy = 480 - height(i) + 10 To 470 Step 20		If Rand(1, 3) = 1 Then Rect i * 40 + 8, wy, 8, 8		If Rand(1, 3) = 1 Then Rect i * 40 + 22, wy, 8, 8	NextNext; find the tallest buildingtallest = 0For i = 1 To 15	If height(i) > height(tallest) Then tallest = iNextlabelX = tallest * 40 + 19If labelX < 40 Then labelX = 40          ; keep the label on the screenIf labelX > 600 Then labelX = 600Color 255, 255, 255Text labelX, 480 - height(tallest) - 20, "Tallest!", TrueText 10, 10, "Press any key"WaitKeyEnd