Author Topic: Starfield Clock  (Read 5555 times)

0 Members and 1 Guest are viewing this topic.

This topic contains a post which is marked as Best Answer. Press here if you would like to see it.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Starfield Clock
« on: December 11, 2020, 09:33:56 pm »
Here is my first Starfield analog clock. I used my recent Starfield to make a backdrop of an analog clock. In order for everything to keep moving, I couldn't use the same chime sound as my older clocks, so instead I used the PLAY command with the "MB" in the string to play in the background. The sound isn't as good but at least it's something. :) The hardest thing on this was figuring out how to stop the PLAY command, so I had to make a done variable to make it stop chiming every hour. Believe me, I tried everything else I knew. lol
Anyways, enjoy the clock :). Also, you can still speed up and slow down with the stars but the clock stays the same speed. You can also still use the FullScreen move by pressing the Space Bar. I had to change the green circle that flies around the clock to look more like a circle in FullScreen mode, but that is only with the shape of my monitor, so it would look a bit different with other monitors, hopefully not too different.

Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(1000, 800, 32)
  2. DIM starx(1000), stary(1000)
  3. DIM dx(1000), dy(1000)
  4. DIM sz(1000)
  5. DIM speed(1000)
  6. DIM col AS LONG
  7. DIM circx AS SINGLE
  8. DIM circy AS SINGLE
  9. _TITLE "Starfield Clock - by SierraKen - Up and down arrow keys (or W and S keys) for speed. Space Bar switches back and forth to Full Screen. Esc to quit."
  10. circ = 360
  11.     _LIMIT 100
  12.     a$ = INKEY$
  13.     IF a$ = CHR$(27) THEN END
  14.     IF a$ = CHR$(0) + CHR$(72) OR a$ = "w" OR a$ = "W" THEN sp = sp + .0005: _TITLE "Warp: " + warp$
  15.     IF a$ = CHR$(0) + CHR$(80) OR a$ = "s" OR a$ = "S" THEN sp = sp - .0005: _TITLE "Warp: " + warp$
  16.     IF a$ = " " THEN f = f + 1
  17.     IF f = 1 THEN _FULLSCREEN: fullscreen = 1
  18.     IF f = 2 THEN _FULLSCREEN OFF: f = 0: fullscreen = 0
  19.  
  20.     'Clock
  21.     clock
  22.     circ = circ - .1
  23.     IF circ < 0 THEN circ = 360
  24.     IF fullscreen = 1 THEN fs = .75: fs2 = 25
  25.     IF fullscreen = 0 THEN fs = 1: fs2 = 0
  26.     circx = (SIN(circ) * (240 - fs2)) + 500
  27.     circy = (COS(circ) * (240 - fs2)) / fs + 400
  28.     col = _RGB32(0, 255, 0)
  29.     cx = circx: cy = circy: c = col
  30.  
  31.     'Chimes
  32.     ho$ = LEFT$(TIME$, 2)
  33.     hou = VAL(ho$)
  34.     min$ = MID$(TIME$, 4, 2)
  35.     minu = VAL(min$)
  36.     seco$ = RIGHT$(TIME$, 2)
  37.     secon = VAL(seco$)
  38.     IF hou > 12 THEN hou = hou - 12
  39.     IF hou = 0 THEN hou = 12
  40.     IF minu = 0 AND secon = 0 AND done = 0 THEN
  41.         FOR chime = 1 TO hou
  42.             PLAY "MB L6 P1 O1 G"
  43.         NEXT chime
  44.         done = 1
  45.     END IF
  46.     IF secon > 0 THEN done = 0
  47.  
  48.     'Starfield
  49.     fillCircle cx, cy, 5, c
  50.     IF sp < .0005 THEN sp = .0005
  51.     IF sp > .1 THEN sp = .1
  52.     warp = (sp * 100) + 1
  53.     IF warp > 10 THEN warp = 10
  54.     warp = INT(warp)
  55.     warp$ = STR$(warp)
  56.     stars = INT(RND * 100) + 1
  57.     IF stars > 25 THEN
  58.         s = s + 1
  59.         IF s > 950 THEN s = 1
  60.         'Set starting position.
  61.         startx = RND * 490
  62.         starty = RND * 390
  63.         st = INT(RND * 360)
  64.         x = (SIN(st) * startx) + 500
  65.         y = (COS(st) * starty) + 400
  66.         starx(s) = x
  67.         stary(s) = y
  68.         'Set direction to move.
  69.         dx(s) = ((x - 500) / 30)
  70.         dy(s) = ((y - 400) / 30)
  71.         'Set size.
  72.         sz(s) = RND
  73.         'Set speed
  74.         speed(s) = .1
  75.     END IF
  76.     IF yy > 640 THEN yy = 0
  77.     FOR t = 1 TO 950
  78.         speed(t) = speed(t) * (1.05 + sp)
  79.         stary(t) = stary(t) + dy(t) * speed(t)
  80.         starx(t) = starx(t) + dx(t) * speed(t)
  81.         cx = starx(t): cy = stary(t)
  82.         r = sz(t) + .5
  83.         c = _RGB32(255, 255, 255)
  84.         fillCircle cx, cy, r, c
  85.         'skip:
  86.     NEXT t
  87.     _DISPLAY
  88.     LINE (0, 0)-(_WIDTH, _HEIGHT), _RGB32(0, 0, 0, 20), BF
  89.  
  90. SUB clock
  91.     hours = TIMER \ 3600
  92.     minutes = TIMER \ 60 - hours * 60
  93.     seconds = (TIMER - hours * 3600 - minutes * 60)
  94.     ho$ = LEFT$(TIME$, 2): hou = VAL(ho$)
  95.     min$ = MID$(TIME$, 4, 2): minu = VAL(min$)
  96.     seco$ = RIGHT$(TIME$, 2): secon = VAL(seco$)
  97.     'oldminu = minu
  98.     'Seconds
  99.     s = (60 - seconds) * 6 + 180
  100.     x = INT(SIN(s / 180 * 3.141592) * 125) + 500
  101.     y = INT(COS(s / 180 * 3.141592) * 125) + 400
  102.     FOR b = -5 TO 5 STEP .1
  103.         LINE (500 + b, 400)-(x, y), _RGB32(127, 255, 255)
  104.         LINE (500, 400 + b)-(x, y), _RGB32(127, 255, 255)
  105.     NEXT b
  106.     'Minutes
  107.     m = 180 - minutes * 6
  108.     xx = INT(SIN(m / 180 * 3.141592) * 120) + 500
  109.     yy = INT(COS(m / 180 * 3.141592) * 120) + 400
  110.     FOR b = -5 TO 5 STEP .1
  111.         LINE (500 + b, 400)-(xx, yy), _RGB32(0, 255, 255)
  112.         LINE (500, 400 + b)-(xx, yy), _RGB32(0, 255, 255)
  113.     NEXT b
  114.     'Hours
  115.     h = 360 - hours * 30 + 180
  116.     xxx = INT(SIN(h / 180 * 3.141592) * 90) + 500
  117.     yyy = INT(COS(h / 180 * 3.141592) * 90) + 400
  118.     FOR b = -5 TO 5 STEP .1
  119.         LINE (500 + b, 400)-(xxx, yyy), _RGB32(0, 255, 0)
  120.         LINE (500, 400 + b)-(xxx, yyy), _RGB32(0, 255, 0)
  121.     NEXT b
  122.  
  123.  
  124. 'from Steve Gold standard
  125. SUB fillCircle (CX AS INTEGER, CY AS INTEGER, R AS INTEGER, C AS _UNSIGNED LONG)
  126.     DIM Radius AS INTEGER, RadiusError AS INTEGER
  127.     DIM X AS INTEGER, Y AS INTEGER
  128.     Radius = ABS(R): RadiusError = -Radius: X = Radius: Y = 0
  129.     IF Radius = 0 THEN PSET (CX, CY), C: EXIT SUB
  130.     LINE (CX - X, CY)-(CX + X, CY), C, BF
  131.     WHILE X > Y
  132.         RadiusError = RadiusError + Y * 2 + 1
  133.         IF RadiusError >= 0 THEN
  134.             IF X <> Y + 1 THEN
  135.                 LINE (CX - Y, CY - X)-(CX + Y, CY - X), C, BF
  136.                 LINE (CX - Y, CY + X)-(CX + Y, CY + X), C, BF
  137.             END IF
  138.             X = X - 1
  139.             RadiusError = RadiusError - X * 2
  140.         END IF
  141.         Y = Y + 1
  142.         LINE (CX - X, CY - Y)-(CX + X, CY - Y), C, BF
  143.         LINE (CX - X, CY + Y)-(CX + X, CY + Y), C, BF
  144.     WEND
  145.  
Kens Starfield Clock.jpg
* Kens Starfield Clock.jpg (Filesize: 184.05 KB, Dimensions: 1003x828, Views: 209)
« Last Edit: December 11, 2020, 10:08:19 pm by SierraKen »

Offline STxAxTIC

  • Library Staff
  • Forum Resident
  • Posts: 1091
  • he lives
    • View Profile
Re: Starfield Clock
« Reply #1 on: December 11, 2020, 09:58:07 pm »
Lovely work. I started playing with it, and it was pretty easy to make it into a parametric clock. These hands connect head-to-tail rather than all at the center:

Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(1000, 800, 32)
  2. DIM starx(1000), stary(1000)
  3. DIM dx(1000), dy(1000)
  4. DIM sz(1000)
  5. DIM speed(1000)
  6. DIM col AS LONG
  7. DIM circx AS SINGLE
  8. DIM circy AS SINGLE
  9. _TITLE "Starfield Clock - by SierraKen - Up and down arrow keys (or W and S keys) for speed. Space Bar switches back and forth to Full Screen. Esc to quit."
  10. circ = 360
  11.     _LIMIT 100
  12.     a$ = INKEY$
  13.     IF a$ = CHR$(27) THEN END
  14.     IF a$ = CHR$(0) + CHR$(72) OR a$ = "w" OR a$ = "W" THEN sp = sp + .0005: _TITLE "Warp: " + warp$
  15.     IF a$ = CHR$(0) + CHR$(80) OR a$ = "s" OR a$ = "S" THEN sp = sp - .0005: _TITLE "Warp: " + warp$
  16.     IF a$ = " " THEN f = f + 1
  17.     IF f = 1 THEN _FULLSCREEN: fullscreen = 1
  18.     IF f = 2 THEN _FULLSCREEN OFF: f = 0: fullscreen = 0
  19.  
  20.     'Clock
  21.     clock
  22.     circ = circ - .1
  23.     IF circ < 0 THEN circ = 360
  24.     IF fullscreen = 1 THEN fs = .75: fs2 = 25
  25.     IF fullscreen = 0 THEN fs = 1: fs2 = 0
  26.     circx = (SIN(circ) * (240 - fs2)) + 500
  27.     circy = (COS(circ) * (240 - fs2)) / fs + 400
  28.     col = _RGB32(0, 255, 0)
  29.     cx = circx: cy = circy: c = col
  30.  
  31.     'Chimes
  32.     ho$ = LEFT$(TIME$, 2)
  33.     hou = VAL(ho$)
  34.     min$ = MID$(TIME$, 4, 2)
  35.     minu = VAL(min$)
  36.     seco$ = RIGHT$(TIME$, 2)
  37.     secon = VAL(seco$)
  38.     IF hou > 12 THEN hou = hou - 12
  39.     IF hou = 0 THEN hou = 12
  40.     IF minu = 0 AND secon = 0 AND done = 0 THEN
  41.         FOR chime = 1 TO hou
  42.             PLAY "MB L6 P1 O1 G"
  43.         NEXT chime
  44.         done = 1
  45.     END IF
  46.     IF secon > 0 THEN done = 0
  47.  
  48.     'Starfield
  49.     fillCircle cx, cy, 5, c
  50.     IF sp < .0005 THEN sp = .0005
  51.     IF sp > .1 THEN sp = .1
  52.     warp = (sp * 100) + 1
  53.     IF warp > 10 THEN warp = 10
  54.     warp = INT(warp)
  55.     warp$ = STR$(warp)
  56.     stars = INT(RND * 100) + 1
  57.     IF stars > 25 THEN
  58.         s = s + 1
  59.         IF s > 950 THEN s = 1
  60.         'Set starting position.
  61.         startx = RND * 490
  62.         starty = RND * 390
  63.         st = INT(RND * 360)
  64.         x = (SIN(st) * startx) + 500
  65.         y = (COS(st) * starty) + 400
  66.         starx(s) = x
  67.         stary(s) = y
  68.         'Set direction to move.
  69.         dx(s) = ((x - 500) / 30)
  70.         dy(s) = ((y - 400) / 30)
  71.         'Set size.
  72.         sz(s) = RND
  73.         'Set speed
  74.         speed(s) = .1
  75.     END IF
  76.     IF yy > 640 THEN yy = 0
  77.     FOR t = 1 TO 950
  78.         speed(t) = speed(t) * (1.05 + sp)
  79.         stary(t) = stary(t) + dy(t) * speed(t)
  80.         starx(t) = starx(t) + dx(t) * speed(t)
  81.         cx = starx(t): cy = stary(t)
  82.         r = sz(t) + .5
  83.         c = _RGB32(255, 255, 255)
  84.         fillCircle cx, cy, r, c
  85.         'skip:
  86.     NEXT t
  87.     _DISPLAY
  88.     LINE (0, 0)-(_WIDTH, _HEIGHT), _RGB32(0, 0, 0, 20), BF
  89.  
  90. SUB clock
  91.     hours = TIMER \ 3600
  92.     minutes = TIMER \ 60 - hours * 60
  93.     seconds = (TIMER - hours * 3600 - minutes * 60)
  94.     ho$ = LEFT$(TIME$, 2): hou = VAL(ho$)
  95.     min$ = MID$(TIME$, 4, 2): minu = VAL(min$)
  96.     seco$ = RIGHT$(TIME$, 2): secon = VAL(seco$)
  97.     'oldminu = minu
  98.     'Hours Minutes Seconds
  99.     h = 360 - hours * 30 + 180
  100.     m = 180 - minutes * 6
  101.     s = (60 - seconds) * 6 + 180
  102.     x = _WIDTH / 2 + INT(SIN(h / 180 * 3.141592) * 90)
  103.     y = _HEIGHT / 2 + INT(COS(h / 180 * 3.141592) * 90)
  104.     xx = x + INT(SIN(m / 180 * 3.141592) * 120)
  105.     yy = y + INT(COS(m / 180 * 3.141592) * 120)
  106.     xxx = xx + INT(SIN(s / 180 * 3.141592) * 125)
  107.     yyy = yy + INT(COS(s / 180 * 3.141592) * 125)
  108.     LINE (_WIDTH / 2, _HEIGHT / 2)-(x, y), _RGB32(0, 255, 0)
  109.     LINE (x, y)-(xx, yy), _RGB32(0, 255, 255)
  110.     LINE (xx, yy)-(xxx, yyy), _RGB32(127, 255, 255)
  111.  
  112.  
  113. 'from Steve Gold standard
  114. SUB fillCircle (CX AS INTEGER, CY AS INTEGER, R AS INTEGER, C AS _UNSIGNED LONG)
  115.     DIM Radius AS INTEGER, RadiusError AS INTEGER
  116.     DIM X AS INTEGER, Y AS INTEGER
  117.     Radius = ABS(R): RadiusError = -Radius: X = Radius: Y = 0
  118.     IF Radius = 0 THEN PSET (CX, CY), C: EXIT SUB
  119.     LINE (CX - X, CY)-(CX + X, CY), C, BF
  120.     WHILE X > Y
  121.         RadiusError = RadiusError + Y * 2 + 1
  122.         IF RadiusError >= 0 THEN
  123.             IF X <> Y + 1 THEN
  124.                 LINE (CX - Y, CY - X)-(CX + Y, CY - X), C, BF
  125.                 LINE (CX - Y, CY + X)-(CX + Y, CY + X), C, BF
  126.             END IF
  127.             X = X - 1
  128.             RadiusError = RadiusError - X * 2
  129.         END IF
  130.         Y = Y + 1
  131.         LINE (CX - X, CY - Y)-(CX + X, CY - Y), C, BF
  132.         LINE (CX - X, CY + Y)-(CX + X, CY + Y), C, BF
  133.     WEND
  134.  
  135.  
ss.png
* ss.png (Filesize: 944.83 KB, Dimensions: 1683x829, Views: 189)
You're not done when it works, you're done when it's right.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Starfield Clock
« Reply #2 on: December 11, 2020, 10:04:07 pm »
LOL I kinda see how you did that Static, way cool!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Starfield Clock
« Reply #3 on: December 12, 2020, 12:38:41 pm »
@SierraKen

Great idea to combine Starfield with clock and I like the circles going round.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Starfield Clock
« Reply #4 on: December 12, 2020, 01:09:38 pm »
Thanks B+ :)

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Starfield Clock
« Reply #5 on: December 13, 2020, 01:50:15 pm »
Ken,

I was going to suggest having a "Stardate" clock combined with your star-field.... Until I saw the math involved in converting from real time... Yikes!

I like what you have done! Will it eventually have an 'alarm' and, more importantly, a 'snooze' button?

J
Logic is the beginning of wisdom.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Starfield Clock
« Reply #6 on: December 13, 2020, 02:24:33 pm »
LOL Johnno, the funny thing about Stardates is that the original series mostly did it at random I heard, and the rest of the Star Trek shows did it some other weird way. I tested some websites about it a long time ago and they were all different from each other's outcomes. lol
Hmm I would make an alarm but I don't think I would ever use it. I use a timer program on my computer that beeps after a certain amount of time and I have my alarm in my bedroom and that's all I need. Thanks for the idea though.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Starfield Clock
« Reply #7 on: December 13, 2020, 02:36:19 pm »
LOL Johnno, the funny thing about Stardates is that the original series mostly did it at random I heard, and the rest of the Star Trek shows did it some other weird way. I tested some websites about it a long time ago and they were all different from each other's outcomes. lol
Hmm I would make an alarm but I don't think I would ever use it. I use a timer program on my computer that beeps after a certain amount of time and I have my alarm in my bedroom and that's all I need. Thanks for the idea though.

Stardates were roughly based on seasons of a series...

https://www.mentalfloss.com/article/68741/how-do-star-trek-stardates-work

A stardate is a five-digit number followed by a decimal point and one more digit. Example: "41254.7." The first two digits of the stardate are always "41." The 4 stands for 24th century, the 1 indicates first season. The additional three leading digits will progress unevenly during the course of the season from 000 to 999. The digit following the decimal point is generally regarded as a day counter.


*****

A Stardate is a five-digit number followed by a decimal point and one more digit. Example: "46254.7". The first two digits of the Stardate are "46." The 4 stands for the 24th Century, the 6 indicates sixth season. The following three digits will progress consecutively during the course of the season from 000 to 999. The digit following the decimal point counts tenths of a day. Stardate 45254.4, therefore, represents the noon hour on the 254th "day" of the fifth season. Because Stardates in the 24th Century are based on a complex mathematical formula, a precise correlation to Earth-based dating systems is not possible.



Converting to the latest stardate format of the last films seems simple enough:

The stardate format from the latest film series is credited to screenwriters Roberto Orci and Alex Kurtzman. According to Orci, they "used the system where, for example, 2233.45 or whatever means 23rd century, 33rd year of that century, and the .45 indicates the day of the year out of 365 days." During a Q&A session, Orci restated that a stardate is "the year, as in 2233, with the month and day expressed as a decimal point from .1 to .365 (as in the 365 days of the year)." He posted a similar reply on Twitter: "star date=standard year, with decimal representing day of year from 1-365."

« Last Edit: December 13, 2020, 02:41:04 pm by SMcNeill »
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Starfield Clock
« Reply #8 on: December 13, 2020, 05:26:33 pm »
Thanks Steve. Yeah I agree it's not possible for precise calculation, unless you make up your own way, like they did with the movies. I mean, what about leap year? lol

Offline Dav

  • Forum Resident
  • Posts: 792
    • View Profile
Re: Starfield Clock
« Reply #9 on: December 16, 2020, 09:36:50 am »
Hi @SierraKen.  Your Starfield clock is good enough without this, but Just for the heck of it I tried to do what you asked about in the Holiday thread here.  This one uses one of the sound files in the SPLAY program I posted, so you will need that or change the filename.

  I marked the changes I made in the code with a #Dav tag for easy finding.  Just for fun, I added _ICON _DISPLAY here, instead of just _DISPLAY, so the clock movement shows in the task bar icon, but sometimes the app crashes doing that so I changed it back.  I guess _ICON just isn't meant to be called so frequently.

Anyway, your clock code is great.

- Dav

Edit: I used _SNDPLAYFILE here, but probably _SNDPLAY would be better and not cause that barely visual delay when the sound starts playing. 

Edit #2: Added DIM starx(1000), stary(1000) I left out...

Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(1000, 800, 32)
  2. DIM starx(1000), stary(1000)
  3. DIM dx(1000), dy(1000)
  4. DIM sz(1000)
  5. DIM speed(1000)
  6. DIM col AS LONG
  7. DIM circx AS SINGLE
  8. DIM circy AS SINGLE
  9. _TITLE "Starfield Clock - by SierraKen - Up and down arrow keys (or W and S keys) for speed. Space Bar switches back and forth to Full Screen. Esc to quit."
  10. circ = 360
  11.     _LIMIT 100
  12.     a$ = INKEY$
  13.     IF a$ = CHR$(27) THEN END
  14.     IF a$ = CHR$(0) + CHR$(72) OR a$ = "w" OR a$ = "W" THEN sp = sp + .0005: _TITLE "Warp: " + warp$
  15.     IF a$ = CHR$(0) + CHR$(80) OR a$ = "s" OR a$ = "S" THEN sp = sp - .0005: _TITLE "Warp: " + warp$
  16.     IF a$ = " " THEN f = f + 1
  17.     IF f = 1 THEN _FULLSCREEN: fullscreen = 1
  18.     IF f = 2 THEN _FULLSCREEN OFF: f = 0: fullscreen = 0
  19.  
  20.     'Clock
  21.     clock
  22.     circ = circ - .1
  23.     IF circ < 0 THEN circ = 360
  24.     IF fullscreen = 1 THEN fs = .75: fs2 = 25
  25.     IF fullscreen = 0 THEN fs = 1: fs2 = 0
  26.     circx = (SIN(circ) * (240 - fs2)) + 500
  27.     circy = (COS(circ) * (240 - fs2)) / fs + 400
  28.     col = _RGB32(0, 255, 0)
  29.     cx = circx: cy = circy: c = col
  30.  
  31.     'Chimes
  32.     ho$ = LEFT$(TIME$, 2)
  33.     hou = VAL(ho$)
  34.     min$ = MID$(TIME$, 4, 2)
  35.     minu = VAL(min$)
  36.     seco$ = RIGHT$(TIME$, 2)
  37.     secon = VAL(seco$)
  38.     IF hou > 12 THEN hou = hou - 12
  39.     IF hou = 0 THEN hou = 12
  40.     IF minu = 0 AND secon = 0 AND done = 0 THEN
  41.         'FOR chime = 1 TO hou
  42.         ''PLAY "MB L6 P1 O1 G"
  43.         'NEXT chime
  44.         done = 1
  45.         '====================================== #Dav
  46.         chimeflag = 1 '<<< time to chime flag
  47.         chimetimer = TIMER '<<< start a TIMER
  48.         '===========================================
  49.     END IF
  50.     IF secon > 0 THEN done = 0
  51.  
  52.     '========================================== #Dav
  53.     'plays soundfile chime, if chime flag on
  54.     IF chimeflag = 1 THEN
  55.         'Check chimetimer & TIMER values.
  56.         'Play sound every 1 second, and
  57.         'keep count how many times played.
  58.         IF TIMER - chimetimer > 1 THEN
  59.             'play a chime
  60.             _SNDPLAYFILE "splay/ogg/g1.ogg"
  61.             'add to the count
  62.             chime = chime + 1
  63.             'set a new timer spot
  64.             chimetimer = TIMER
  65.             'If chime count reached, reset chimeflag & count
  66.             IF chime = hou THEN
  67.                 chime = 0
  68.                 chimeflag = 0
  69.             END IF
  70.         END IF
  71.     END IF
  72.     '================================================
  73.  
  74.     'Starfield
  75.     fillCircle cx, cy, 5, c
  76.     IF sp < .0005 THEN sp = .0005
  77.     IF sp > .1 THEN sp = .1
  78.     warp = (sp * 100) + 1
  79.     IF warp > 10 THEN warp = 10
  80.     warp = INT(warp)
  81.     warp$ = STR$(warp)
  82.     stars = INT(RND * 100) + 1
  83.     IF stars > 25 THEN
  84.         s = s + 1
  85.         IF s > 950 THEN s = 1
  86.         'Set starting position.
  87.         startx = RND * 490
  88.         starty = RND * 390
  89.         st = INT(RND * 360)
  90.         x = (SIN(st) * startx) + 500
  91.         y = (COS(st) * starty) + 400
  92.         starx(s) = x
  93.         stary(s) = y
  94.         'Set direction to move.
  95.         dx(s) = ((x - 500) / 30)
  96.         dy(s) = ((y - 400) / 30)
  97.         'Set size.
  98.         sz(s) = RND
  99.         'Set speed
  100.         speed(s) = .1
  101.     END IF
  102.     IF yy > 640 THEN yy = 0
  103.     FOR t = 1 TO 950
  104.         speed(t) = speed(t) * (1.05 + sp)
  105.         stary(t) = stary(t) + dy(t) * speed(t)
  106.         starx(t) = starx(t) + dx(t) * speed(t)
  107.         cx = starx(t): cy = stary(t)
  108.         r = sz(t) + .5
  109.         c = _RGB32(255, 255, 255)
  110.         fillCircle cx, cy, r, c
  111.         'skip:
  112.     NEXT t
  113.     _DISPLAY
  114.     '_ICON _DISPLAY '#Dav
  115.     LINE (0, 0)-(_WIDTH, _HEIGHT), _RGB32(0, 0, 0, 20), BF
  116.  
  117. SUB clock
  118.     hours = TIMER \ 3600
  119.     minutes = TIMER \ 60 - hours * 60
  120.     seconds = (TIMER - hours * 3600 - minutes * 60)
  121.     ho$ = LEFT$(TIME$, 2): hou = VAL(ho$)
  122.     min$ = MID$(TIME$, 4, 2): minu = VAL(min$)
  123.     seco$ = RIGHT$(TIME$, 2): secon = VAL(seco$)
  124.     'oldminu = minu
  125.     'Seconds
  126.     s = (60 - seconds) * 6 + 180
  127.     x = INT(SIN(s / 180 * 3.141592) * 125) + 500
  128.     y = INT(COS(s / 180 * 3.141592) * 125) + 400
  129.     FOR b = -5 TO 5 STEP .1
  130.         LINE (500 + b, 400)-(x, y), _RGB32(127, 255, 255)
  131.         LINE (500, 400 + b)-(x, y), _RGB32(127, 255, 255)
  132.     NEXT b
  133.     'Minutes
  134.     m = 180 - minutes * 6
  135.     xx = INT(SIN(m / 180 * 3.141592) * 120) + 500
  136.     yy = INT(COS(m / 180 * 3.141592) * 120) + 400
  137.     FOR b = -5 TO 5 STEP .1
  138.         LINE (500 + b, 400)-(xx, yy), _RGB32(0, 255, 255)
  139.         LINE (500, 400 + b)-(xx, yy), _RGB32(0, 255, 255)
  140.     NEXT b
  141.     'Hours
  142.     h = 360 - hours * 30 + 180
  143.     xxx = INT(SIN(h / 180 * 3.141592) * 90) + 500
  144.     yyy = INT(COS(h / 180 * 3.141592) * 90) + 400
  145.     FOR b = -5 TO 5 STEP .1
  146.         LINE (500 + b, 400)-(xxx, yyy), _RGB32(0, 255, 0)
  147.         LINE (500, 400 + b)-(xxx, yyy), _RGB32(0, 255, 0)
  148.     NEXT b
  149.  
  150.  
  151. 'from Steve Gold standard
  152. SUB fillCircle (CX AS INTEGER, CY AS INTEGER, R AS INTEGER, C AS _UNSIGNED LONG)
  153.     DIM Radius AS INTEGER, RadiusError AS INTEGER
  154.     DIM X AS INTEGER, Y AS INTEGER
  155.     Radius = ABS(R): RadiusError = -Radius: X = Radius: Y = 0
  156.     IF Radius = 0 THEN PSET (CX, CY), C: EXIT SUB
  157.     LINE (CX - X, CY)-(CX + X, CY), C, BF
  158.     WHILE X > Y
  159.         RadiusError = RadiusError + Y * 2 + 1
  160.         IF RadiusError >= 0 THEN
  161.             IF X <> Y + 1 THEN
  162.                 LINE (CX - Y, CY - X)-(CX + Y, CY - X), C, BF
  163.                 LINE (CX - Y, CY + X)-(CX + Y, CY + X), C, BF
  164.             END IF
  165.             X = X - 1
  166.             RadiusError = RadiusError - X * 2
  167.         END IF
  168.         Y = Y + 1
  169.         LINE (CX - X, CY - Y)-(CX + X, CY - Y), C, BF
  170.         LINE (CX - X, CY + Y)-(CX + X, CY + Y), C, BF
  171.     WEND
  172.  
 
« Last Edit: December 16, 2020, 01:21:13 pm by Dav »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Starfield Clock
« Reply #10 on: December 16, 2020, 12:05:15 pm »
Dang just missed 12 noon chime!

Someone forgot to get starx, stary dimensioned.

Oh this wont work either
Code: QB64: [Select]
  1.  hou = 12: minu = 0: secon = 0

Missing sound files. :P
« Last Edit: December 16, 2020, 12:09:39 pm by bplus »

Marked as best answer by SierraKen on December 16, 2020, 08:13:00 am

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Starfield Clock
« Reply #11 on: December 16, 2020, 01:11:03 pm »
Dang Dav that's genius! I was close, but not close enough. :) One thing though, for some reason you left out 2 DIM statements which errors the program on running it. It's these on top: DIM starx(1000), stary(1000) , so I put them back in.

B+, and anyone else, if you want to test the chimes at any time, first calculate how far back in minutes it was until the last hour, for example, if it is 9:51 AM, use the number 52. Then add this on LINE 49: minu = minu - 52. Then it will chime when the clock strikes the next minute. Or it might be better to use the number 53 (2 numbers higher than the current minute), so the clock thinks it's 2 minutes before the hour it already is. Then you run it and wait less than 2 minutes and then it will chime.

Here is the zipped up file with the g1.ogg and the program. Put both files in the same directory. I renamed it to Starfield Clock 2. Thanks again Dav!





* Starfield Clock 2.zip (Filesize: 29.7 KB, Downloads: 168)
« Last Edit: December 16, 2020, 03:44:17 pm by SierraKen »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Starfield Clock
« Reply #12 on: December 16, 2020, 03:23:45 pm »

 Dang! the ogg must be in same folder as source, Explorer dies!
« Last Edit: December 16, 2020, 03:27:06 pm by bplus »

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Starfield Clock
« Reply #13 on: December 16, 2020, 03:43:30 pm »
Sorry B+, I thought people would know to put all files in the same directory. But yeah, I changed his code to mine because not all people will get his Christmas song. 
Edit: I just added that to the post above for people to put both files in the same directory.
« Last Edit: December 16, 2020, 03:44:51 pm by SierraKen »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Starfield Clock
« Reply #14 on: December 16, 2020, 03:45:56 pm »
Normally (without oggs) that should be fine, teaches me to be more careful in future.

Time to build a File Explorer of my own anyway!