Author Topic: Navy Time  (Read 4609 times)

0 Members and 1 Guest are viewing this topic.

Offline Richard Frost

  • Seasoned Forum Regular
  • Posts: 316
  • Needle nardle noo. - Peter Sellers
    • View Profile
Navy Time
« on: February 26, 2020, 08:24:41 pm »
Yarrr.  Ahoy.  A clock for Captain Fishsticks.

Code: QB64: [Select]
  1. _TITLE "Navy Time"
  2. $EXEICON:'boat2.ico'
  3.  
  4. DEFINT A-Z
  5. DIM a(11, 1)
  6. SCREEN 12 '                                           640*480*16
  7. FOR i = 1 TO 11: READ t$, a(i, 0), a(i, 1): NEXT i '  angles
  8. q = 41: q2 = 16
  9. man = 1: w$ = SPACE$(6)
  10.  
  11. begin:
  12. t$ = TIME$
  13. MID$(t$, 3) = " ": MID$(t$, 6) = " " '                no colons in military time
  14. t2$ = t$
  15. LOCATE 28, 37: PRINT t$;
  16. t$ = MID$(t$, 1, 2) + MID$(t$, 4, 2) + MID$(t$, 7, 2)
  17. FOR i = 6 TO 1 STEP -1
  18.     c$ = MID$(t$, i, 1): lc$ = MID$(w$, i, 1)
  19.     IF c$ = lc$ THEN EXIT FOR '                       unchanged digit
  20.     dx = INSTR("1234567890", c$) - (c$ = "0")
  21.     IF ctype = 0 THEN
  22.         x1 = 60 + (i - 1) * 104: y1 = 200
  23.         LINE (x1 - 52, 150)-(x1 + 52, 250), 0, BF
  24.     ELSE
  25.         x1 = 230 + ((i - 1) MOD 2) * 160
  26.         y1 = 80 + ((i - 1) \ 2) * 140
  27.         LINE (x1 - 80, y1 - 60)-(x1 + 80, y1 + 60), 0, BF
  28.     END IF
  29.     FOR j = 0 TO 1
  30.         de = a(dx, j) - 90 '                          degrees
  31.         IF man THEN
  32.             CIRCLE (x1, y1 - 6), 4, 15
  33.             LINE (x1 - 6, y1)-(x1 + 6, y1 + 20), 15, B
  34.         END IF
  35.         x2 = x1 + (j - .5) * (20 - (ctype = 1) * 20)
  36.         x3 = x2 + q * COS(_D2R(de))
  37.         y2 = y1 + q * SIN(_D2R(de))
  38.         LINE (x2, y1)-(x3, y2), 15 '                  arms
  39.         IF j = 0 THEN s = 1 ELSE s = -1
  40.         IF (j = 1) AND (INSTR("89", c$)) THEN s = -s
  41.         FOR a = 1 TO 3 '                              flags
  42.             de = de - 90 * s
  43.             x4 = x3 + q2 * COS(_D2R(de))
  44.             y4 = y2 + q2 * SIN(_D2R(de))
  45.             LINE -(x4, y4), 15
  46.             IF a = 1 THEN '                           save for diagonal
  47.                 sx = x4: sy = y4
  48.                 td = de - 45 * s
  49.                 rx = x3 + (q2 \ 2) * COS(_D2R(td)) '  to paint red
  50.                 ry = y2 + (q2 \ 2) * SIN(_D2R(td))
  51.             END IF
  52.             IF a = 3 THEN
  53.                 td = de - 45 * s
  54.                 yx = x3 + (q2 \ 2) * COS(_D2R(td)) '  to paint yellow
  55.                 yy = y2 + (q2 \ 2) * SIN(_D2R(td))
  56.             END IF
  57.             x3 = x4: y2 = y4
  58.         NEXT a
  59.         LINE -(sx, sy), 15 '                          diagonal
  60.         PAINT (rx, ry), 4, 15 '                       red
  61.         PAINT (yx, yy), 14, 15 '                      yellow
  62.     NEXT j
  63. w$ = t$ '                                             was
  64.     i$ = INKEY$
  65.     IF LEN(i$) THEN
  66.         IF INSTR(CHR$(13) + " bm", i$) THEN man = 1 - man: w$ = SPACE$(6)
  67.         IF i$ = "t" THEN '                            3 rows of 2
  68.             ctype = ctype XOR 1
  69.             IF ctype = 0 THEN
  70.                 q = 41: q2 = 16
  71.             ELSE
  72.                 q = 58: q2 = 24
  73.             END IF
  74.             CLS: w$ = SPACE$(6)
  75.         END IF
  76.         IF i$ = CHR$(27) THEN END '                   Esc to quit
  77.     END IF
  78. GOTO begin
  79.  
  80. DATA 1,225,180,2,270,180,3,315,180,4,0,180,5,180,45,6,180,90
  81. DATA 7,180,135,8,270,225,9,225,315,j,0,90,0,225,0
  82.  

* boat2.ico (Filesize: 16.56 KB, Dimensions: 64x64, Views: 458)
It works better if you plug it in.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Navy Time
« Reply #1 on: February 26, 2020, 08:56:13 pm »
reply message:
 
reply to r Frost.PNG


Hey but yours are hand drawn, very cool!
« Last Edit: February 26, 2020, 09:13:57 pm by bplus »

Offline Richard Frost

  • Seasoned Forum Regular
  • Posts: 316
  • Needle nardle noo. - Peter Sellers
    • View Profile
Re: Navy Time with Date
« Reply #2 on: February 26, 2020, 09:16:21 pm »
Since someone asked for a version with a date, here she be.

Yarrr.  The format B+ came up with is much prettier.  I will consult a genetic enginner,
get me some graphics designer genes.

Code: QB64: [Select]
  1. _TITLE "Navy Time" '                                  with date
  2. $EXEICON:'boat2.ico'
  3.  
  4. DEFINT A-Z
  5. DIM a(11, 1)
  6. SCREEN 12 '                                           640*480*16
  7. FOR i = 1 TO 11: READ t$, a(i, 0), a(i, 1): NEXT i '  angles
  8. q = 28: q2 = 14
  9. man = 1: w$ = SPACE$(6)
  10.  
  11. begin:
  12. FOR pass = 0 TO 1
  13.     IF pass THEN t$ = TIME$ ELSE t$ = DATE$
  14.     t$ = LEFT$(t$, 2) + MID$(t$, 4, 2) + MID$(t$, 7, 4 - pass * 2)
  15.     LOCATE 26 + pass * 2, 40 - LEN(t$) \ 2: PRINT t$;
  16.     FOR i = 1 TO LEN(t$)
  17.         c$ = MID$(t$, i, 1)
  18.         dx = INSTR("1234567890", c$) - (c$ = "0")
  19.         x1 = 40 + (i - 1) * 80 + pass * 72
  20.         y1 = 160 + pass * 120
  21.         FOR j = 0 TO 1
  22.             de = a(dx, j) - 90 '                          degrees
  23.             IF man THEN
  24.                 CIRCLE (x1, y1 - 6), 4, 7
  25.                 LINE (x1 - 3, y1)-(x1 + 3, y1 + 20), 7, B
  26.             END IF
  27.             x2 = x1 + (j - .5) * 20
  28.             x3 = x2 + q * COS(_D2R(de))
  29.             y2 = y1 + q * SIN(_D2R(de))
  30.             LINE (x2, y1)-(x3, y2), 15 '                  arms
  31.             IF j = 0 THEN s = 1 ELSE s = -1
  32.             IF (j = 1) AND (INSTR("89", c$)) THEN s = -s
  33.             FOR a = 1 TO 3 '                              flags
  34.                 de = de - 90 * s
  35.                 x4 = x3 + q2 * COS(_D2R(de))
  36.                 y4 = y2 + q2 * SIN(_D2R(de))
  37.                 LINE -(x4, y4), 15
  38.                 IF a = 1 THEN '                           save for diagonal
  39.                     sx = x4: sy = y4
  40.                     td = de - 45 * s
  41.                     rx = x3 + (q2 \ 2) * COS(_D2R(td)) '  to paint red
  42.                     ry = y2 + (q2 \ 2) * SIN(_D2R(td))
  43.                 END IF
  44.                 IF a = 3 THEN
  45.                     td = de - 45 * s
  46.                     yx = x3 + (q2 \ 2) * COS(_D2R(td)) '  to paint yellow
  47.                     yy = y2 + (q2 \ 2) * SIN(_D2R(td))
  48.                 END IF
  49.                 x3 = x4: y2 = y4
  50.             NEXT a
  51.             LINE -(sx, sy), 15 '                          diagonal
  52.             PAINT (rx, ry), 4, 15 '                       red
  53.             PAINT (yx, yy), 14, 15 '                      yellow
  54.         NEXT j
  55.     NEXT i
  56. NEXT pass
  57.  
  58.  
  59. t$ = TIME$
  60.     i$ = INKEY$
  61.     IF LEN(i$) THEN
  62.         IF INSTR(CHR$(13) + " bm", i$) THEN man = 1 - man: w$ = SPACE$(6)
  63.         IF i$ = CHR$(27) THEN END '                   Esc to quit
  64.     END IF
  65. GOTO begin
  66.  
  67. DATA 1,225,180,2,270,180,3,315,180,4,0,180,5,180,45,6,180,90
  68. DATA 7,180,135,8,270,225,9,225,315,j,0,90,0,225,0
  69.  
It works better if you plug it in.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Navy Time
« Reply #3 on: February 26, 2020, 09:19:03 pm »
B+ just modified [banned user]'s code and images, thanks [banned user]!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Navy Time
« Reply #4 on: February 27, 2020, 11:04:25 am »
Have you guys considered putting a space between digits or flag a space signal as Date and Time are normally formatted?
« Last Edit: February 27, 2020, 11:05:26 am by bplus »

Offline Richard Frost

  • Seasoned Forum Regular
  • Posts: 316
  • Needle nardle noo. - Peter Sellers
    • View Profile
Re: Navy Time
« Reply #5 on: February 27, 2020, 11:14:32 am »
Nice change, [banned user], but a primary responsibility of a signalman is to smack himself in the nose. 

Spaces between digits would necessitate smaller critters, and I'll have to put on my glasses.  The
original version does have the option to tell time with 3 rows of 2 characters each - "t".

T.  T is for turtle.  - Officer Barbrady, Southpark, on seeing Cartman crucified
It works better if you plug it in.

Offline Richard Frost

  • Seasoned Forum Regular
  • Posts: 316
  • Needle nardle noo. - Peter Sellers
    • View Profile
Re: Navy Time
« Reply #6 on: February 27, 2020, 11:18:28 am »
Wut?
ccr.JPG
* ccr.JPG (Filesize: 24.06 KB, Dimensions: 625x467, Views: 234)
It works better if you plug it in.