Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
My Lunar Lander bloatware! (ver 0.33)
#4
Here is one of my simple clocks using Dav's chimes. The chimes section is towards the bottom. When you run it, press the Space Bar to hear the chimes anytime. They also play at the top of the hour.

Code: (Select All)
_Title "Clock by Ken G."
Screen _NewImage(350, 350, 32)
_Limit 500
Do
    a$ = InKey$
    If a$ = " " Then chimes = 1
    Circle (180, 184), 140, _RGB32(127, 249, 255)
    hours = Timer \ 3600
    minutes = Timer \ 60 - hours * 60
    seconds = (Timer - hours * 3600 - minutes * 60)
    ho$ = Left$(Time$, 2): hou = Val(ho$)
    min$ = Mid$(Time$, 4, 2): minu = Val(min$)
    seco$ = Right$(Time$, 2): secon = Val(seco$)

    'Minutes
    m = 180 - minutes * 6
    xx = Int(Sin(m / 180 * 3.141592) * 120) + 180
    yy = Int(Cos(m / 180 * 3.141592) * 120) + 184
    For b = -5 To 5 Step .1
        Line (180 + b, 184)-(xx, yy), _RGB32(0, 255, 255)
        Line (180, 184 + b)-(xx, yy), _RGB32(0, 255, 255)
    Next b
    'Hours
    h = 360 - hours * 30 + 180
    xxx = Int(Sin(h / 180 * 3.141592) * 100) + 180
    yyy = Int(Cos(h / 180 * 3.141592) * 100) + 184
    For b = -5 To 5 Step .1
        Line (180 + b, 184)-(xxx, yyy), _RGB32(0, 255, 0)
        Line (180, 184 + b)-(xxx, yyy), _RGB32(0, 255, 0)
    Next b
    'Seconds
    s = (60 - seconds) * 6 + 180
    x = Int(Sin(s / 180 * 3.141592) * 125) + 180
    y = Int(Cos(s / 180 * 3.141592) * 125) + 184
    For b = -5 To 5 Step .1
        Line (180 + b, 184)-(x, y), _RGB32(255, 0, 0)
        Line (180, 184 + b)-(x, y), _RGB32(255, 0, 0)
    Next b

    'Dav's Chimes
    If (minu = 0 And secon = 0) Or chimes = 1 Then
        hour2 = hou
        If hour2 > 12 Then hour2 = hour2 - 12
        If hour2 = 0 Then hour2 = 12
        For chimes = 1 To hour2
            ttt = 0
            Do
                'queue some sound
                Do While _SndRawLen < 0.1 'you may wish to adjust this
                    sample = Sin(ttt * 340 * Atn(1) * 8) '340Hz sine wave (ttt * 440 * 2p)
                    sample = sample * Exp(-ttt * 3) 'fade out eliminates clicks after sound
                    _SndRaw sample
                    ttt = ttt + 1 / _SndRate 'sound card sample frequency determines time
                Loop
                'do other stuff, but it may interrupt sound
            Loop While ttt < 2 'play for 2 seconds
            Do While _SndRawLen > 0 'Finish any left over queued sound!
            Loop
        Next chimes
    End If
    chimes = 0
    two:
    _Display
    Cls
Loop
Reply


Messages In This Thread
RE: My Lunar Lander bloatware! (ver 0.33) - by SierraKen - 07-20-2022, 06:47 PM



Users browsing this thread: 1 Guest(s)