Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
request for printing patterns with for loops tutorial
#4
Color the tree:
Code: (Select All)
Screen _NewImage(400, 600, 32)
xc = 200
For i = 1 To 31
    Locate i + 1, 25 - Int(i / 2)
    For j = 1 To i
        Color _RGB32(Rnd * 200 + 55, -(Rnd < .5) * Rnd * 255, -(Rnd < .5) * Rnd * 255)
        Print "*";
    Next
Next
Color _RGB32(100, 50, 25)
For i = 32 To 35
    _PrintString (xc - .5 * 2 * 8, i * 16), String$(2, "*")
Next
Sleep

Color the tree AND make lights twinkle:
Code: (Select All)
Screen _NewImage(400, 600, 32)
_PrintMode _KeepBackground
xc = 200
For i = 1 To 31
    Locate i + 1, 25 - Int(i / 2)
    For j = 1 To i
        Color _RGB32(Rnd * 200 + 55, -(Rnd < .5) * Rnd * 255, -(Rnd < .5) * Rnd * 255)
        Print "*";
    Next
Next
Color _RGB32(100, 50, 25)
For i = 32 To 35
    _PrintString (xc - .5 * 2 * 8, i * 16), String$(2, "*")
Next
' twinkle
Do
    i = Int(Rnd * 31) + 1
    Locate i + 1, 25 - Int(i / 2)
    k = Int(Rnd * i) + 1
    For j = 1 To i
        If j = k Then
            Color _RGB32(Rnd * 200 + 55, -(Rnd < .5) * Rnd * 255, -(Rnd < .5) * Rnd * 255)
            Print "*";
        Else
            Print " ";
        End If
    Next
    _Limit 10
Loop
b = b + ...
Reply


Messages In This Thread
RE: request for printing patterns with for loops tutorial - by bplus - 11-20-2024, 02:59 PM



Users browsing this thread: 2 Guest(s)