Author Topic: Beyond Sol  (Read 11858 times)

0 Members and 1 Guest are viewing this topic.

Offline romichess

  • Forum Regular
  • Posts: 145
    • View Profile
Re: Beyond Sol
« Reply #15 on: December 16, 2019, 11:54:16 pm »
It is enough better to make a new post.

Press:
esc to quit
p to pause/unpause
t toggles star name and production value
n for new game

Click:
on a blue planet then any planet to send ships
on numbers to select number of ships
on OK to send ships
on QUIT to cancel send
on CLEAR to start over selecting number of ships
can only click on second planet if range line is green
if range line is red second planet is out of range

I think that is all actions for now.

Code: QB64: [Select]
  1. TYPE stars
  2.     n AS STRING * 10 '                 Name of star
  3.     x AS INTEGER '                     x-position
  4.     y AS INTEGER '                     y-position
  5.     o AS INTEGER '                     Owner
  6.     c AS INTEGER '                     Color
  7.     s AS INTEGER '                     Size
  8.     t AS LONG '                     (Type of planetary system; terran, frozen, radiated, toxic, etc.) Ships
  9.     p AS INTEGER '                     (Population) For now ships produced per turn
  10.  
  11. TYPE FLEETS
  12.     t AS LONG
  13.     x1 AS INTEGER
  14.     y1 AS INTEGER
  15.     x2 AS INTEGER
  16.     y2 AS INTEGER
  17.     o AS INTEGER
  18.     d AS INTEGER
  19.  
  20. 'DECLARE SUB NewGame
  21. 'DECLARE SUB PaintStars
  22. 'DECLARE SUB StarNames
  23. 'DECLARE SUB ShowPanel (i)
  24. 'DECLARE SUB Identify (x, y)
  25. 'DECLARE SUB PaintBackground
  26. 'DECLARE SUB GetInput
  27.  
  28. ' Global variables shared because they are needed in more than one routine
  29. DIM SHARED sw AS INTEGER '             Screen Width
  30. DIM SHARED sh AS INTEGER '             Screen Height
  31. DIM SHARED sww AS INTEGER '            Screen Width Wide margin
  32. DIM SHARED swn AS INTEGER '            Screen Width Narrow adjustment
  33. DIM SHARED shw AS INTEGER '            Screen Height Wide margine
  34. DIM SHARED shn AS INTEGER '            Screen Height Narrow adjustment
  35. DIM SHARED nw AS INTEGER '             games Natural screen Width
  36. DIM SHARED nh AS INTEGER '             games Natural screen Height
  37. DIM SHARED ratio AS _FLOAT '           the Ratio of the games natural screen width to the actual
  38. DIM SHARED star(100) AS stars '        100 stars - may change
  39. DIM SHARED names(200) AS STRING * 10 ' 200 star names
  40. DIM SHARED seed AS INTEGER '           Seed to prime the Randomizer to display identical background each frame
  41. DIM SHARED home(7) AS INTEGER '        The starting star for each player. The human always has star(0), Sol
  42. DIM SHARED tt AS INTEGER '             tt = 0 star names displayed, tt = 0 star names not didplayed
  43. DIM SHARED ch AS STRING * 1 '          Game loop key input variable
  44. DIM SHARED repeat AS INTEGER '         Game loop control variable
  45. DIM SHARED fleet(1000) AS FLEETS
  46. DIM SHARED srcstr AS STRING * 10
  47. DIM SHARED dststr AS STRING * 10
  48. DIM SHARED panx, pany AS INTEGER
  49. DIM SHARED strng AS STRING * 10
  50. DIM SHARED hate(7, 7) AS INTEGER
  51.  
  52. sw = _DESKTOPWIDTH '                   native video with of syatem
  53. sww = sw / 24 '                        margin based on native video width to keep stars away from edge
  54. swn = sw / 48 '                        adjustment that works with sww to keep stars away from left and top of screen
  55. nw = 1920
  56.  
  57. ratio = sw / 1920 '                    Used to adjust distances and sizes for various screen modes
  58.  
  59. shw = sh / 20
  60. shn = sh / 40
  61. nh = 1080
  62.  
  63. tt = 0
  64. cx = sw
  65. cp = 100
  66. h = 100
  67. ar = 0
  68. rng = 200
  69. slct = 0
  70. strng = ""
  71.  
  72. SCREEN _NEWIMAGE(sw, sh, 256) '        creates a screen the resolution of the users native system
  73.  
  74.  
  75. ps = _NEWIMAGE(400 * ratio, 540 * ratio, 256)
  76.  
  77. StarNames '                            Routine to load star names into string array stars(200)
  78.  
  79. NewGame
  80.  
  81. ttf1 = _LOADFONT("cyberbit.ttf", 16 * ratio, "BOLD")
  82. ttf2 = _LOADFONT("cyberbit.ttf", 72 * ratio, "BOLD")
  83.  
  84. repeat = 1
  85.  
  86. WHILE repeat
  87.  
  88.     _LIMIT 200 '                        Set to 200 frames per second
  89.  
  90.     id = INT(RND * 5 + 2)
  91.  
  92.     CLS
  93.  
  94.     PaintBackground
  95.  
  96.     PaintStars
  97.  
  98.     PaintFleet
  99.  
  100.     GetInput
  101.  
  102.     Identify x, y '                     Identify star mouse is over if any
  103.  
  104.     Player
  105.  
  106.     Computer
  107.  
  108.     _DISPLAY
  109.  
  110.  
  111.  
  112. SUB PaintFleet
  113.     count = fltcnt
  114.     i = 0
  115.     WHILE count
  116.         IF fleet(i).o <> 0 THEN
  117.             CIRCLE (fleet(i).x1, fleet(i).y1), 3, fleet(i).o + 8
  118.             count = count - 1
  119.         END IF
  120.         i = i + 1
  121.     WEND
  122.  
  123. SUB SendFleet (org, dst, ships)
  124.     FOR i = 0 TO 999
  125.         IF fleet(i).o = 0 THEN
  126.             fleet(i).o = star(org).o
  127.             fleet(i).d = dst
  128.             fleet(i).x1 = star(org).x
  129.             fleet(i).y1 = star(org).y
  130.             fleet(i).x2 = star(dst).x
  131.             fleet(i).y2 = star(dst).y
  132.             fleet(i).t = ships
  133.             star(org).t = star(org).t - ships
  134.             fltcnt = fltcnt + 1
  135.             EXIT FOR
  136.         END IF
  137.     NEXT
  138.     LL = LL + 1
  139.  
  140. SUB Computer
  141.     FOR i = 0 TO 99
  142.         r = INT(RND * 60)
  143.         IF r < star(i).p THEN
  144.             IF star(i).o > 0 THEN
  145.                 star(i).t = star(i).t + 1
  146.             ELSE
  147.                 IF INT(RND * 10) < 3 THEN
  148.                     star(i).t = star(i).t + 1
  149.                 END IF
  150.             END IF
  151.         END IF
  152.     NEXT
  153.  
  154.     org = home(id)
  155.     IF star(org).o <> id THEN
  156.         FOR j = 0 TO 99
  157.             IF star(j).o = id THEN home(id) = j: EXIT FOR
  158.         NEXT
  159.     END IF
  160.  
  161.     FOR p = 0 TO 3
  162.  
  163.         IF p = 0 THEN
  164.             sf2 = 100
  165.             sf1 = home(id)
  166.             IF star(sf1).t > LL * 2 THEN
  167.                 sf3 = star(sf1).t / 2
  168.                 g = -1
  169.                 FOR j = 0 TO 99
  170.                     IF star(j).o <> id THEN
  171.                         IF hate(id, star(j).o) > g THEN
  172.                             IF star(sf1).t > star(j).t * 5 + RND * 200 - 100 THEN
  173.                                 FOR k = 0 TO 99
  174.                                     IF star(k).o = id THEN
  175.                                         dist = SQR(ABS(star(k).x - star(j).x) ^ 2 + ABS(star(k).y - star(j).y) ^ 2)
  176.                                         IF dist <= 250 * ratio THEN
  177.                                             sf2 = j
  178.                                             g = hate(id, star(j).o)
  179.                                             EXIT FOR
  180.                                         END IF
  181.                                     END IF
  182.                                 NEXT
  183.                             END IF
  184.                         END IF
  185.                     END IF
  186.                     IF g = h THEN EXIT FOR
  187.                 NEXT
  188.                 IF sf2 < 100 THEN
  189.                     SendFleet sf1, sf2, sf3
  190.                     sf2 = 100
  191.                     EXIT FOR
  192.                 END IF
  193.             END IF
  194.         END IF
  195.  
  196.         IF p = 1 THEN
  197.             ok = 0
  198.             FOR i = 1 TO 99
  199.                 IF i <> home(id) AND star(i).o = id THEN
  200.                     IF star(i).t > LL * 1.5 THEN
  201.                         ok = 1
  202.                         EXIT FOR
  203.                     END IF
  204.                 END IF
  205.             NEXT
  206.             IF ok = 1 THEN
  207.                 SendFleet i, home(id), star(i).t / 4
  208.                 EXIT FOR
  209.             END IF
  210.         END IF
  211.  
  212.         IF p = 2 THEN
  213.             FOR i = 1 TO 99
  214.                 IF i <> home(id) AND star(i).o = id THEN
  215.                     IF star(i).t > 49 THEN
  216.                         ok = 1
  217.                         FOR j = 0 TO 99
  218.                             IF star(j).o <> id AND star(j).o <> 0 THEN
  219.                                 dist = SQR(ABS(star(i).x - star(j).x) ^ 2 + ABS(star(i).y - star(j).y) ^ 2)
  220.                                 IF dist <= 350 * ratio THEN
  221.                                     ok = 0
  222.                                     EXIT FOR
  223.                                 END IF
  224.                             END IF
  225.                         NEXT
  226.                         IF ok = 1 THEN
  227.                             SendFleet i, home(id), star(i).t
  228.                             EXIT FOR
  229.                         END IF
  230.                     END IF
  231.                 END IF
  232.             NEXT
  233.             IF ok = 1 THEN EXIT FOR
  234.         END IF
  235.  
  236.         IF p = 3 THEN
  237.             sf2 = 100
  238.             FOR i = 0 TO 99
  239.                 IF star(i).o = id AND star(i).t > LL * 1.5 THEN
  240.                     sf3 = star(i).t / 2
  241.                     FOR j = 0 TO 99
  242.                         IF star(j).o <> id AND star(i).t > star(j).t * 4 THEN
  243.                             FOR k = 0 TO 99
  244.                                 IF star(k).o = id THEN
  245.                                     dist = SQR(ABS(star(k).x - star(j).x) ^ 2 + ABS(star(k).y - star(j).y) ^ 2)
  246.                                     IF dist <= 250 * ratio THEN
  247.                                         sf1 = i
  248.                                         sf2 = j
  249.                                         g = hate(id, star(j).o)
  250.                                         EXIT FOR
  251.                                     END IF
  252.                                 END IF
  253.                             NEXT
  254.                         END IF
  255.                     NEXT
  256.                     IF g = h THEN EXIT FOR
  257.                 END IF
  258.             NEXT
  259.             IF sf2 < 100 THEN
  260.                 SendFleet sf1, sf2, sf3
  261.                 sf2 = 100
  262.                 EXIT FOR
  263.             END IF
  264.         END IF
  265.  
  266.     NEXT
  267.  
  268.     GetInput
  269.  
  270.     Identify x, y '                     Identify star mouse is over if any
  271.  
  272.     count = fltcnt
  273.     i = 0
  274.     WHILE count
  275.         IF fleet(i).o <> 0 THEN
  276.             count = count - 1
  277.             IF fleet(i).x2 > fleet(i).x1 THEN
  278.                 fleet(i).x1 = fleet(i).x1 + 1
  279.             END IF
  280.             IF fleet(i).x2 < fleet(i).x1 THEN
  281.                 fleet(i).x1 = fleet(i).x1 - 1
  282.             END IF
  283.             IF fleet(i).y2 > fleet(i).y1 THEN
  284.                 fleet(i).y1 = fleet(i).y1 + 1
  285.             END IF
  286.             IF fleet(i).y2 < fleet(i).y1 THEN
  287.                 fleet(i).y1 = fleet(i).y1 - 1
  288.             END IF
  289.             IF fleet(i).x1 = fleet(i).x2 AND fleet(i).y1 = fleet(i).y2 THEN
  290.                 dst = fleet(i).d
  291.                 IF star(dst).o = fleet(i).o THEN
  292.                     star(dst).t = star(dst).t + fleet(i).t
  293.                     fleet(i).o = 0
  294.                     fltcnt = fltcnt - 1
  295.                 ELSE
  296.                     IF fleet(i).t > star(dst).t * 1.1 THEN
  297.                         alive = 1
  298.                         WHILE alive
  299.                             alive = 0
  300.                             damorg = fleet(i).t / 11 + 1
  301.                             damdst = star(dst).t / 10 + 1
  302.                             fleet(i).t = fleet(i).t - damdst
  303.                             star(dst).t = star(dst).t - damorg
  304.                             IF fleet(i).t > 0 AND star(dst).t > 0 THEN
  305.                                 alive = 1
  306.                             END IF
  307.                         WEND
  308.                         IF star(dst).t < 1 THEN
  309.                             hate(star(dst).o, fleet(i).o) = hate(star(dst).o, fleet(i).o) + 1
  310.                             star(dst).t = fleet(i).t
  311.                             star(dst).o = fleet(i).o
  312.                         END IF
  313.                         fleet(i).o = 0
  314.                         fltcnt = fltcnt - 1
  315.                     ELSE
  316.                         k = 100
  317.                         shortest = 10000
  318.                         FOR j = 0 TO 99
  319.                             IF star(j).o = fleet(i).o THEN
  320.                                 dist = SQR(ABS(star(j).x - fleet(i).x1) ^ 2 + ABS(star(j).y - fleet(i).y1) ^ 2)
  321.                                 IF dist < shortest THEN
  322.                                     shortest = dist
  323.                                     k = j
  324.                                 END IF
  325.                             END IF
  326.                         NEXT
  327.                         IF k < 100 THEN
  328.                             fleet(i).x2 = star(k).x
  329.                             fleet(i).y2 = star(k).y
  330.                             fleet(i).d = k
  331.                         END IF
  332.                     END IF
  333.                 END IF
  334.             END IF
  335.         END IF
  336.         i = i + 1
  337.     WEND
  338.  
  339. SUB GetInput
  340.  
  341.     ch = INKEY$
  342.     IF ch = CHR$(27) THEN repeat = 0
  343.     IF ch = "n" THEN NewGame
  344.     IF ch = "t" THEN tt = 1 - tt
  345.     IF ch = "p" THEN pause = 1
  346.  
  347.     WHILE (pause = 1)
  348.         IF INKEY$ = "p" THEN
  349.             pause = 0
  350.         END IF
  351.     WEND
  352.  
  353.     WHILE _MOUSEINPUT: WEND '          Eat all the mice but keep last mouse to toy with
  354.  
  355.     x = _MOUSEX
  356.     y = _MOUSEY
  357.     mb = _MOUSEBUTTON(1)
  358.     clk = 0
  359.  
  360.     IF mb = -1 AND cx = sw THEN
  361.         cx = x
  362.         cy = y
  363.     END IF
  364.  
  365.     IF mb = 0 AND cx < sw THEN
  366.         IF ABS(x - cx) < 9 AND ABS(y - cy) < 9 THEN
  367.             clk = 1
  368.         END IF
  369.         cx = sw
  370.     END IF
  371.  
  372. SUB PaintBackground
  373.     x = RND * sw
  374.     y = RND * sh
  375.     c = RND * 14 + 1
  376.     PSET (x, y), c
  377.     RANDOMIZE USING seed
  378.     FOR i = 1 TO 600 * ratio
  379.         x = RND * sw
  380.         y = RND * sh
  381.         c = RND * 14 + 1
  382.         PSET (x, y), c
  383.     NEXT
  384.  
  385. SUB Player
  386.     tmp$ = RTRIM$(strng)
  387.     IF slct = 1 THEN
  388.         nclk = 1
  389.         FOR i = 0 TO 99
  390.             IF star(i).o = 1 THEN
  391.                 dist = SQR(ABS(star(i).x - x) ^ 2 + ABS(star(i).y - y) ^ 2)
  392.                 IF dist <= 200 * ratio THEN
  393.                     nclk = 0
  394.                     EXIT FOR
  395.                 END IF
  396.             END IF
  397.         NEXT
  398.         c = 10
  399.         IF nclk = 1 THEN
  400.             c = 12
  401.             clk = 0
  402.         END IF
  403.         LINE (px, py)-(x, y), c
  404.         EXIT SUB
  405.     END IF
  406.     IF pact = 1 THEN
  407.         ShowPanel ii
  408.         IF clk = 1 THEN
  409.             x1 = panx: x2 = panx + 400 * ratio
  410.             y1 = pany: y2 = pany + 540 * ratio
  411.             IF x > x1 + 216 * ratio AND x < x1 + 366 * ratio AND y > y1 + 460 * ratio AND y < y1 + 530 * ratio THEN
  412.                 pact = 0
  413.             ELSE IF x > x1 + 20 * ratio AND x < x1 + 380 * ratio AND y > y1 + 260 * ratio AND y < y1 + 320 * ratio THEN
  414.                     dig = (x - x1 - 32 * ratio) / (38 * ratio)
  415.                     strng = tmp$ + STR$(dig)
  416.                 ELSE IF x > x1 + 266 * ratio AND x < x1 + 366 * ratio AND y > y1 + 366 * ratio AND y < y1 + 406 * ratio THEN
  417.                         strng = ""
  418.                     ELSE IF x > x1 + 32 * ratio AND x < x1 + 182 * ratio AND y > y1 + 460 * ratio AND y < y1 + 530 * ratio THEN
  419.                             value = VAL(strng)
  420.                             strng = ""
  421.                             pact = 0
  422.                             IF value <= star(srcidx).t THEN
  423.                                 SendFleet srcidx, dstidx, value
  424.                             END IF
  425.                         END IF
  426.                     END IF
  427.                 END IF
  428.             END IF
  429.         END IF
  430.     END IF
  431.  
  432. SUB Identify (x, y)
  433.     IF nclk = 0 THEN
  434.         FOR i = 0 TO 99
  435.             dx = star(i).x - x
  436.             dy = star(i).y - y
  437.             IF pact = 0 AND ABS(dx) <= star(i).s + 8 AND ABS(dy) <= star(i).s + 8 THEN
  438.                 ii = i
  439.                 IF star(i).o = 1 AND slct = 0 THEN
  440.                     IF clk THEN
  441.                         slct = 1
  442.                     END IF
  443.                     px = x
  444.                     py = y
  445.                     srcstr = star(i).n
  446.                     srcidx = i
  447.                 ELSE
  448.                     IF slct = 1 OR pact = 1 THEN
  449.                         IF clk THEN
  450.                             slct = 0
  451.                             pact = 1
  452.                             dststr = star(i).n
  453.                             dstidx = i
  454.                         END IF
  455.                     END IF
  456.                 END IF
  457.                 EXIT FOR
  458.             END IF
  459.         NEXT
  460.     END IF
  461.  
  462. SUB ShowPanel (i)
  463.     x1 = star(i).x - 420 * ratio
  464.     IF star(i).x < sw / 2 THEN x1 = star(i).x + 20 * ratio
  465.     x2 = x1 + 400 * ratio
  466.     y1 = star(i).y
  467.     IF y1 > sh - 560 * ratio THEN y1 = sh - 560 * ratio
  468.     y2 = y1 + 540 * ratio
  469.     _DEST ps
  470.     CLS 0, 8
  471.     COLOR 0, 8
  472.     _FONT ttf2
  473.     n$ = RTRIM$(srcstr)
  474.     L = _PRINTWIDTH(n$)
  475.     _PRINTSTRING ((400 * ratio - L) / 2, 8 * ratio), n$, ps
  476.     n$ = "to"
  477.     L = _PRINTWIDTH(n$)
  478.     _PRINTSTRING ((400 * ratio - L) / 2, 80 * ratio), n$, ps
  479.     n$ = RTRIM$(dststr)
  480.     L = _PRINTWIDTH(n$)
  481.     _PRINTSTRING ((400 * ratio - L) / 2, 152 * ratio), n$, ps
  482.     LINE (20 * ratio, 240 * ratio)-(380 * ratio, 240 * ratio), 0
  483.     _PRINTSTRING (20 * ratio, 260 * ratio), "0123456789", ps
  484.     _PRINTSTRING (20 * ratio, 346 * ratio), strng, ps
  485.     xo = 286 * ratio: xd = 366 * ratio: yo = 366 * ratio: yd = 406 * ratio
  486.     LINE (xo, yo)-(xd, yd), 7, BF
  487.     xo = 32 * ratio: xd = 182 * ratio: yo = 458 * ratio: yd = 530 * ratio
  488.     LINE (xo, yo)-(xd, yd), 7, BF
  489.     xo = 216 * ratio: xd = 366 * ratio: yo = 458 * ratio: yd = 530 * ratio
  490.     LINE (xo, yo)-(xd, yd), 7, BF
  491.     _FONT ttf1
  492.     COLOR 7, 8
  493.     _PRINTSTRING (100 * ratio, 112 * ratio), STR$(star(srcidx).t), ps
  494.     _PRINTSTRING (270 * ratio, 112 * ratio), STR$(star(dstidx).t), ps
  495.     COLOR 0, 7
  496.     _PRINTSTRING (300 * ratio, 380 * ratio), "CLEAR", ps
  497.     _FONT ttf2
  498.     _PRINTSTRING (60 * ratio, 458 * ratio), "Ok", ps
  499.     _PRINTSTRING (220 * ratio, 458 * ratio), "Quit", ps
  500.     _PUTIMAGE (x1, y1), ps, 0, (0, 0)-(400 * ratio, 540 * ratio)
  501.     panx = x1: pany = y1
  502.     _DEST 0
  503.  
  504. SUB PaintStars
  505.     FOR i = 0 TO 99
  506.         c = star(i).c
  507.         x = star(i).x
  508.         y = star(i).y
  509.         o = star(i).o
  510.         CIRCLE (x, y), (star(i).s + 8) * ratio, c
  511.         COLOR 15
  512.         IF o > 0 THEN
  513.             PAINT (x, y), o + 8, c
  514.         END IF
  515.         _FONT ttf1
  516.         IF tt THEN
  517.             n$ = star(i).n
  518.             n$ = RTRIM$(n$)
  519.             L = _PRINTWIDTH(n$)
  520.             _PRINTSTRING (x + 10, y), STR$(star(i).p), 0
  521.         ELSE
  522.             n$ = STR$(star(i).t)
  523.             L = _PRINTWIDTH(n$)
  524.         END IF
  525.         _PRINTSTRING (x - L / 2, y + 14), n$, 0
  526.     NEXT
  527.  
  528. SUB NewGame
  529.     DIM k AS INTEGER
  530.     DIM r AS INTEGER
  531.     DIM dx AS INTEGER
  532.     DIM dy AS INTEGER
  533.     DIM n AS STRING * 10
  534.     FOR i = 0 TO 999
  535.         fleet(i).o = 0
  536.     NEXT
  537.     slct = 0
  538.     fltcnt = 0
  539.     LL = 0
  540.     seed = RND * 1000
  541.     star(0).n = "Sol"
  542.     star(0).x = RND * (sw - sww) + swn
  543.     star(0).y = RND * (sh - shw) + shn
  544.     star(0).c = 14
  545.     star(0).s = 2
  546.     star(0).o = 1
  547.     star(0).p = 10
  548.     star(0).t = 100
  549.     home(1) = 0
  550.     FOR i = 1 TO 99
  551.         k = 1
  552.         WHILE k
  553.             k = 0
  554.             x = RND * (sw - sww) + swn
  555.             y = RND * (sh - shw) + shn
  556.             r = INT(RND * 200)
  557.             n = names(r)
  558.             FOR j = 0 TO i - 1
  559.                 dx = x - star(j).x
  560.                 dy = y - star(j).y
  561.                 IF ABS(dx) < sww AND ABS(dy) < shw THEN
  562.                     k = 1
  563.                 END IF
  564.                 IF n = star(j).n THEN
  565.                     k = 1
  566.                 END IF
  567.             NEXT
  568.         WEND
  569.         star(i).n = n
  570.         star(i).x = x
  571.         star(i).y = y
  572.         star(i).c = RND * 6 + 9
  573.         star(i).s = RND * 5
  574.         star(i).o = 0
  575.         star(i).p = star(i).s + (RND * 5) + 3
  576.         star(i).t = 0
  577.     NEXT
  578.     FOR i = 2 TO 6
  579.         ok = 0
  580.         WHILE (ok < 1)
  581.             ok = 1
  582.             j = RND * 100
  583.             FOR k = 1 TO i - 1
  584.                 dist = SQR(ABS(star(j).x - star(home(k)).x) ^ 2 + ABS(star(j).y - star(home(k)).y) ^ 2)
  585.                 IF dist < 500 * ratio THEN
  586.                     ok = 0
  587.                     EXIT FOR
  588.                 END IF
  589.             NEXT
  590.             IF ok = 1 THEN
  591.                 ok = -1
  592.                 FOR k = 0 TO 99
  593.                     dist = SQR(ABS(star(j).x - star(k).x) ^ 2 + ABS(star(j).y - star(k).y) ^ 2)
  594.                     IF dist <= 250 THEN ok = ok + 1
  595.                     IF ok = 1 THEN EXIT FOR
  596.                 NEXT
  597.             END IF
  598.         WEND
  599.         home(i) = j
  600.         star(j).o = i
  601.         star(j).t = 100
  602.     NEXT
  603.  
  604. ' A lot of star names I made up
  605.  
  606. SUB StarNames
  607.     names(0) = "Acamar"
  608.     names(1) = "Arcab"
  609.     names(2) = "Acrux"
  610.     names(3) = "Adhara"
  611.     names(4) = "Arneb"
  612.     names(5) = "Antares"
  613.     names(6) = "Arcturus"
  614.     names(7) = "Atria"
  615.     names(8) = "Beid"
  616.     names(9) = "Betelgeuse"
  617.     names(10) = "Botein"
  618.     names(11) = "Beemim"
  619.     names(12) = "Bellatrix"
  620.     names(13) = "Bharani"
  621.     names(14) = "Biham"
  622.     names(15) = "Brachium"
  623.     names(16) = "Canopus"
  624.     names(17) = "Capella"
  625.     names(18) = "Castor"
  626.     names(19) = "Chara"
  627.     names(20) = "Cursa"
  628.     names(21) = "Copernicus"
  629.     names(22) = "Chalawan"
  630.     names(23) = "Chertan"
  631.     names(24) = "Dabih"
  632.     names(25) = "Dalim"
  633.     names(26) = "Deneb"
  634.     names(27) = "Denebola"
  635.     names(28) = "Diadem"
  636.     names(29) = "Diphda"
  637.     names(30) = "Dschubba"
  638.     names(31) = "Dziban"
  639.     names(32) = "Edasich"
  640.     names(33) = "Electra"
  641.     names(34) = "Elgafar"
  642.     names(35) = "Elkurud"
  643.     names(36) = "Elnath"
  644.     names(37) = "Eltanin"
  645.     names(38) = "Enif"
  646.     names(39) = "Errai"
  647.     names(40) = "Fafnir"
  648.     names(41) = "Fang"
  649.     names(42) = "Fawaris"
  650.     names(43) = "Felis"
  651.     names(44) = "Fomalhaut"
  652.     names(45) = "Fulu"
  653.     names(46) = "Fumal"
  654.     names(47) = "Furud"
  655.     names(48) = "Garnet"
  656.     names(49) = "Giausar"
  657.     names(50) = "Gienah"
  658.     names(51) = "Ginan"
  659.     names(52) = "Gomeisa"
  660.     names(53) = "Graffias"
  661.     names(54) = "Grumium"
  662.     names(55) = "Gudja"
  663.     names(56) = "Hadar"
  664.     names(57) = "Haedus"
  665.     names(58) = "Hamal"
  666.     names(59) = "Hassaleh"
  667.     names(60) = "Hatysa"
  668.     names(61) = "Helvetios"
  669.     names(62) = "Heze"
  670.     names(63) = "Homan"
  671.     names(64) = "Iklil"
  672.     names(65) = "Imai"
  673.     names(66) = "Intercrus"
  674.     names(67) = "Izar"
  675.     names(68) = "Iccar"
  676.     names(69) = "Inar"
  677.     names(70) = "Iaeth"
  678.     names(71) = "Imaous"
  679.     names(72) = "Jabbah"
  680.     names(73) = "Jishui"
  681.     names(74) = "Jax"
  682.     names(75) = "Jalae"
  683.     names(76) = "Jewel"
  684.     names(77) = "Jumbo"
  685.     names(78) = "Jerue"
  686.     names(79) = "Jabear"
  687.     names(80) = "Kakkab"
  688.     names(81) = "Kang"
  689.     names(82) = "Kekouan"
  690.     names(83) = "Keid"
  691.     names(84) = "Kitalpha"
  692.     names(85) = "Kochab"
  693.     names(86) = "Kolob"
  694.     names(87) = "Kobol"
  695.     names(88) = "Larawag"
  696.     names(89) = "Lesath"
  697.     names(90) = "Libertas"
  698.     names(91) = "Lich"
  699.     names(92) = "Lilly"
  700.     names(93) = "Laddel"
  701.     names(94) = "Luminous"
  702.     names(95) = "Lasacious"
  703.     names(96) = "Mizar"
  704.     names(97) = "Markab"
  705.     names(98) = "Matar"
  706.     names(99) = "Mintaka"
  707.     names(100) = "Meleph"
  708.     names(101) = "Menkar"
  709.     names(102) = "Merga"
  710.     names(103) = "Merope"
  711.     names(104) = "Nahn"
  712.     names(105) = "Naos"
  713.     names(106) = "Nashira"
  714.     names(107) = "Navi"
  715.     names(108) = "Nekkar"
  716.     names(109) = "Nembus"
  717.     names(110) = "Nihal"
  718.     names(111) = "Nunki"
  719.     names(112) = "Ogma"
  720.     names(113) = "Okab"
  721.     names(114) = "Ohmy"
  722.     names(115) = "Oragami"
  723.     names(116) = "Origen"
  724.     names(117) = "Omanii"
  725.     names(118) = "Obytewa"
  726.     names(119) = "Oglok"
  727.     names(120) = "Phact"
  728.     names(121) = "Pherkad"
  729.     names(122) = "Pleione"
  730.     names(122) = "Polaris"
  731.     names(123) = "Pollux"
  732.     names(124) = "Procyon"
  733.     names(125) = "Proxima"
  734.     names(126) = "Polis"
  735.     names(127) = "Quaint"
  736.     names(128) = "Quazzat"
  737.     names(129) = "Quetzal"
  738.     names(130) = "Qussol"
  739.     names(131) = "Quella"
  740.     names(132) = "Quyaeo"
  741.     names(133) = "Ququdas"
  742.     names(134) = "Quekak"
  743.     names(135) = "Rasalas"
  744.     names(136) = "Regor"
  745.     names(137) = "Regulus"
  746.     names(138) = "Rigel"
  747.     names(139) = "Revati"
  748.     names(140) = "Rotenev"
  749.     names(141) = "Rukbat"
  750.     names(142) = "Rastaban"
  751.     names(143) = "Sabik"
  752.     names(144) = "Sadr"
  753.     names(145) = "Saiph"
  754.     names(146) = "Sargas"
  755.     names(147) = "Sarin"
  756.     names(148) = "Syrma"
  757.     names(149) = "Spica"
  758.     names(150) = "Sirius"
  759.     names(151) = "Tarazed"
  760.     names(152) = "Taygeta"
  761.     names(153) = "Tejat"
  762.     names(154) = "Thabit"
  763.     names(155) = "Thuban"
  764.     names(156) = "Tiaki"
  765.     names(157) = "Toliman"
  766.     names(158) = "Torcular"
  767.     names(157) = "Umala"
  768.     names(158) = "Ulatte"
  769.     names(159) = "Ubbessa"
  770.     names(160) = "Unoless"
  771.     names(161) = "Umaddem"
  772.     names(162) = "Ummbra"
  773.     names(162) = "Uniqu"
  774.     names(163) = "Uzzaal"
  775.     names(164) = "Vega"
  776.     names(165) = "Veritate"
  777.     names(166) = "Vindetrix"
  778.     names(167) = "Vedas"
  779.     names(168) = "Vergg"
  780.     names(169) = "Vacant"
  781.     names(170) = "Vucae"
  782.     names(171) = "Vicar"
  783.     names(172) = "Wasat"
  784.     names(173) = "Wazn"
  785.     names(174) = "Wezen"
  786.     names(175) = "Waiten"
  787.     names(176) = "Wachar"
  788.     names(177) = "Wheelz"
  789.     names(178) = "Whatsp"
  790.     names(179) = "Wassand"
  791.     names(180) = "Xenno"
  792.     names(181) = "Xyphod"
  793.     names(182) = "Xu"
  794.     names(183) = "Xaal"
  795.     names(184) = "Xyross"
  796.     names(185) = "Xiggot"
  797.     names(186) = "Xirrks"
  798.     names(187) = "Yed"
  799.     names(188) = "Yildun"
  800.     names(189) = "Yundun"
  801.     names(190) = "Yavyo"
  802.     names(191) = "Yotrac"
  803.     names(192) = "Yxzoqu"
  804.     names(193) = "Ynnot"
  805.     names(194) = "Zaniah"
  806.     names(195) = "Zaurak"
  807.     names(196) = "Zhang"
  808.     names(197) = "Zibal"
  809.     names(198) = "Zosma"
  810.     names(199) = "Zuben"
  811.  
  812.  
  813.  
« Last Edit: December 17, 2019, 12:56:08 am by romichess »
My name is Michael, but you can call me Mike :)

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Beyond Sol
« Reply #16 on: December 17, 2019, 10:06:17 am »
Quote
Any feedback good or bad is not only welcome it is needed for this project to last much longer. I'll be on to something else if no one is interested. As it is it seems like at least an interesting example of GUI on demand.

OK in last post you start explaining some things, I have no idea idea why I want to send ships anywhere? So if you want a new audience, you might consider explaining the the game setup and objectives.

Offline romichess

  • Forum Regular
  • Posts: 145
    • View Profile
Re: Beyond Sol
« Reply #17 on: December 17, 2019, 11:31:31 am »
OK in last post you start explaining some things, I have no idea idea why I want to send ships anywhere? So if you want a new audience, you might consider explaining the the game setup and objectives.
From the op.

The game lives! Save humanity from the alien threat!!

To play just click on one of your stars. Then click (don't drag) on any other star and then send ships. That is all there is to it. The esc key exits the game. The "t' key toggles the star names. Look for the blue star. That is Sol the human's home star.


I'm pretty sure any child could figure it out from that. :)
My name is Michael, but you can call me Mike :)

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Beyond Sol
« Reply #18 on: December 17, 2019, 12:25:03 pm »
LOL sure a child can figure it out but well a little far from that...

OK so I click Sol and then click another star and a blue bubble travels (and not as the crow flies, which I can fix if you are interested) ever so slowly from Sol to planet and back and then nothing changes... ??? Still don't get it?

Offline romichess

  • Forum Regular
  • Posts: 145
    • View Profile
Re: Beyond Sol
« Reply #19 on: December 18, 2019, 12:28:53 am »
LOL sure a child can figure it out but well a little far from that...

OK so I click Sol and then click another star and a blue bubble travels (and not as the crow flies, which I can fix if you are interested) ever so slowly from Sol to planet and back and then nothing changes... ??? Still don't get it?

You have to send enough ships to take over the star system. If you don't the fleet turns around. Afterall they don't want to die for nothing, LOL. The graphics are not the final graphics. I'm just working on game play right now. When the ships are not traveling as the crow flies it is unknown by the player where the computers ships are going until they make the turn. In some cases that gives the player little time to react. It is a work in progress.
My name is Michael, but you can call me Mike :)

Offline Kazman

  • Newbie
  • Posts: 14
    • View Profile
Re: Beyond Sol
« Reply #20 on: December 18, 2019, 10:07:25 am »
I'm playing the game, I like it but mouse reactions are too slow... I often had to click several times on every button in order to make effect

Offline romichess

  • Forum Regular
  • Posts: 145
    • View Profile
Re: Beyond Sol
« Reply #21 on: December 18, 2019, 04:50:48 pm »
I'm playing the game, I like it but mouse reactions are too slow... I often had to click several times on every button in order to make effect

Thank you for trying the game and thanks for liking it! The mouse is a problem. It seems to be the speed of the click. If I hesitate in the button down position for just a moment before letting the button up it works every time. If I could figure out why then maybe it can be fixed. Also my goal is for the computer to be a challenge without resorting to cheating like so many games do.
My name is Michael, but you can call me Mike :)

Offline romichess

  • Forum Regular
  • Posts: 145
    • View Profile
Re: Beyond Sol
« Reply #22 on: December 20, 2019, 06:15:23 am »
The news is that the mouse problem is solved. It is silky smooth now. Still if one is in a hurry moving and clicking the mouse at the same time especially if clicking at double click speed there are still issues. But that is like at crazy speed. One can operate the mouse very quickly without any problems at all. And clicking on the numbers is more accurate as well. Also the computer target selection code has been completely rewritten. I do have a friend that test almost every new version. And he really likes this version. He says it is more challenging. So it seems that the playing algorithm may be finalized soon.

In the next update (not this one) starbases will be added. Basically starbases will be from level 0 to 9. The math will be like a lvl 0 (1) will be like 1 x 1 x 1000 ships. They will do the damage of a thousand ships but only cost 500 ships to build. They will take normal damage. A lvl 9 (10) starbase will be like 10 x 10 x 1000 ships and they will do the damage of 100,000 ships but because of their size and thickness of hull they will take half damage. It will cost ships at one fourth to repair them. Just wanted to let everyone know it was coming! :)

Code: QB64: [Select]
  1. TYPE stars
  2.     n AS STRING * 10 '                 Name of star
  3.     x AS INTEGER '                     x-position
  4.     y AS INTEGER '                     y-position
  5.     o AS INTEGER '                     Owner
  6.     c AS INTEGER '                     Color
  7.     s AS INTEGER '                     Size
  8.     t AS LONG '                     (Type of planetary system; terran, frozen, radiated, toxic, etc.) Ships
  9.     p AS INTEGER '                     (Population) For now ships produced per turn
  10.  
  11. TYPE FLEETS
  12.     t AS LONG
  13.     x1 AS INTEGER
  14.     y1 AS INTEGER
  15.     x2 AS INTEGER
  16.     y2 AS INTEGER
  17.     o AS INTEGER
  18.     d AS INTEGER
  19.  
  20. 'DECLARE SUB NewGame
  21. 'DECLARE SUB PaintStars
  22. 'DECLARE SUB StarNames
  23. 'DECLARE SUB ShowPanel (i)
  24. 'DECLARE SUB Identify (x, y)
  25. 'DECLARE SUB PaintBackground
  26. 'DECLARE SUB GetInput
  27.  
  28. ' Global variables shared because they are needed in more than one routine
  29. DIM SHARED sw AS INTEGER '             Screen Width
  30. DIM SHARED sh AS INTEGER '             Screen Height
  31. DIM SHARED sww AS INTEGER '            Screen Width Wide margin
  32. DIM SHARED swn AS INTEGER '            Screen Width Narrow adjustment
  33. DIM SHARED shw AS INTEGER '            Screen Height Wide margine
  34. DIM SHARED shn AS INTEGER '            Screen Height Narrow adjustment
  35. DIM SHARED nw AS INTEGER '             games Natural screen Width
  36. DIM SHARED nh AS INTEGER '             games Natural screen Height
  37. DIM SHARED ratio AS _FLOAT '           the Ratio of the games natural screen width to the actual
  38. DIM SHARED star(100) AS stars '        100 stars - may change
  39. DIM SHARED names(200) AS STRING * 10 ' 200 star names
  40. DIM SHARED seed AS INTEGER '           Seed to prime the Randomizer to display identical background each frame
  41. DIM SHARED home(7) AS INTEGER '        The starting star for each player. The human always has star(0), Sol
  42. DIM SHARED tt AS INTEGER '             tt = 0 star names displayed, tt = 0 star names not didplayed
  43. DIM SHARED ch AS STRING * 1 '          Game loop key input variable
  44. DIM SHARED repeat AS INTEGER '         Game loop control variable
  45. DIM SHARED fleet(1000) AS FLEETS
  46. DIM SHARED srcstr AS STRING * 10
  47. DIM SHARED dststr AS STRING * 10
  48. DIM SHARED panx, pany AS INTEGER
  49. DIM SHARED strng AS STRING * 10
  50. DIM SHARED hate(7, 7) AS INTEGER
  51.  
  52. sw = _DESKTOPWIDTH '                   native video with of syatem
  53. sww = sw / 24 '                        margin based on native video width to keep stars away from edge
  54. swn = sw / 48 '                        adjustment that works with sww to keep stars away from left and top of screen
  55. nw = 1920
  56.  
  57. ratio = sw / 1920 '                    Used to adjust distances and sizes for various screen modes
  58.  
  59. shw = sh / 20
  60. shn = sh / 40
  61. nh = 1080
  62.  
  63. tt = 0
  64. cx = sw
  65. cp = 100
  66. h = 100
  67. ar = 0
  68. rng = 200
  69. slct = 0
  70. strng = ""
  71.  
  72. SCREEN _NEWIMAGE(sw, sh, 256) '        creates a screen the resolution of the users native system
  73.  
  74.  
  75. ps = _NEWIMAGE(400 * ratio, 540 * ratio, 256)
  76.  
  77. StarNames '                            Routine to load star names into string array stars(200)
  78.  
  79. NewGame
  80.  
  81. ttf1 = _LOADFONT("cyberbit.ttf", 16 * ratio, "BOLD")
  82. ttf2 = _LOADFONT("cyberbit.ttf", 72 * ratio, "BOLD")
  83.  
  84. repeat = 1
  85.  
  86. WHILE repeat
  87.  
  88.     _LIMIT 60 '                        Set to 200 frames per second
  89.  
  90.     id = INT(RND * 5 + 2)
  91.  
  92.     CLS
  93.  
  94.     PaintBackground
  95.  
  96.     PaintStars
  97.  
  98.     PaintFleet
  99.  
  100.     GetInput
  101.  
  102.     Identify x, y
  103.  
  104.     Player
  105.  
  106.     Computer
  107.  
  108.     _DISPLAY
  109.  
  110.  
  111.  
  112. SUB PaintFleet
  113.     count = fltcnt
  114.     i = 0
  115.     WHILE count
  116.         IF fleet(i).o <> 0 THEN
  117.             CIRCLE (fleet(i).x1, fleet(i).y1), 3, fleet(i).o + 8
  118.             count = count - 1
  119.         END IF
  120.         i = i + 1
  121.     WEND
  122.  
  123. SUB SendFleet (org, dst, ships)
  124.     FOR i = 0 TO 999
  125.         IF fleet(i).o = 0 THEN
  126.             fleet(i).o = star(org).o
  127.             fleet(i).d = dst
  128.             fleet(i).x1 = star(org).x
  129.             fleet(i).y1 = star(org).y
  130.             fleet(i).x2 = star(dst).x
  131.             fleet(i).y2 = star(dst).y
  132.             fleet(i).t = ships
  133.             star(org).t = star(org).t - ships
  134.             fltcnt = fltcnt + 1
  135.             EXIT FOR
  136.         END IF
  137.     NEXT
  138.     LL = LL + 1
  139.  
  140. SUB Computer
  141.     FOR i = 0 TO 99
  142.         r = INT(RND * 60)
  143.         IF r < star(i).p THEN
  144.             IF star(i).o > 0 THEN
  145.                 star(i).t = star(i).t + 1
  146.             ELSE
  147.                 IF INT(RND * 10) < 3 THEN
  148.                     star(i).t = star(i).t + 1
  149.                 END IF
  150.             END IF
  151.         END IF
  152.     NEXT
  153.  
  154.     org = home(id)
  155.     IF star(org).o <> id THEN
  156.         FOR j = 0 TO 99
  157.             IF star(j).o = id THEN home(id) = j: EXIT FOR
  158.         NEXT
  159.     END IF
  160.  
  161.     FOR p = 0 TO 3
  162.  
  163.         IF p = 0 THEN
  164.             away = 10000
  165.             i = home(id)
  166.             IF star(i).t > LL * 2 THEN
  167.                 FOR j = 0 TO 99
  168.                     IF star(j).o <> id THEN
  169.                         dist = SQR(ABS(star(i).x - star(j).x) ^ 2 + ABS(star(i).y - star(j).y) ^ 2)
  170.                         IF dist <= 250 AND star(j).t > star(i).t / 3 THEN
  171.                             away = 10000
  172.                             EXIT FOR
  173.                         END IF
  174.                         ok = 0
  175.                         FOR K = 0 TO 99
  176.                             IF star(K).o = id THEN
  177.                                 dist = SQR(ABS(star(j).x - star(K).x) ^ 2 + ABS(star(j).y - star(K).y) ^ 2)
  178.                                 IF dist <= 250 THEN
  179.                                     ok = 1
  180.                                     EXIT FOR
  181.                                 END IF
  182.                             END IF
  183.                         NEXT
  184.                         IF ok = 1 THEN
  185.                             dist = SQR(ABS(star(i).x - star(j).x) ^ 2 + ABS(star(i).y - star(j).y) ^ 2)
  186.                             IF dist < away AND star(i).t > star(j).t * 3 THEN
  187.                                 away = dist
  188.                                 jay = j
  189.                             END IF
  190.                         END IF
  191.                     END IF
  192.                 NEXT
  193.                 IF away < 10000 THEN
  194.                     SendFleet i, jay, star(i).t / 2
  195.                 END IF
  196.             END IF
  197.         END IF
  198.  
  199.         IF p = 1 THEN
  200.             sf2 = 100
  201.             FOR i = 0 TO 99
  202.                 IF star(i).o = id AND i <> home(id) AND star(i).t > LL * 1.5 THEN
  203.                     sf3 = star(i).t / 2
  204.                     FOR j = 0 TO 99
  205.                         IF star(j).o <> id AND star(i).t > star(j).t * 4 THEN
  206.                             FOR K = 0 TO 99
  207.                                 IF star(K).o = id THEN
  208.                                     dist = SQR(ABS(star(K).x - star(j).x) ^ 2 + ABS(star(K).y - star(j).y) ^ 2)
  209.                                     IF dist <= 250 * ratio THEN
  210.                                         sf1 = i
  211.                                         sf2 = j
  212.                                         EXIT FOR
  213.                                     END IF
  214.                                 END IF
  215.                             NEXT
  216.                         END IF
  217.                     NEXT
  218.                     IF sf2 < 100 THEN EXIT FOR
  219.                 END IF
  220.             NEXT
  221.             IF sf2 < 100 THEN
  222.                 SendFleet sf1, sf2, sf3
  223.                 EXIT FOR
  224.             END IF
  225.         END IF
  226.  
  227.         IF p = 2 THEN
  228.             FOR i = 0 TO 99
  229.                 IF i <> home(id) AND star(i).o = id THEN
  230.                     IF star(i).t > 49 THEN
  231.                         ok = 1
  232.                         FOR j = 0 TO 99
  233.                             IF star(j).o <> id AND star(j).o <> 0 THEN
  234.                                 dist = SQR(ABS(star(i).x - star(j).x) ^ 2 + ABS(star(i).y - star(j).y) ^ 2)
  235.                                 IF dist <= 350 * ratio THEN
  236.                                     ok = 0
  237.                                     EXIT FOR
  238.                                 END IF
  239.                             END IF
  240.                         NEXT
  241.                         IF ok = 1 THEN
  242.                             SendFleet i, home(id), star(i).t
  243.                             EXIT FOR
  244.                         END IF
  245.                     END IF
  246.                 END IF
  247.             NEXT
  248.             IF ok = 1 THEN EXIT FOR
  249.         END IF
  250.  
  251.         IF p = 3 THEN
  252.             ok = 0
  253.             FOR i = 0 TO 99
  254.                 IF i <> home(id) AND star(i).o = id THEN
  255.                     IF star(i).t > LL * 1.5 + star(i).p * 50 THEN
  256.                         ok = 1
  257.                         EXIT FOR
  258.                     END IF
  259.                 END IF
  260.             NEXT
  261.             IF ok = 1 THEN
  262.                 SendFleet i, home(id), star(i).t / 4
  263.                 EXIT FOR
  264.             END IF
  265.         END IF
  266.  
  267.     NEXT
  268.  
  269.     count = fltcnt
  270.     i = 0
  271.     WHILE count
  272.         IF fleet(i).o <> 0 THEN
  273.             count = count - 1
  274.             IF fleet(i).x2 > fleet(i).x1 THEN
  275.                 fleet(i).x1 = fleet(i).x1 + 1
  276.             END IF
  277.             IF fleet(i).x2 < fleet(i).x1 THEN
  278.                 fleet(i).x1 = fleet(i).x1 - 1
  279.             END IF
  280.             IF fleet(i).y2 > fleet(i).y1 THEN
  281.                 fleet(i).y1 = fleet(i).y1 + 1
  282.             END IF
  283.             IF fleet(i).y2 < fleet(i).y1 THEN
  284.                 fleet(i).y1 = fleet(i).y1 - 1
  285.             END IF
  286.             IF fleet(i).x1 = fleet(i).x2 AND fleet(i).y1 = fleet(i).y2 THEN
  287.                 dst = fleet(i).d
  288.                 IF star(dst).o = fleet(i).o THEN
  289.                     star(dst).t = star(dst).t + fleet(i).t
  290.                     fleet(i).o = 0
  291.                     fltcnt = fltcnt - 1
  292.                 ELSE
  293.                     IF fleet(i).t > star(dst).t * 0.6 THEN
  294.                         alive = 1
  295.                         WHILE alive
  296.                             alive = 0
  297.                             damorg = fleet(i).t / 10 + 1
  298.                             damdst = star(dst).t / 9 + 1
  299.                             fleet(i).t = fleet(i).t - damdst
  300.                             star(dst).t = star(dst).t - damorg
  301.                             IF fleet(i).t > 0 AND star(dst).t > 0 THEN
  302.                                 alive = 1
  303.                             END IF
  304.                         WEND
  305.                         IF star(dst).t < 1 THEN
  306.                             hate(star(dst).o, fleet(i).o) = hate(star(dst).o, fleet(i).o) + 1
  307.                             star(dst).t = fleet(i).t
  308.                             star(dst).o = fleet(i).o
  309.                         END IF
  310.                         fleet(i).o = 0
  311.                         fltcnt = fltcnt - 1
  312.                     ELSE
  313.                         K = 100
  314.                         shortest = 10000
  315.                         FOR j = 0 TO 99
  316.                             IF star(j).o = fleet(i).o THEN
  317.                                 dist = SQR(ABS(star(j).x - fleet(i).x1) ^ 2 + ABS(star(j).y - fleet(i).y1) ^ 2)
  318.                                 IF dist < shortest THEN
  319.                                     shortest = dist
  320.                                     K = j
  321.                                 END IF
  322.                             END IF
  323.                         NEXT
  324.                         IF K < 100 THEN
  325.                             fleet(i).x2 = star(K).x
  326.                             fleet(i).y2 = star(K).y
  327.                             fleet(i).d = K
  328.                         END IF
  329.                     END IF
  330.                 END IF
  331.             END IF
  332.         END IF
  333.         i = i + 1
  334.     WEND
  335.  
  336. SUB GetInput
  337.  
  338.     ch = INKEY$
  339.     IF ch = CHR$(27) THEN repeat = 0
  340.     IF ch = "n" THEN NewGame
  341.     IF ch = "t" THEN tt = 1 - tt
  342.     IF ch = "p" THEN pause = 1
  343.  
  344.     WHILE (pause = 1)
  345.         IF INKEY$ = "p" THEN
  346.             pause = 0
  347.         END IF
  348.     WEND
  349.  
  350.     clk = 0
  351.  
  352.  
  353.         x = _MOUSEX
  354.         y = _MOUSEY
  355.         mb = _MOUSEBUTTON(1)
  356.  
  357.         IF mb AND cx = sw THEN cx = x
  358.  
  359.     WEND
  360.  
  361.     IF mb = 0 AND cx < sw THEN clk = 1
  362.  
  363.     cx = sw
  364.  
  365.     x = _MOUSEX
  366.     y = _MOUSEY
  367.  
  368.  
  369. SUB PaintBackground
  370.     x = RND * sw
  371.     y = RND * sh
  372.     c = RND * 14 + 1
  373.     PSET (x, y), c
  374.     RANDOMIZE USING seed
  375.     FOR i = 1 TO 600 * ratio
  376.         x = RND * sw
  377.         y = RND * sh
  378.         c = RND * 14 + 1
  379.         PSET (x, y), c
  380.     NEXT
  381.  
  382. SUB Player
  383.     tmp$ = RTRIM$(strng)
  384.     IF slct = 1 THEN
  385.         nclk = 1
  386.         FOR i = 0 TO 99
  387.             IF star(i).o = 1 THEN
  388.                 dist = SQR(ABS(star(i).x - x) ^ 2 + ABS(star(i).y - y) ^ 2)
  389.                 IF dist <= 250 * ratio THEN
  390.                     nclk = 0
  391.                     EXIT FOR
  392.                 END IF
  393.             END IF
  394.         NEXT
  395.         c = 10
  396.         IF nclk = 1 THEN
  397.             c = 12
  398.             clk = 0
  399.         END IF
  400.         LINE (px, py)-(x, y), c
  401.         n$ = STR$(INT(dist))
  402.         _PRINTSTRING (x + 20, y), n$, 0
  403.         EXIT SUB
  404.     END IF
  405.     IF pact = 1 THEN
  406.         ShowPanel ii
  407.         IF clk = 1 THEN
  408.             x1 = panx: x2 = panx + 400 * ratio
  409.             y1 = pany: y2 = pany + 540 * ratio
  410.             IF x > x1 + 216 * ratio AND x < x1 + 366 * ratio AND y > y1 + 460 * ratio AND y < y1 + 530 * ratio THEN
  411.                 pact = 0
  412.             ELSE IF x > x1 + 20 * ratio AND x < x1 + 380 * ratio AND y > y1 + 260 * ratio AND y < y1 + 320 * ratio THEN
  413.                     dig = (x - x1 - 32 * ratio) / (37 * ratio)
  414.                     strng = tmp$ + STR$(dig)
  415.                 ELSE IF x > x1 + 266 * ratio AND x < x1 + 366 * ratio AND y > y1 + 366 * ratio AND y < y1 + 406 * ratio THEN
  416.                         strng = ""
  417.                     ELSE IF x > x1 + 32 * ratio AND x < x1 + 182 * ratio AND y > y1 + 460 * ratio AND y < y1 + 530 * ratio THEN
  418.                             value = VAL(strng)
  419.                             strng = ""
  420.                             pact = 0
  421.                             IF value <= star(srcidx).t THEN
  422.                                 SendFleet srcidx, dstidx, value
  423.                             END IF
  424.                         END IF
  425.                     END IF
  426.                 END IF
  427.             END IF
  428.         END IF
  429.     END IF
  430.  
  431. SUB Identify (x, y)
  432.     IF nclk = 0 THEN
  433.         FOR i = 0 TO 99
  434.             dx = star(i).x - x
  435.             dy = star(i).y - y
  436.             IF pact = 0 AND ABS(dx) <= star(i).s + 8 AND ABS(dy) <= star(i).s + 8 THEN
  437.                 ii = i
  438.                 IF star(i).o = 1 AND slct = 0 THEN
  439.                     IF clk THEN
  440.                         slct = 1
  441.                     END IF
  442.                     px = x
  443.                     py = y
  444.                     srcstr = star(i).n
  445.                     srcidx = i
  446.                 ELSE
  447.                     IF slct = 1 OR pact = 1 THEN
  448.                         IF clk THEN
  449.                             slct = 0
  450.                             pact = 1
  451.                             dststr = star(i).n
  452.                             dstidx = i
  453.                         END IF
  454.                     END IF
  455.                 END IF
  456.                 EXIT FOR
  457.             END IF
  458.         NEXT
  459.     END IF
  460.  
  461. SUB ShowPanel (i)
  462.     x1 = star(i).x - 420 * ratio
  463.     IF star(i).x < sw / 2 THEN x1 = star(i).x + 20 * ratio
  464.     x2 = x1 + 400 * ratio
  465.     y1 = star(i).y
  466.     IF y1 > sh - 560 * ratio THEN y1 = sh - 560 * ratio
  467.     y2 = y1 + 540 * ratio
  468.     _DEST ps
  469.     CLS 0, 8
  470.     COLOR 0, 8
  471.     _FONT ttf2
  472.     n$ = RTRIM$(srcstr)
  473.     L = _PRINTWIDTH(n$)
  474.     _PRINTSTRING ((400 * ratio - L) / 2, 8 * ratio), n$, ps
  475.     n$ = "to"
  476.     L = _PRINTWIDTH(n$)
  477.     _PRINTSTRING ((400 * ratio - L) / 2, 80 * ratio), n$, ps
  478.     n$ = RTRIM$(dststr)
  479.     L = _PRINTWIDTH(n$)
  480.     _PRINTSTRING ((400 * ratio - L) / 2, 152 * ratio), n$, ps
  481.     LINE (20 * ratio, 240 * ratio)-(380 * ratio, 240 * ratio), 0
  482.     _PRINTSTRING (20 * ratio, 260 * ratio), "0123456789", ps
  483.     _PRINTSTRING (20 * ratio, 346 * ratio), strng, ps
  484.     xo = 286 * ratio: xd = 366 * ratio: yo = 366 * ratio: yd = 406 * ratio
  485.     LINE (xo, yo)-(xd, yd), 7, BF
  486.     xo = 32 * ratio: xd = 182 * ratio: yo = 458 * ratio: yd = 530 * ratio
  487.     LINE (xo, yo)-(xd, yd), 7, BF
  488.     xo = 216 * ratio: xd = 366 * ratio: yo = 458 * ratio: yd = 530 * ratio
  489.     LINE (xo, yo)-(xd, yd), 7, BF
  490.     _FONT ttf1
  491.     COLOR 7, 8
  492.     _PRINTSTRING (100 * ratio, 112 * ratio), STR$(star(srcidx).t), ps
  493.     _PRINTSTRING (270 * ratio, 112 * ratio), STR$(star(dstidx).t), ps
  494.     COLOR 0, 7
  495.     _PRINTSTRING (300 * ratio, 380 * ratio), "CLEAR", ps
  496.     _FONT ttf2
  497.     _PRINTSTRING (60 * ratio, 458 * ratio), "Ok", ps
  498.     _PRINTSTRING (220 * ratio, 458 * ratio), "Quit", ps
  499.     _PUTIMAGE (x1, y1), ps, 0, (0, 0)-(400 * ratio, 540 * ratio)
  500.     panx = x1: pany = y1
  501.     _DEST 0
  502.  
  503. SUB PaintStars
  504.     FOR i = 0 TO 99
  505.         c = star(i).c
  506.         x = star(i).x
  507.         y = star(i).y
  508.         o = star(i).o
  509.         CIRCLE (x, y), (star(i).s + 8) * ratio, c
  510.         COLOR 15
  511.         IF o > 0 THEN
  512.             PAINT (x, y), o + 8, c
  513.         END IF
  514.         _FONT ttf1
  515.         IF tt THEN
  516.             n$ = star(i).n
  517.             n$ = RTRIM$(n$)
  518.             L = _PRINTWIDTH(n$)
  519.             _PRINTSTRING (x + 10, y), STR$(star(i).p), 0
  520.         ELSE
  521.             n$ = STR$(star(i).t)
  522.             L = _PRINTWIDTH(n$)
  523.         END IF
  524.         _PRINTSTRING (x - L / 2, y + 14), n$, 0
  525.     NEXT
  526.  
  527. SUB NewGame
  528.     DIM k AS INTEGER
  529.     DIM r AS INTEGER
  530.     DIM dx AS INTEGER
  531.     DIM dy AS INTEGER
  532.     DIM n AS STRING * 10
  533.     FOR i = 0 TO 999
  534.         fleet(i).o = 0
  535.     NEXT
  536.     slct = 0
  537.     fltcnt = 0
  538.     LL = 25
  539.     seed = RND * 1000
  540.     star(0).n = "Sol"
  541.     star(0).x = RND * (sw - sww) + swn
  542.     star(0).y = RND * (sh - shw) + shn
  543.     star(0).c = 14
  544.     star(0).s = 2
  545.     star(0).o = 1
  546.     star(0).p = 10
  547.     star(0).t = 100
  548.     home(1) = 0
  549.     FOR i = 1 TO 99
  550.         k = 1
  551.         WHILE k
  552.             k = 0
  553.             x = RND * (sw - sww) + swn
  554.             y = RND * (sh - shw) + shn
  555.             r = INT(RND * 200)
  556.             n = names(r)
  557.             FOR j = 0 TO i - 1
  558.                 dx = x - star(j).x
  559.                 dy = y - star(j).y
  560.                 IF ABS(dx) < sww AND ABS(dy) < shw THEN
  561.                     k = 1
  562.                 END IF
  563.                 IF n = star(j).n THEN
  564.                     k = 1
  565.                 END IF
  566.             NEXT
  567.         WEND
  568.         star(i).n = n
  569.         star(i).x = x
  570.         star(i).y = y
  571.         star(i).c = RND * 6 + 9
  572.         star(i).s = RND * 5
  573.         star(i).o = 0
  574.         star(i).p = star(i).s + (RND * 5) + 3
  575.         star(i).t = 0
  576.     NEXT
  577.     FOR i = 2 TO 6
  578.         ok = 0
  579.         WHILE (ok < 1)
  580.             ok = 1
  581.             j = RND * 100
  582.             FOR k = 1 TO i - 1
  583.                 dist = SQR(ABS(star(j).x - star(home(k)).x) ^ 2 + ABS(star(j).y - star(home(k)).y) ^ 2)
  584.                 IF dist < 500 * ratio THEN
  585.                     ok = 0
  586.                     EXIT FOR
  587.                 END IF
  588.             NEXT
  589.             IF ok = 1 THEN
  590.                 ok = -1
  591.                 FOR k = 0 TO 99
  592.                     dist = SQR(ABS(star(j).x - star(k).x) ^ 2 + ABS(star(j).y - star(k).y) ^ 2)
  593.                     IF dist <= 200 THEN ok = ok + 1
  594.                     IF ok = 1 THEN EXIT FOR
  595.                 NEXT
  596.             END IF
  597.         WEND
  598.         home(i) = j
  599.         star(j).o = i
  600.         star(j).p = 10
  601.         star(j).t = 100
  602.     NEXT
  603.  
  604. ' A lot of star names I made up
  605.  
  606. SUB StarNames
  607.     names(0) = "Acamar"
  608.     names(1) = "Arcab"
  609.     names(2) = "Acrux"
  610.     names(3) = "Adhara"
  611.     names(4) = "Arneb"
  612.     names(5) = "Antares"
  613.     names(6) = "Arcturus"
  614.     names(7) = "Atria"
  615.     names(8) = "Beid"
  616.     names(9) = "Betelgeuse"
  617.     names(10) = "Botein"
  618.     names(11) = "Beemim"
  619.     names(12) = "Bellatrix"
  620.     names(13) = "Bharani"
  621.     names(14) = "Biham"
  622.     names(15) = "Brachium"
  623.     names(16) = "Canopus"
  624.     names(17) = "Capella"
  625.     names(18) = "Castor"
  626.     names(19) = "Chara"
  627.     names(20) = "Cursa"
  628.     names(21) = "Copernicus"
  629.     names(22) = "Chalawan"
  630.     names(23) = "Chertan"
  631.     names(24) = "Dabih"
  632.     names(25) = "Dalim"
  633.     names(26) = "Deneb"
  634.     names(27) = "Denebola"
  635.     names(28) = "Diadem"
  636.     names(29) = "Diphda"
  637.     names(30) = "Dschubba"
  638.     names(31) = "Dziban"
  639.     names(32) = "Edasich"
  640.     names(33) = "Electra"
  641.     names(34) = "Elgafar"
  642.     names(35) = "Elkurud"
  643.     names(36) = "Elnath"
  644.     names(37) = "Eltanin"
  645.     names(38) = "Enif"
  646.     names(39) = "Errai"
  647.     names(40) = "Fafnir"
  648.     names(41) = "Fang"
  649.     names(42) = "Fawaris"
  650.     names(43) = "Felis"
  651.     names(44) = "Fomalhaut"
  652.     names(45) = "Fulu"
  653.     names(46) = "Fumal"
  654.     names(47) = "Furud"
  655.     names(48) = "Garnet"
  656.     names(49) = "Giausar"
  657.     names(50) = "Gienah"
  658.     names(51) = "Ginan"
  659.     names(52) = "Gomeisa"
  660.     names(53) = "Graffias"
  661.     names(54) = "Grumium"
  662.     names(55) = "Gudja"
  663.     names(56) = "Hadar"
  664.     names(57) = "Haedus"
  665.     names(58) = "Hamal"
  666.     names(59) = "Hassaleh"
  667.     names(60) = "Hatysa"
  668.     names(61) = "Helvetios"
  669.     names(62) = "Heze"
  670.     names(63) = "Homan"
  671.     names(64) = "Iklil"
  672.     names(65) = "Imai"
  673.     names(66) = "Intercrus"
  674.     names(67) = "Izar"
  675.     names(68) = "Iccar"
  676.     names(69) = "Inar"
  677.     names(70) = "Iaeth"
  678.     names(71) = "Imaous"
  679.     names(72) = "Jabbah"
  680.     names(73) = "Jishui"
  681.     names(74) = "Jax"
  682.     names(75) = "Jalae"
  683.     names(76) = "Jewel"
  684.     names(77) = "Jumbo"
  685.     names(78) = "Jerue"
  686.     names(79) = "Jabear"
  687.     names(80) = "Kakkab"
  688.     names(81) = "Kang"
  689.     names(82) = "Kekouan"
  690.     names(83) = "Keid"
  691.     names(84) = "Kitalpha"
  692.     names(85) = "Kochab"
  693.     names(86) = "Kolob"
  694.     names(87) = "Kobol"
  695.     names(88) = "Larawag"
  696.     names(89) = "Lesath"
  697.     names(90) = "Libertas"
  698.     names(91) = "Lich"
  699.     names(92) = "Lilly"
  700.     names(93) = "Laddel"
  701.     names(94) = "Luminous"
  702.     names(95) = "Lasacious"
  703.     names(96) = "Mizar"
  704.     names(97) = "Markab"
  705.     names(98) = "Matar"
  706.     names(99) = "Mintaka"
  707.     names(100) = "Meleph"
  708.     names(101) = "Menkar"
  709.     names(102) = "Merga"
  710.     names(103) = "Merope"
  711.     names(104) = "Nahn"
  712.     names(105) = "Naos"
  713.     names(106) = "Nashira"
  714.     names(107) = "Navi"
  715.     names(108) = "Nekkar"
  716.     names(109) = "Nembus"
  717.     names(110) = "Nihal"
  718.     names(111) = "Nunki"
  719.     names(112) = "Ogma"
  720.     names(113) = "Okab"
  721.     names(114) = "Ohmy"
  722.     names(115) = "Oragami"
  723.     names(116) = "Origen"
  724.     names(117) = "Omanii"
  725.     names(118) = "Obytewa"
  726.     names(119) = "Oglok"
  727.     names(120) = "Phact"
  728.     names(121) = "Pherkad"
  729.     names(122) = "Pleione"
  730.     names(122) = "Polaris"
  731.     names(123) = "Pollux"
  732.     names(124) = "Procyon"
  733.     names(125) = "Proxima"
  734.     names(126) = "Polis"
  735.     names(127) = "Quaint"
  736.     names(128) = "Quazzat"
  737.     names(129) = "Quetzal"
  738.     names(130) = "Qussol"
  739.     names(131) = "Quella"
  740.     names(132) = "Quyaeo"
  741.     names(133) = "Ququdas"
  742.     names(134) = "Quekak"
  743.     names(135) = "Rasalas"
  744.     names(136) = "Regor"
  745.     names(137) = "Regulus"
  746.     names(138) = "Rigel"
  747.     names(139) = "Revati"
  748.     names(140) = "Rotenev"
  749.     names(141) = "Rukbat"
  750.     names(142) = "Rastaban"
  751.     names(143) = "Sabik"
  752.     names(144) = "Sadr"
  753.     names(145) = "Saiph"
  754.     names(146) = "Sargas"
  755.     names(147) = "Sarin"
  756.     names(148) = "Syrma"
  757.     names(149) = "Spica"
  758.     names(150) = "Sirius"
  759.     names(151) = "Tarazed"
  760.     names(152) = "Taygeta"
  761.     names(153) = "Tejat"
  762.     names(154) = "Thabit"
  763.     names(155) = "Thuban"
  764.     names(156) = "Tiaki"
  765.     names(157) = "Toliman"
  766.     names(158) = "Torcular"
  767.     names(157) = "Umala"
  768.     names(158) = "Ulatte"
  769.     names(159) = "Ubbessa"
  770.     names(160) = "Unoless"
  771.     names(161) = "Umaddem"
  772.     names(162) = "Ummbra"
  773.     names(162) = "Uniqu"
  774.     names(163) = "Uzzaal"
  775.     names(164) = "Vega"
  776.     names(165) = "Veritate"
  777.     names(166) = "Vindetrix"
  778.     names(167) = "Vedas"
  779.     names(168) = "Vergg"
  780.     names(169) = "Vacant"
  781.     names(170) = "Vucae"
  782.     names(171) = "Vicar"
  783.     names(172) = "Wasat"
  784.     names(173) = "Wazn"
  785.     names(174) = "Wezen"
  786.     names(175) = "Waiten"
  787.     names(176) = "Wachar"
  788.     names(177) = "Wheelz"
  789.     names(178) = "Whatsp"
  790.     names(179) = "Wassand"
  791.     names(180) = "Xenno"
  792.     names(181) = "Xyphod"
  793.     names(182) = "Xu"
  794.     names(183) = "Xaal"
  795.     names(184) = "Xyross"
  796.     names(185) = "Xiggot"
  797.     names(186) = "Xirrks"
  798.     names(187) = "Yed"
  799.     names(188) = "Yildun"
  800.     names(189) = "Yundun"
  801.     names(190) = "Yavyo"
  802.     names(191) = "Yotrac"
  803.     names(192) = "Yxzoqu"
  804.     names(193) = "Ynnot"
  805.     names(194) = "Zaniah"
  806.     names(195) = "Zaurak"
  807.     names(196) = "Zhang"
  808.     names(197) = "Zibal"
  809.     names(198) = "Zosma"
  810.     names(199) = "Zuben"
  811.  
  812.  
My name is Michael, but you can call me Mike :)

Offline romichess

  • Forum Regular
  • Posts: 145
    • View Profile
Re: Beyond Sol
« Reply #23 on: December 23, 2019, 04:23:36 am »
First of all when over 60 y.o. never program when tired. I just went through several days of hell making and fixing bugs only to create more bugs than I fixed. After taking a day and a half off and getting lots of sleep I was able to fix all the bugs and add a ton of new features. No star bases yet but that is next. Much of the code was completely rewritten and is much cleaner. That process will continue. Optimising for speed will come later.

I probably can't name all the changes but here is a list of what I can remember.

Send all, send half and send third buttons to the fleet send panel.
A standing orders panel. So stars can automatically send ships to another planet.
Right clicking the mouse will cancel a panel
Right clicking on empty space will pause/unpause the game. Orders can still be issued.
Pressing "p" will do the same and orders can be issued.
The range line will when over a star snap to the center of the star and give the exact range
Range can be gotten between any two stars.
Right clicking will cancel range lines.
The computer players start the game paused so that a player can find his home star. Initial orders can be placed before unpausing.
And a few more minor changes.
The computer players are better than ever also! And still no cheating!!

To bring up a panel left or right click on one of your stars. Then left click another star to send ships or right click another one of your planets to bring up the standing orders panel. To cancel a standing order just enter 0 and 0. One standing order per star.

I was going to add star bases before making another post but I'm at the point of needing another day and a half off. That is all there is for now. Opinions about the interface are welcome as well as suggestions and opinions about the computer's play. Thanks!

Code: QB64: [Select]
  1. TYPE stars
  2.     n AS STRING * 10 '                 Name of star
  3.     x AS INTEGER '                     x-position
  4.     y AS INTEGER '                     y-position
  5.     o AS INTEGER '                     Owner
  6.     c AS INTEGER '                     Color
  7.     s AS INTEGER '                     Size
  8.     t AS LONG '                        Ships
  9.     p AS INTEGER '                     (Population) For now ships production
  10.  
  11. TYPE FLEETS
  12.     t AS LONG
  13.     x1 AS INTEGER
  14.     y1 AS INTEGER
  15.     x2 AS INTEGER
  16.     y2 AS INTEGER
  17.     o AS INTEGER
  18.     d AS INTEGER
  19.  
  20. TYPE ORDERS
  21.     src AS LONG
  22.     ovr AS LONG
  23.     shp AS LONG
  24.     dst AS LONG
  25.  
  26. ' Global variables shared because they are needed in more than one routine
  27. DIM SHARED sw AS INTEGER '             Screen Width
  28. DIM SHARED sh AS INTEGER '             Screen Height
  29. DIM SHARED sww AS INTEGER '            Screen Width Wide margin
  30. DIM SHARED swn AS INTEGER '            Screen Width Narrow adjustment
  31. DIM SHARED shw AS INTEGER '            Screen Height Wide margine
  32. DIM SHARED shn AS INTEGER '            Screen Height Narrow adjustment
  33. DIM SHARED nw AS INTEGER '             games Natural screen Width
  34. DIM SHARED nh AS INTEGER '             games Natural screen Height
  35. DIM SHARED ratio AS _FLOAT '           the Ratio of the games natural screen width to the actual
  36. DIM SHARED star(100) AS stars '        100 stars - may change
  37. DIM SHARED names(200) AS STRING * 10 ' 200 star names
  38. DIM SHARED seed AS INTEGER '           Seed to prime the Randomizer to display identical background each frame
  39. DIM SHARED home(7) AS INTEGER '        The starting star for each player. The human always has star(0), Sol
  40. DIM SHARED tt AS INTEGER '             tt = 0 star names displayed, tt = 0 star names not didplayed
  41. DIM SHARED ch AS STRING * 1 '          Game loop key input variable
  42. DIM SHARED repeat AS INTEGER '         Game loop control variable
  43. DIM SHARED fleet(1000) AS FLEETS
  44. DIM SHARED panx, pany AS INTEGER
  45. DIM SHARED oanx, oany AS INTEGER
  46. DIM SHARED strng AS STRING * 14
  47. DIM SHARED hate(7, 7) AS INTEGER
  48. DIM SHARED strng0 AS STRING * 10
  49. DIM SHARED strng1 AS STRING * 10
  50. DIM SHARED order(100) AS ORDERS
  51. DIM SHARED ord AS ORDERS
  52.  
  53. sw = _DESKTOPWIDTH '                   native video with of syatem
  54. sww = sw / 24 '                        margin based on native video width to keep stars away from edge
  55. swn = sw / 48 '                        adjustment that works with sww to keep stars away from left and top of screen
  56. nw = 1920
  57.  
  58. ratio = sw / 1920 '                    Used to adjust distances and sizes for various screen modes
  59.  
  60. shw = sh / 20
  61. shn = sh / 40
  62. nh = 1080
  63.  
  64. tt = 0
  65. lcx = sw
  66. rcx = sw
  67. cp = 100
  68. h = 100
  69. ar = 0
  70. rng = 200
  71. slct = 0
  72. strng = ""
  73. strng0 = ""
  74. strng1 = ""
  75. src = 100
  76. dst = 100
  77. ord.src = 100
  78.  
  79. SCREEN _NEWIMAGE(sw, sh, 256) '        creates a screen the resolution of the users native system
  80.  
  81.  
  82. sp = _NEWIMAGE(400 * ratio, 540 * ratio, 256)
  83. op = _NEWIMAGE(400 * ratio, 225 * ratio, 256)
  84.  
  85. StarNames '                            Routine to load star names into string array stars(200)
  86.  
  87. NewGame
  88.  
  89. ttf16 = _LOADFONT("cyberbit.ttf", 16 * ratio, "BOLD")
  90. ttf24 = _LOADFONT("cyberbit.ttf", 24 * ratio, "BOLD")
  91. ttf36 = _LOADFONT("cyberbit.ttf", 36 * ratio, "BOLD")
  92. ttf72 = _LOADFONT("cyberbit.ttf", 72 * ratio, "BOLD")
  93.  
  94. repeat = 1
  95.  
  96. WHILE repeat
  97.  
  98.     _LIMIT 60 '                        Set to 200 frames per second
  99.  
  100.     id = INT(RND * 5 + 2)
  101.  
  102.     CLS
  103.  
  104.     PaintBackground
  105.  
  106.     PaintStars
  107.  
  108.     PaintFleet
  109.  
  110.     GetInput
  111.  
  112.     Player
  113.  
  114.     Computer
  115.  
  116.     _DISPLAY
  117.  
  118.  
  119.  
  120. SUB Computer
  121.     STATIC last(7) AS INTEGER
  122.  
  123.     IF paused = 0 THEN
  124.         RANDOMIZE TIMER
  125.         FOR i = 0 TO 99
  126.             r = INT(RND * 60)
  127.             IF r < star(i).p THEN
  128.                 IF star(i).o > 0 THEN
  129.                     star(i).t = star(i).t + 1
  130.                 ELSE
  131.                     IF INT(RND * 10) < 3 THEN
  132.                         star(i).t = star(i).t + 1
  133.                     END IF
  134.                 END IF
  135.             END IF
  136.         NEXT
  137.  
  138.         org = home(id)
  139.         IF star(org).o <> id THEN
  140.             FOR j = 0 TO 99
  141.                 IF star(j).o = id THEN home(id) = j: EXIT FOR
  142.             NEXT
  143.         END IF
  144.  
  145.         FOR p = 0 TO 3
  146.  
  147.             IF p = 0 THEN
  148.                 away = 10000
  149.                 i = home(id)
  150.                 IF star(i).t > LL THEN
  151.                     FOR j = 0 TO 99
  152.                         IF star(j).o <> id AND last(id) <> j THEN
  153.                             dist = SQR(ABS(star(i).x - star(j).x) ^ 2 + ABS(star(i).y - star(j).y) ^ 2)
  154.                             IF dist <= 250 AND star(j).t > star(i).t / 3 THEN
  155.                                 away = 10000
  156.                                 EXIT FOR
  157.                             END IF
  158.                             ok = 0
  159.                             FOR K = 0 TO 99
  160.                                 IF star(K).o = id THEN
  161.                                     dist = SQR(ABS(star(j).x - star(K).x) ^ 2 + ABS(star(j).y - star(K).y) ^ 2)
  162.                                     IF dist <= 250 THEN
  163.                                         ok = 1
  164.                                         EXIT FOR
  165.                                     END IF
  166.                                 END IF
  167.                             NEXT
  168.                             IF ok = 1 THEN
  169.                                 dist = SQR(ABS(star(i).x - star(j).x) ^ 2 + ABS(star(i).y - star(j).y) ^ 2)
  170.                                 IF dist < away AND star(i).t > star(j).t * 2 THEN
  171.                                     away = dist
  172.                                     jay = j
  173.                                 END IF
  174.                             END IF
  175.                         END IF
  176.                     NEXT
  177.                     IF away < 10000 THEN
  178.                         last(id) = jay
  179.                         SendFleet i, jay, star(i).t / 1.5
  180.                     END IF
  181.                 END IF
  182.             END IF
  183.  
  184.             IF p = 1 THEN
  185.                 sf2 = 100
  186.                 FOR i = 0 TO 99
  187.                     IF star(i).o = id AND i <> home(id) AND star(i).t > LL * 1.5 THEN
  188.                         sf3 = star(i).t / 2
  189.                         FOR j = 0 TO 99
  190.                             IF star(j).o <> id AND star(i).t > star(j).t * 4 THEN
  191.                                 FOR K = 0 TO 99
  192.                                     IF star(K).o = id THEN
  193.                                         dist = SQR(ABS(star(K).x - star(j).x) ^ 2 + ABS(star(K).y - star(j).y) ^ 2)
  194.                                         IF dist <= 250 * ratio THEN
  195.                                             sf1 = i
  196.                                             sf2 = j
  197.                                             EXIT FOR
  198.                                         END IF
  199.                                     END IF
  200.                                 NEXT
  201.                             END IF
  202.                         NEXT
  203.                         IF sf2 < 100 THEN EXIT FOR
  204.                     END IF
  205.                 NEXT
  206.                 IF sf2 < 100 THEN
  207.                     SendFleet sf1, sf2, sf3
  208.                     EXIT FOR
  209.                 END IF
  210.             END IF
  211.  
  212.             IF p = 2 THEN
  213.                 FOR i = 0 TO 99
  214.                     IF i <> home(id) AND star(i).o = id THEN
  215.                         IF star(i).t > 49 THEN
  216.                             ok = 1
  217.                             FOR j = 0 TO 99
  218.                                 IF star(j).o <> id AND star(j).o <> 0 THEN
  219.                                     dist = SQR(ABS(star(i).x - star(j).x) ^ 2 + ABS(star(i).y - star(j).y) ^ 2)
  220.                                     IF dist <= 350 * ratio THEN
  221.                                         ok = 0
  222.                                         EXIT FOR
  223.                                     END IF
  224.                                 END IF
  225.                             NEXT
  226.                             IF ok = 1 THEN
  227.                                 SendFleet i, home(id), star(i).t
  228.                                 EXIT FOR
  229.                             END IF
  230.                         END IF
  231.                     END IF
  232.                 NEXT
  233.                 IF ok = 1 THEN EXIT FOR
  234.             END IF
  235.  
  236.             IF p = 3 THEN
  237.                 ok = 0
  238.                 FOR i = 0 TO 99
  239.                     IF i <> home(id) AND star(i).o = id THEN
  240.                         IF star(i).t > LL * 1.5 + star(i).p * 50 THEN
  241.                             ok = 1
  242.                             EXIT FOR
  243.                         END IF
  244.                     END IF
  245.                 NEXT
  246.                 IF ok = 1 THEN
  247.                     SendFleet i, home(id), star(i).t / 4
  248.                     EXIT FOR
  249.                 END IF
  250.             END IF
  251.  
  252.         NEXT
  253.  
  254.         count = fltcnt
  255.         i = 0
  256.         WHILE count
  257.             IF fleet(i).o <> 0 THEN
  258.                 count = count - 1
  259.                 IF fleet(i).x2 > fleet(i).x1 THEN
  260.                     fleet(i).x1 = fleet(i).x1 + 1
  261.                 END IF
  262.                 IF fleet(i).x2 < fleet(i).x1 THEN
  263.                     fleet(i).x1 = fleet(i).x1 - 1
  264.                 END IF
  265.                 IF fleet(i).y2 > fleet(i).y1 THEN
  266.                     fleet(i).y1 = fleet(i).y1 + 1
  267.                 END IF
  268.                 IF fleet(i).y2 < fleet(i).y1 THEN
  269.                     fleet(i).y1 = fleet(i).y1 - 1
  270.                 END IF
  271.                 IF fleet(i).x1 = fleet(i).x2 AND fleet(i).y1 = fleet(i).y2 THEN
  272.                     dest = fleet(i).d
  273.                     IF star(dest).o = fleet(i).o THEN
  274.                         star(dest).t = star(dest).t + fleet(i).t
  275.                         fleet(i).o = 0
  276.                         fltcnt = fltcnt - 1
  277.                     ELSE
  278.                         IF fleet(i).t > star(dest).t * 0.6 THEN
  279.                             alive = 1
  280.                             WHILE alive
  281.                                 alive = 0
  282.                                 damorg = fleet(i).t / 10 + 1
  283.                                 damdst = star(dest).t / 9 + 1
  284.                                 fleet(i).t = fleet(i).t - damdst
  285.                                 star(dest).t = star(dest).t - damorg
  286.                                 IF fleet(i).t > 0 AND star(dest).t > 0 THEN
  287.                                     alive = 1
  288.                                 END IF
  289.                             WEND
  290.                             IF star(dest).t < 1 THEN
  291.                                 hate(star(dest).o, fleet(i).o) = hate(star(dest).o, fleet(i).o) + 1
  292.                                 star(dest).t = fleet(i).t
  293.                                 star(dest).o = fleet(i).o
  294.                             END IF
  295.                             fleet(i).o = 0
  296.                             fltcnt = fltcnt - 1
  297.                         ELSE
  298.                             K = 100
  299.                             shortest = 10000
  300.                             FOR j = 0 TO 99
  301.                                 IF star(j).o = fleet(i).o THEN
  302.                                     dist = SQR(ABS(star(j).x - fleet(i).x1) ^ 2 + ABS(star(j).y - fleet(i).y1) ^ 2)
  303.                                     IF dist < shortest THEN
  304.                                         shortest = dist
  305.                                         K = j
  306.                                     END IF
  307.                                 END IF
  308.                             NEXT
  309.                             IF K < 100 THEN
  310.                                 fleet(i).x2 = star(K).x
  311.                                 fleet(i).y2 = star(K).y
  312.                                 fleet(i).d = K
  313.                             END IF
  314.                         END IF
  315.                     END IF
  316.                 END IF
  317.             END IF
  318.             i = i + 1
  319.         WEND
  320.     END IF
  321.  
  322. SUB GetInput
  323.  
  324.     IF ch = CHR$(27) THEN repeat = 0
  325.     IF ch = "n" THEN NewGame
  326.     IF ch = "t" THEN tt = 1 - tt
  327.     IF ch = "p" THEN paused = 1 - paused
  328.     ch = INKEY$
  329.  
  330.     lclk = 0
  331.     rclk = 0
  332.  
  333.  
  334.         x = _MOUSEX
  335.         y = _MOUSEY
  336.         lmb = _MOUSEBUTTON(1)
  337.         rmb = _MOUSEBUTTON(2)
  338.  
  339.         IF lmb AND lcx = sw THEN lcx = x
  340.         IF rmb AND rcx = sw THEN rcx = x
  341.     WEND
  342.  
  343.     IF lmb = 0 AND lcx < sw THEN lclk = 1
  344.     IF rmb = 0 AND rcx < sw THEN rclk = 1
  345.  
  346.     lcx = sw
  347.     rcx = sw
  348.  
  349.     x = _MOUSEX
  350.     y = _MOUSEY
  351.  
  352.     IF rclk = 1 THEN
  353.         i = Identify
  354.         IF i = 100 THEN
  355.             IF src = 100 THEN
  356.                 paused = 1 - paused
  357.                 ch = ""
  358.             ELSE
  359.                 src = 100
  360.                 oact = 0
  361.                 pact = 0
  362.             END IF
  363.             rclk = 0
  364.         END IF
  365.         IF pact = 1 OR oact = 1 THEN
  366.             rclk = 0
  367.         END IF
  368.     END IF
  369.  
  370.  
  371. FUNCTION Identify
  372.     ii = 100
  373.     FOR i = 0 TO 99
  374.         dx = star(i).x - x
  375.         dy = star(i).y - y
  376.         IF ABS(dx) <= star(i).s + 8 AND ABS(dy) <= star(i).s + 8 THEN
  377.             ii = i
  378.             EXIT FOR
  379.         END IF
  380.     NEXT
  381.     Identify = ii
  382.  
  383. SUB OrderPanel (i)
  384.     x1 = star(i).x - 420 * ratio
  385.     IF star(i).x < sw / 2 THEN x1 = star(i).x + 20 * ratio
  386.     x2 = x1 + 400 * ratio
  387.     y1 = star(i).y
  388.     IF y1 > sh - 225 * ratio THEN y1 = sh - 225 * ratio
  389.     y2 = y1 + 225 * ratio
  390.     _DEST op
  391.     CLS 0, 8
  392.     COLOR 0, 8
  393.     _FONT ttf72
  394.     n$ = RTRIM$(star(i).n)
  395.     l = _PRINTWIDTH(n$)
  396.     _PRINTSTRING ((400 * ratio - l) / 2, 4 * ratio), n$, op
  397.     LINE (20 * ratio, 76 * ratio)-(380 * ratio, 76 * ratio), 0
  398.     _PRINTSTRING (20 * ratio, 80 * ratio), "0123456789", op
  399.     COLOR 7, 8
  400.     _FONT ttf36
  401.     IF box = 0 THEN
  402.         _PRINTSTRING (20 * ratio, 166 * ratio), "If Over", op
  403.         xo = 142 * ratio: xd = 250 * ratio: yo = 166 * ratio: yd = 200 * ratio
  404.         LINE (xo, yo)-(xd, yd), 7, BF
  405.         xo = 268 * ratio: xd = 314 * ratio: yo = 166 * ratio: yd = 200 * ratio
  406.         LINE (xo, yo)-(xd, yd), 7, BF
  407.         xo = 332 * ratio: xd = 366 * ratio: yo = 166 * ratio: yd = 200 * ratio
  408.         LINE (xo, yo)-(xd, yd), 7, BF
  409.         n$ = RTRIM$(strng0)
  410.         COLOR 0, 7
  411.         _FONT ttf24
  412.         _PRINTSTRING (148 * ratio, 172 * ratio), n$, op
  413.         _PRINTSTRING (273 * ratio, 172 * ratio), "OK", op
  414.         _PRINTSTRING (341 * ratio, 172 * ratio), "X", op
  415.     END IF
  416.     IF box = 1 THEN
  417.         _PRINTSTRING (20 * ratio, 166 * ratio), "Then Send", op
  418.         xo = 198 * ratio: xd = 278 * ratio: yo = 166 * ratio: yd = 200 * ratio
  419.         LINE (xo, yo)-(xd, yd), 7, BF
  420.         xo = 294 * ratio: xd = 340 * ratio: yo = 166 * ratio: yd = 200 * ratio
  421.         LINE (xo, yo)-(xd, yd), 7, BF
  422.         xo = 356 * ratio: xd = 390 * ratio: yo = 166 * ratio: yd = 200 * ratio
  423.         LINE (xo, yo)-(xd, yd), 7, BF
  424.         n$ = RTRIM$(strng1)
  425.         COLOR 0, 7
  426.         _FONT ttf24
  427.         _PRINTSTRING (200 * ratio, 172 * ratio), n$, op
  428.         _PRINTSTRING (299 * ratio, 172 * ratio), "OK", op
  429.         _PRINTSTRING (365 * ratio, 172 * ratio), "X", op
  430.     END IF
  431.     _PUTIMAGE (x1, y1), op, 0, (0, 0)-(400 * ratio, 225 * ratio)
  432.     _DEST 0
  433.     oanx = x1: oany = y1
  434.  
  435. SUB PaintBackground
  436.     x = RND * sw
  437.     y = RND * sh
  438.     c = RND * 14 + 1
  439.     PSET (x, y), c
  440.     RANDOMIZE USING seed
  441.     FOR i = 1 TO 600 * ratio
  442.         x = RND * sw
  443.         y = RND * sh
  444.         c = RND * 14 + 1
  445.         PSET (x, y), c
  446.     NEXT
  447.  
  448. SUB PaintFleet
  449.     count = fltcnt
  450.     i = 0
  451.     WHILE count
  452.         IF fleet(i).o <> 0 THEN
  453.             CIRCLE (fleet(i).x1, fleet(i).y1), 3, fleet(i).o + 8
  454.             count = count - 1
  455.         END IF
  456.         i = i + 1
  457.     WEND
  458.  
  459. SUB PaintStars
  460.     FOR i = 0 TO 99
  461.         c = star(i).c
  462.         x = star(i).x
  463.         y = star(i).y
  464.         o = star(i).o
  465.         CIRCLE (x, y), (star(i).s + 8) * ratio, c
  466.         COLOR 15
  467.         IF o > 0 THEN
  468.             PAINT (x, y), o + 8, c
  469.         END IF
  470.         _FONT ttf16
  471.         IF tt THEN
  472.             n$ = star(i).n
  473.             n$ = RTRIM$(n$)
  474.             l = _PRINTWIDTH(n$)
  475.             _PRINTSTRING (x + 10, y), STR$(star(i).p), 0
  476.         ELSE
  477.             n$ = STR$(star(i).t)
  478.             l = _PRINTWIDTH(n$)
  479.         END IF
  480.         _PRINTSTRING (x - l / 2, y + 14), n$, 0
  481.     NEXT
  482.  
  483. SUB Player
  484.  
  485.     'Add new order to standing orders
  486.     IF ord.src <> 100 THEN
  487.         i = ord.src
  488.         IF ord.shp = 0 THEN
  489.             order(i).src = 100
  490.         ELSE
  491.             order(i) = ord
  492.         END IF
  493.         ord.src = 100
  494.     END IF
  495.  
  496.     'execute standing orders
  497.     FOR i = 0 TO 99
  498.         IF order(i).src <> 100 THEN
  499.             IF star(i).o <> 1 THEN
  500.                 order(i).src = 100
  501.             ELSE
  502.                 IF star(i).t >= order(i).ovr THEN
  503.                     SendFleet order(i).src, order(i).dst, order(i).shp
  504.                 END IF
  505.             END IF
  506.         END IF
  507.     NEXT
  508.  
  509.     IF pact = 0 AND oact = 0 THEN
  510.  
  511.         'If there is no source star see if we can get one
  512.         IF src = 100 THEN
  513.             IF lclk = 1 OR rclk = 1 THEN
  514.                 lclk = 0
  515.                 rclk = 0
  516.                 src = Identify
  517.             END IF
  518.         END IF
  519.  
  520.         ' If there is a source star then look for a right click else draw a range line
  521.         IF src <> 100 THEN
  522.             c = 12
  523.             FOR i = 0 TO 99
  524.                 IF star(i).o = 1 THEN
  525.                     dist = SQR(ABS(star(i).x - x) ^ 2 + ABS(star(i).y - y) ^ 2)
  526.                     IF dist <= 250 * ratio THEN
  527.                         c = 10
  528.                         EXIT FOR
  529.                     END IF
  530.                 END IF
  531.             NEXT
  532.             rang = SQR(ABS(star(src).x - x) ^ 2 + ABS(star(src).y - y) ^ 2)
  533.             i = Identify
  534.             IF i <> 100 THEN
  535.                 x = star(i).x
  536.                 y = star(i).y
  537.             END IF
  538.             LINE (star(src).x, star(src).y)-(x, y), c
  539.             n$ = STR$(INT(rang))
  540.             _FONT ttf16
  541.             _PRINTSTRING (x + 20, y), n$, 0
  542.         END IF
  543.  
  544.         'If we have a source star see if we clicked on a destination star
  545.         IF src <> 100 THEN
  546.             IF lclk = 1 OR rclk = 1 THEN
  547.                 i = Identify
  548.                 IF i < 100 AND i <> src THEN
  549.                     dst = i
  550.                     IF lclk = 1 THEN
  551.                         lclk = 0
  552.                         pact = 1
  553.                     ELSE
  554.                         rclk = 0
  555.                         IF star(i).o = 1 THEN
  556.                             oact = 1
  557.                         END IF
  558.                     END IF
  559.                 END IF
  560.             END IF
  561.         END IF
  562.  
  563.     END IF
  564.  
  565.     'If the star standing orders panel is active
  566.     IF oact = 1 THEN
  567.  
  568.         IF star(src).o = 1 THEN
  569.             OrderPanel dst
  570.         END IF
  571.  
  572.         IF rclk = 1 THEN oact = 0
  573.  
  574.         IF box = 0 THEN
  575.             tmp$ = RTRIM$(strng0)
  576.         ELSE
  577.             tmp$ = RTRIM$(strng1)
  578.         END IF
  579.  
  580.         IF lclk = 1 THEN
  581.  
  582.             x1 = oanx: x2 = oanx + 400 * ratio
  583.             y1 = oany: y2 = oany + 540 * ratio
  584.  
  585.             IF y > y1 + 80 * ratio AND y < y1 + 152 * ratio THEN
  586.                 IF x > x1 + 20 * ratio AND x < x1 + 380 * ratio THEN
  587.                     dig = (x - x1 - 32 * ratio) / (37 * ratio)
  588.                     IF box = 0 THEN
  589.                         n$ = RTRIM$(strng0)
  590.                         l = LEN(n$)
  591.                         IF l < 8 THEN strng0 = tmp$ + STR$(dig)
  592.                     ELSE
  593.                         n$ = RTRIM$(strng1)
  594.                         l = LEN(n$)
  595.                         IF l < 8 THEN strng1 = tmp$ + STR$(dig)
  596.                     END IF
  597.                 END IF
  598.             END IF
  599.  
  600.             IF y > y1 + 166 * ratio AND y < y1 + 200 * ratio THEN
  601.  
  602.                 IF box = 0 THEN
  603.  
  604.                     IF x > x1 + 268 * ratio AND x < x1 + 314 * ratio THEN
  605.                         ord.ovr = INT(VAL(strng0))
  606.                         strng0 = ""
  607.                         strng1 = ""
  608.                         box = 1
  609.                     END IF
  610.  
  611.                     IF x > x1 + 332 * ratio AND x < x1 + 366 * ratio THEN
  612.                         strng0 = ""
  613.                     END IF
  614.  
  615.                 ELSE
  616.  
  617.                     IF x > x1 + 294 * ratio AND x < x1 + 340 * ratio THEN
  618.                         IF INT(VAL(strng1)) > ord.ovr THEN
  619.                             strng1 = ""
  620.                         ELSE
  621.                             ord.src = src
  622.                             ord.shp = VAL(strng1)
  623.                             ord.dst = dst
  624.                             box = 0
  625.                             oact = 0
  626.                             strng0 = ""
  627.                             strng1 = ""
  628.                             src = 100
  629.                         END IF
  630.                     END IF
  631.  
  632.                     IF x > x1 + 356 * ratio AND x < x1 + 390 * ratio THEN
  633.                         strng0 = ""
  634.                         strng1 = ""
  635.                         box = 0
  636.                     END IF
  637.  
  638.                 END IF
  639.  
  640.             END IF
  641.         END IF
  642.         x1 = 10000: y1 = 10000
  643.     END IF
  644.  
  645.     'If the fleet send panel is active
  646.     IF pact = 1 THEN
  647.         IF rclk = 1 THEN pact = 0
  648.         IF star(src).o = 1 THEN
  649.             ShowPanel dst
  650.         END IF
  651.         IF lclk = 1 THEN
  652.             tmp$ = RTRIM$(strng)
  653.  
  654.             x1 = panx: x2 = panx + 400 * ratio
  655.             y1 = pany: y2 = pany + 540 * ratio
  656.  
  657.             IF y > y1 + 256 * ratio AND y < y1 + 328 * ratio THEN
  658.                 IF x > x1 + 20 * ratio AND x < x1 + 380 * ratio THEN
  659.                     dig = (x - x1 - 32 * ratio) / (37 * ratio)
  660.                     strng = tmp$ + STR$(dig)
  661.                 END IF
  662.             END IF
  663.  
  664.             IF y > y1 + 334 * ratio AND y < y1 + 374 * ratio THEN
  665.                 IF x > x1 + 20 * ratio AND x < x1 + 84 * ratio THEN
  666.                     pact = 0
  667.                     value = star(src).t
  668.                     SendFleet src, dst, value
  669.                     src = 100
  670.                 END IF
  671.                 IF x > x1 + 102 * ratio AND x < x1 + 184 * ratio THEN
  672.                     pact = 0
  673.                     value = star(src).t / 2
  674.                     SendFleet src, dst, value
  675.                     src = 100
  676.                 END IF
  677.                 IF x > x1 + 202 * ratio AND x < x1 + 282 * ratio THEN
  678.                     pact = 0
  679.                     value = star(src).t / 3
  680.                     SendFleet src, dst, value
  681.                     src = 100
  682.                 END IF
  683.                 IF x > x1 + 300 * ratio AND x < x1 + 380 * ratio THEN
  684.                     strng = ""
  685.                 END IF
  686.             END IF
  687.  
  688.             IF y > y1 + 460 * ratio AND y < y1 + 530 * ratio THEN
  689.                 IF x > x1 + 32 * ratio AND x < x1 + 182 * ratio THEN
  690.                     value = VAL(strng)
  691.                     strng = ""
  692.                     pact = 0
  693.                     IF value <= star(src).t THEN
  694.                         SendFleet src, dst, value
  695.                     END IF
  696.                     src = 100
  697.                 END IF
  698.                 IF x > x1 + 212 * ratio AND x < x1 + 362 * ratio THEN
  699.                     pact = 0
  700.                     src = 100
  701.                     strng = ""
  702.                 END IF
  703.             END IF
  704.         END IF
  705.     END IF
  706.  
  707. SUB SendFleet (src, dst, ships)
  708.     FOR i = 0 TO 999
  709.         IF fleet(i).o = 0 THEN
  710.             fleet(i).o = star(src).o
  711.             fleet(i).d = dst
  712.             fleet(i).x1 = star(src).x
  713.             fleet(i).y1 = star(src).y
  714.             fleet(i).x2 = star(dst).x
  715.             fleet(i).y2 = star(dst).y
  716.             fleet(i).t = ships
  717.             star(src).t = star(src).t - ships
  718.             fltcnt = fltcnt + 1
  719.             EXIT FOR
  720.         END IF
  721.     NEXT
  722.     LL = LL + 1
  723.  
  724. SUB ShowPanel (i)
  725.     x1 = star(i).x - 420 * ratio
  726.     IF star(i).x < sw / 2 THEN x1 = star(i).x + 20 * ratio
  727.     x2 = x1 + 400 * ratio
  728.     y1 = star(i).y
  729.     IF y1 > sh - 560 * ratio THEN y1 = sh - 560 * ratio
  730.     y2 = y1 + 540 * ratio
  731.     _DEST sp
  732.     CLS 0, 8
  733.     COLOR 0, 8
  734.     _FONT ttf72
  735.     n$ = RTRIM$(star(src).n)
  736.     l = _PRINTWIDTH(n$)
  737.     _PRINTSTRING ((400 * ratio - l) / 2, 12 * ratio), n$, sp
  738.     n$ = "to"
  739.     l = _PRINTWIDTH(n$)
  740.     _PRINTSTRING ((400 * ratio - l) / 2, 80 * ratio), n$, sp
  741.     n$ = RTRIM$(star(dst).n)
  742.     l = _PRINTWIDTH(n$)
  743.     _PRINTSTRING ((400 * ratio - l) / 2, 152 * ratio), n$, sp
  744.     LINE (20 * ratio, 239 * ratio)-(380 * ratio, 239 * ratio), 0
  745.     _PRINTSTRING (20 * ratio, 256 * ratio), "0123456789", sp
  746.     n$ = RTRIM$(strng)
  747.     l = _PRINTWIDTH(n$)
  748.     _PRINTSTRING ((400 * ratio - l) / 2, 383 * ratio), n$, sp
  749.     xo = 20 * ratio: xd = 84 * ratio: yo = 334 * ratio: yd = 374 * ratio
  750.     LINE (xo, yo)-(xd, yd), 7, BF
  751.     xo = 102 * ratio: xd = 184 * ratio: yo = 334 * ratio: yd = 374 * ratio
  752.     LINE (xo, yo)-(xd, yd), 7, BF
  753.     xo = 202 * ratio: xd = 282 * ratio: yo = 334 * ratio: yd = 374 * ratio
  754.     LINE (xo, yo)-(xd, yd), 7, BF
  755.     xo = 300 * ratio: xd = 380 * ratio: yo = 334 * ratio: yd = 374 * ratio
  756.     LINE (xo, yo)-(xd, yd), 7, BF
  757.     xo = 32 * ratio: xd = 182 * ratio: yo = 458 * ratio: yd = 530 * ratio
  758.     LINE (xo, yo)-(xd, yd), 7, BF
  759.     xo = 212 * ratio: xd = 362 * ratio: yo = 458 * ratio: yd = 530 * ratio
  760.     LINE (xo, yo)-(xd, yd), 7, BF
  761.     _FONT ttf24
  762.     COLOR 7, 8
  763.     n$ = RTRIM$(STR$(star(src).t))
  764.     l = _PRINTWIDTH(n$)
  765.     _PRINTSTRING (120 * ratio - l, 112 * ratio), n$, sp
  766.     n$ = RTRIM$(STR$(star(dst).t))
  767.     l = _PRINTWIDTH(n$)
  768.     _PRINTSTRING (300 * ratio - l, 112 * ratio), n$, sp
  769.     _FONT ttf16
  770.     COLOR 0, 7
  771.     _PRINTSTRING (38 * ratio, 347 * ratio), "ALL", sp
  772.     _PRINTSTRING (122 * ratio, 347 * ratio), "HALF", sp
  773.     _PRINTSTRING (214 * ratio, 347 * ratio), "THIRD", sp
  774.     _PRINTSTRING (312 * ratio, 347 * ratio), "CLEAR", sp
  775.     _FONT ttf72
  776.     _PRINTSTRING (60 * ratio, 458 * ratio), "Ok", sp
  777.     _PRINTSTRING (216 * ratio, 458 * ratio), "Quit", sp
  778.     _PUTIMAGE (x1, y1), sp, 0, (0, 0)-(400 * ratio, 540 * ratio)
  779.     panx = x1: pany = y1
  780.     _DEST 0
  781.  
  782. SUB NewGame
  783.     DIM k AS INTEGER
  784.     DIM r AS INTEGER
  785.     DIM dx AS INTEGER
  786.     DIM dy AS INTEGER
  787.     DIM n AS STRING * 10
  788.     paused = 1
  789.     FOR i = 0 TO 999
  790.         fleet(i).o = 0
  791.     NEXT
  792.     slct = 0
  793.     fltcnt = 0
  794.     LL = 25
  795.     seed = RND * 1000
  796.     FOR i = 0 TO 99
  797.         k = 1
  798.         WHILE k
  799.             k = 0
  800.             x = RND * (sw - sww) + swn
  801.             y = RND * (sh - shw) + shn
  802.             r = INT(RND * 200)
  803.             n = names(r)
  804.             FOR j = 0 TO i - 1
  805.                 dx = x - star(j).x
  806.                 dy = y - star(j).y
  807.                 IF ABS(dx) < sww AND ABS(dy) < shw THEN
  808.                     k = 1
  809.                 END IF
  810.                 IF n = star(j).n THEN
  811.                     k = 1
  812.                 END IF
  813.             NEXT
  814.         WEND
  815.         star(i).n = n
  816.         star(i).x = x
  817.         star(i).y = y
  818.         star(i).c = RND * 6 + 9
  819.         star(i).s = RND * 5
  820.         star(i).o = 0
  821.         star(i).p = star(i).s + (RND * 5) + 3
  822.         star(i).t = 0
  823.         order(i).src = 100
  824.     NEXT
  825.     FOR i = 1 TO 6
  826.         ok = 0
  827.         WHILE (ok < 1)
  828.             ok = 1
  829.             j = RND * 100
  830.             FOR k = 1 TO i - 1
  831.                 dist = SQR(ABS(star(j).x - star(home(k)).x) ^ 2 + ABS(star(j).y - star(home(k)).y) ^ 2)
  832.                 IF dist < 500 * ratio THEN
  833.                     ok = 0
  834.                     EXIT FOR
  835.                 END IF
  836.             NEXT
  837.             IF ok = 1 THEN
  838.                 ok = -1
  839.                 FOR k = 0 TO 99
  840.                     dist = SQR(ABS(star(j).x - star(k).x) ^ 2 + ABS(star(j).y - star(k).y) ^ 2)
  841.                     IF dist <= 200 THEN ok = ok + 1
  842.                     IF ok = 1 THEN EXIT FOR
  843.                 NEXT
  844.             END IF
  845.         WEND
  846.         home(i) = j
  847.         star(j).o = i
  848.         star(j).p = 10
  849.         star(j).t = 100
  850.         star(j).s = 4
  851.         star(home(1)).n = "Sol"
  852.         star(home(1)).c = 14
  853.     NEXT
  854.  
  855. ' A lot of star names I made up
  856.  
  857. SUB StarNames
  858.     names(0) = "Acamar"
  859.     names(1) = "Arcab"
  860.     names(2) = "Acrux"
  861.     names(3) = "Adhara"
  862.     names(4) = "Arneb"
  863.     names(5) = "Antares"
  864.     names(6) = "Arcturus"
  865.     names(7) = "Atria"
  866.     names(8) = "Beid"
  867.     names(9) = "Betelgeuse"
  868.     names(10) = "Botein"
  869.     names(11) = "Beemim"
  870.     names(12) = "Bellatrix"
  871.     names(13) = "Bharani"
  872.     names(14) = "Biham"
  873.     names(15) = "Brachium"
  874.     names(16) = "Canopus"
  875.     names(17) = "Capella"
  876.     names(18) = "Castor"
  877.     names(19) = "Chara"
  878.     names(20) = "Cursa"
  879.     names(21) = "Copernicus"
  880.     names(22) = "Chalawan"
  881.     names(23) = "Chertan"
  882.     names(24) = "Dabih"
  883.     names(25) = "Dalim"
  884.     names(26) = "Deneb"
  885.     names(27) = "Denebola"
  886.     names(28) = "Diadem"
  887.     names(29) = "Diphda"
  888.     names(30) = "Dschubba"
  889.     names(31) = "Dziban"
  890.     names(32) = "Edasich"
  891.     names(33) = "Electra"
  892.     names(34) = "Elgafar"
  893.     names(35) = "Elkurud"
  894.     names(36) = "Elnath"
  895.     names(37) = "Eltanin"
  896.     names(38) = "Enif"
  897.     names(39) = "Errai"
  898.     names(40) = "Fafnir"
  899.     names(41) = "Fang"
  900.     names(42) = "Fawaris"
  901.     names(43) = "Felis"
  902.     names(44) = "Fomalhaut"
  903.     names(45) = "Fulu"
  904.     names(46) = "Fumal"
  905.     names(47) = "Furud"
  906.     names(48) = "Garnet"
  907.     names(49) = "Giausar"
  908.     names(50) = "Gienah"
  909.     names(51) = "Ginan"
  910.     names(52) = "Gomeisa"
  911.     names(53) = "Graffias"
  912.     names(54) = "Grumium"
  913.     names(55) = "Gudja"
  914.     names(56) = "Hadar"
  915.     names(57) = "Haedus"
  916.     names(58) = "Hamal"
  917.     names(59) = "Hassaleh"
  918.     names(60) = "Hatysa"
  919.     names(61) = "Helvetios"
  920.     names(62) = "Heze"
  921.     names(63) = "Homan"
  922.     names(64) = "Iklil"
  923.     names(65) = "Imai"
  924.     names(66) = "Intercrus"
  925.     names(67) = "Izar"
  926.     names(68) = "Iccar"
  927.     names(69) = "Inar"
  928.     names(70) = "Iaeth"
  929.     names(71) = "Imaous"
  930.     names(72) = "Jabbah"
  931.     names(73) = "Jishui"
  932.     names(74) = "Jax"
  933.     names(75) = "Jalae"
  934.     names(76) = "Jewel"
  935.     names(77) = "Jumbo"
  936.     names(78) = "Jerue"
  937.     names(79) = "Jabear"
  938.     names(80) = "Kakkab"
  939.     names(81) = "Kang"
  940.     names(82) = "Kekouan"
  941.     names(83) = "Keid"
  942.     names(84) = "Kitalpha"
  943.     names(85) = "Kochab"
  944.     names(86) = "Kolob"
  945.     names(87) = "Kobol"
  946.     names(88) = "Larawag"
  947.     names(89) = "Lesath"
  948.     names(90) = "Libertas"
  949.     names(91) = "Lich"
  950.     names(92) = "Lilly"
  951.     names(93) = "Laddel"
  952.     names(94) = "Luminous"
  953.     names(95) = "Lasacious"
  954.     names(96) = "Mizar"
  955.     names(97) = "Markab"
  956.     names(98) = "Matar"
  957.     names(99) = "Mintaka"
  958.     names(100) = "Meleph"
  959.     names(101) = "Menkar"
  960.     names(102) = "Merga"
  961.     names(103) = "Merope"
  962.     names(104) = "Nahn"
  963.     names(105) = "Naos"
  964.     names(106) = "Nashira"
  965.     names(107) = "Navi"
  966.     names(108) = "Nekkar"
  967.     names(109) = "Nembus"
  968.     names(110) = "Nihal"
  969.     names(111) = "Nunki"
  970.     names(112) = "Ogma"
  971.     names(113) = "Okab"
  972.     names(114) = "Ohmy"
  973.     names(115) = "Oragami"
  974.     names(116) = "Origen"
  975.     names(117) = "Omanii"
  976.     names(118) = "Obytewa"
  977.     names(119) = "Oglok"
  978.     names(120) = "Phact"
  979.     names(121) = "Pherkad"
  980.     names(122) = "Pleione"
  981.     names(122) = "Polaris"
  982.     names(123) = "Pollux"
  983.     names(124) = "Procyon"
  984.     names(125) = "Proxima"
  985.     names(126) = "Polis"
  986.     names(127) = "Quaint"
  987.     names(128) = "Quazzat"
  988.     names(129) = "Quetzal"
  989.     names(130) = "Qussol"
  990.     names(131) = "Quella"
  991.     names(132) = "Quyaeo"
  992.     names(133) = "Ququdas"
  993.     names(134) = "Quekak"
  994.     names(135) = "Rasalas"
  995.     names(136) = "Regor"
  996.     names(137) = "Regulus"
  997.     names(138) = "Rigel"
  998.     names(139) = "Revati"
  999.     names(140) = "Rotenev"
  1000.     names(141) = "Rukbat"
  1001.     names(142) = "Rastaban"
  1002.     names(143) = "Sabik"
  1003.     names(144) = "Sadr"
  1004.     names(145) = "Saiph"
  1005.     names(146) = "Sargas"
  1006.     names(147) = "Sarin"
  1007.     names(148) = "Syrma"
  1008.     names(149) = "Spica"
  1009.     names(150) = "Sirius"
  1010.     names(151) = "Tarazed"
  1011.     names(152) = "Taygeta"
  1012.     names(153) = "Tejat"
  1013.     names(154) = "Thabit"
  1014.     names(155) = "Thuban"
  1015.     names(156) = "Tiaki"
  1016.     names(157) = "Toliman"
  1017.     names(158) = "Torcular"
  1018.     names(157) = "Umala"
  1019.     names(158) = "Ulatte"
  1020.     names(159) = "Ubbessa"
  1021.     names(160) = "Unoless"
  1022.     names(161) = "Umaddem"
  1023.     names(162) = "Ummbra"
  1024.     names(162) = "Uniqu"
  1025.     names(163) = "Uzzaal"
  1026.     names(164) = "Vega"
  1027.     names(165) = "Veritate"
  1028.     names(166) = "Vindetrix"
  1029.     names(167) = "Vedas"
  1030.     names(168) = "Vergg"
  1031.     names(169) = "Vacant"
  1032.     names(170) = "Vucae"
  1033.     names(171) = "Vicar"
  1034.     names(172) = "Wasat"
  1035.     names(173) = "Wazn"
  1036.     names(174) = "Wezen"
  1037.     names(175) = "Waiten"
  1038.     names(176) = "Wachar"
  1039.     names(177) = "Wheelz"
  1040.     names(178) = "Whatsp"
  1041.     names(179) = "Wassand"
  1042.     names(180) = "Xenno"
  1043.     names(181) = "Xyphod"
  1044.     names(182) = "Xu"
  1045.     names(183) = "Xaal"
  1046.     names(184) = "Xyross"
  1047.     names(185) = "Xiggot"
  1048.     names(186) = "Xirrks"
  1049.     names(187) = "Yed"
  1050.     names(188) = "Yildun"
  1051.     names(189) = "Yundun"
  1052.     names(190) = "Yavyo"
  1053.     names(191) = "Yotrac"
  1054.     names(192) = "Yxzoqu"
  1055.     names(193) = "Ynnot"
  1056.     names(194) = "Zaniah"
  1057.     names(195) = "Zaurak"
  1058.     names(196) = "Zhang"
  1059.     names(197) = "Zibal"
  1060.     names(198) = "Zosma"
  1061.     names(199) = "Zuben"
  1062.  
  1063.  
My name is Michael, but you can call me Mike :)

Offline Kazman

  • Newbie
  • Posts: 14
    • View Profile
Re: Beyond Sol
« Reply #24 on: December 23, 2019, 07:31:44 am »
I will test last version at home, because I'm testing it at work and it does almost nothing... no right click, no menus, no ships moving... I thing it is my problem, this pc is a sh#t :P

Offline romichess

  • Forum Regular
  • Posts: 145
    • View Profile
Re: Beyond Sol
« Reply #25 on: December 23, 2019, 02:04:47 pm »
I will test last version at home, because I'm testing it at work and it does almost nothing... no right click, no menus, no ships moving... I thing it is my problem, this pc is a sh#t :P

I'm sorry! Just to be sure I copied the posted code and ran it. It works on my machine. The game DOES START PAUSED now. Right clicking or pressing "p" toggles the paused mode. Even paused, orders should be able to be entered. Thus one should get menus. Please let me know when you get home if it is working for you, or not. Thanks!
My name is Michael, but you can call me Mike :)

Offline romichess

  • Forum Regular
  • Posts: 145
    • View Profile
Re: Beyond Sol
« Reply #26 on: December 24, 2019, 04:31:28 pm »
I did find a couple of bugs. They were not fatal bugs. Anyway they are squashed now. And I performed more rigorous testing to make sure that there are no more bugs. And I added two more features. Lines were added for standing orders which are barely visible but if I can see them with my old eyes ... but if they are not visible on a lower contrast monitor, let me know. The second feature is a "mystery player". One of the computer players is randomly selected to use a different algorithm.

Code: QB64: [Select]
  1. TYPE stars
  2.     n AS STRING * 10 '                 Name of star
  3.     x AS INTEGER '                     x-position
  4.     y AS INTEGER '                     y-position
  5.     o AS INTEGER '                     Owner
  6.     c AS INTEGER '                     Color
  7.     s AS INTEGER '                     Size
  8.     t AS LONG '                        Ships
  9.     p AS INTEGER '                     (Population) For now ships production
  10.  
  11. TYPE FLEETS
  12.     t AS LONG
  13.     x1 AS INTEGER
  14.     y1 AS INTEGER
  15.     x2 AS INTEGER
  16.     y2 AS INTEGER
  17.     o AS INTEGER
  18.     d AS INTEGER
  19.  
  20. TYPE ORDERS
  21.     src AS LONG
  22.     ovr AS LONG
  23.     shp AS LONG
  24.     dst AS LONG
  25.  
  26. ' Global variables shared because they are needed in more than one routine
  27. DIM SHARED sw AS INTEGER '             Screen Width
  28. DIM SHARED sh AS INTEGER '             Screen Height
  29. DIM SHARED sww AS INTEGER '            Screen Width Wide margin
  30. DIM SHARED swn AS INTEGER '            Screen Width Narrow adjustment
  31. DIM SHARED shw AS INTEGER '            Screen Height Wide margine
  32. DIM SHARED shn AS INTEGER '            Screen Height Narrow adjustment
  33. DIM SHARED nw AS INTEGER '             games Natural screen Width
  34. DIM SHARED nh AS INTEGER '             games Natural screen Height
  35. DIM SHARED ratio AS _FLOAT '           the Ratio of the games natural screen width to the actual
  36. DIM SHARED star(100) AS stars '        100 stars - may change
  37. DIM SHARED names(200) AS STRING * 10 ' 200 star names
  38. DIM SHARED seed AS INTEGER '           Seed to prime the Randomizer to display identical background each frame
  39. DIM SHARED home(7) AS INTEGER '        The starting star for each player. The human always has star(0), Sol
  40. DIM SHARED tt AS INTEGER '             tt = 0 star names displayed, tt = 0 star names not didplayed
  41. DIM SHARED ch AS STRING * 1 '          Game loop key input variable
  42. DIM SHARED repeat AS INTEGER '         Game loop control variable
  43. DIM SHARED fleet(1000) AS FLEETS
  44. DIM SHARED panx, pany AS INTEGER
  45. DIM SHARED oanx, oany AS INTEGER
  46. DIM SHARED strng AS STRING * 14
  47. DIM SHARED hate(7, 7) AS INTEGER
  48. DIM SHARED strng0 AS STRING * 10
  49. DIM SHARED strng1 AS STRING * 10
  50. DIM SHARED order(100) AS ORDERS
  51. DIM SHARED ord AS ORDERS
  52.  
  53. sw = _DESKTOPWIDTH '                   native video with of syatem
  54. sww = sw / 24 '                        margin based on native video width to keep stars away from edge
  55. swn = sw / 48 '                        adjustment that works with sww to keep stars away from left and top of screen
  56. nw = 1920
  57.  
  58. ratio = sw / 1920 '                    Used to adjust distances and sizes for various screen modes
  59.  
  60. shw = sh / 20
  61. shn = sh / 40
  62. nh = 1080
  63.  
  64. tt = 0
  65. lcx = sw
  66. rcx = sw
  67. cp = 100
  68. h = 100
  69. ar = 0
  70. rng = 200
  71. slct = 0
  72. strng = ""
  73. strng0 = ""
  74. strng1 = ""
  75. src = 100
  76. dst = 100
  77. ord.src = 100
  78.  
  79. SCREEN _NEWIMAGE(sw, sh, 256) '        creates a screen the resolution of the users native system
  80.  
  81.  
  82. sp = _NEWIMAGE(400 * ratio, 540 * ratio, 256)
  83. op = _NEWIMAGE(400 * ratio, 225 * ratio, 256)
  84.  
  85. StarNames '                            Routine to load star names into string array stars(200)
  86.  
  87. NewGame
  88.  
  89. ttf16 = _LOADFONT("cyberbit.ttf", 16 * ratio, "BOLD")
  90. ttf24 = _LOADFONT("cyberbit.ttf", 24 * ratio, "BOLD")
  91. ttf36 = _LOADFONT("cyberbit.ttf", 36 * ratio, "BOLD")
  92. ttf72 = _LOADFONT("cyberbit.ttf", 72 * ratio, "BOLD")
  93.  
  94. repeat = 1
  95.  
  96. WHILE repeat
  97.  
  98.     _LIMIT 60 '                        Set to 200 frames per second
  99.  
  100.     id = INT(RND * 5 + 2)
  101.  
  102.     CLS
  103.  
  104.     PaintBackground
  105.  
  106.     PaintStars
  107.  
  108.     PaintFleet
  109.  
  110.     GetInput
  111.  
  112.     Player
  113.  
  114.     Computer
  115.  
  116.     _DISPLAY
  117.  
  118.  
  119.  
  120. SUB Computer
  121.     STATIC last(7) AS INTEGER
  122.  
  123.     IF paused = 0 THEN
  124.         RANDOMIZE TIMER
  125.         FOR i = 0 TO 99
  126.             r = INT(RND * 60)
  127.             IF r < star(i).p THEN
  128.                 IF star(i).o > 0 THEN
  129.                     star(i).t = star(i).t + 1
  130.                 ELSE
  131.                     IF INT(RND * 10) < 3 THEN
  132.                         star(i).t = star(i).t + 1
  133.                     END IF
  134.                 END IF
  135.             END IF
  136.         NEXT
  137.  
  138.         org = home(id)
  139.         IF star(org).o <> id THEN
  140.             FOR j = 0 TO 99
  141.                 IF star(j).o = id THEN home(id) = j: EXIT FOR
  142.             NEXT
  143.         END IF
  144.  
  145.         FOR p = 0 TO 3
  146.  
  147.             IF p = 0 THEN
  148.                 away = 10000
  149.                 i = home(id)
  150.                 IF id = hid THEN
  151.                     most = 0
  152.                     FOR j = 0 TO 99
  153.                         IF star(j).o <> hid THEN
  154.                             ok = 0
  155.                             FOR k = 0 TO 99
  156.                                 IF star(k).o = hid THEN
  157.                                     dist = SQR(ABS(star(j).x - star(k).x) ^ 2 + ABS(star(j).y - star(k).y) ^ 2)
  158.                                     IF dist <= 250 THEN
  159.                                         ok = 1
  160.                                         EXIT FOR
  161.                                     END IF
  162.                                 END IF
  163.                             NEXT
  164.                             IF ok = 1 THEN
  165.                                 IF star(j).p >= most THEN
  166.                                     most = star(j).p
  167.                                     jay = j
  168.                                 END IF
  169.                             END IF
  170.                         END IF
  171.                     NEXT
  172.                     IF star(i).t > star(jay).t * 3 THEN
  173.                         SendFleet i, jay, star(i).t / 2
  174.                     END IF
  175.                 ELSE
  176.                     IF star(i).t > LL THEN
  177.                         FOR j = 0 TO 99
  178.                             IF star(j).o <> id AND last(id) <> j THEN
  179.                                 ok = 0
  180.                                 FOR k = 0 TO 99
  181.                                     IF star(k).o = id THEN
  182.                                         dist = SQR(ABS(star(j).x - star(k).x) ^ 2 + ABS(star(j).y - star(k).y) ^ 2)
  183.                                         IF dist <= 250 THEN
  184.                                             ok = 1
  185.                                             EXIT FOR
  186.                                         END IF
  187.                                     END IF
  188.                                 NEXT
  189.                                 IF ok = 1 THEN
  190.                                     dist = SQR(ABS(star(i).x - star(j).x) ^ 2 + ABS(star(i).y - star(j).y) ^ 2)
  191.                                     IF dist < away AND star(i).t > star(j).t * 2 THEN
  192.                                         away = dist
  193.                                         jay = j
  194.                                     END IF
  195.                                 END IF
  196.                             END IF
  197.                         NEXT
  198.                         IF away < 10000 THEN
  199.                             last(id) = jay
  200.                             SendFleet i, jay, star(i).t / 1.5
  201.                         END IF
  202.                     END IF
  203.                 END IF
  204.             END IF
  205.  
  206.             IF p = 1 THEN
  207.                 sf2 = 100
  208.                 FOR i = 0 TO 99
  209.                     IF star(i).o = id AND i <> home(id) AND star(i).t > LL * 1.5 THEN
  210.                         sf3 = star(i).t / 2
  211.                         FOR j = 0 TO 99
  212.                             IF star(j).o <> id AND star(i).t > star(j).t * 4 AND id <> hid THEN
  213.                                 FOR k = 0 TO 99
  214.                                     IF star(k).o = id THEN
  215.                                         dist = SQR(ABS(star(k).x - star(j).x) ^ 2 + ABS(star(k).y - star(j).y) ^ 2)
  216.                                         IF dist <= 250 * ratio THEN
  217.                                             sf1 = i
  218.                                             sf2 = j
  219.                                             EXIT FOR
  220.                                         END IF
  221.                                     END IF
  222.                                 NEXT
  223.                             END IF
  224.                         NEXT
  225.                         IF sf2 < 100 THEN EXIT FOR
  226.                     END IF
  227.                 NEXT
  228.                 IF sf2 < 100 THEN
  229.                     SendFleet sf1, sf2, sf3
  230.                     EXIT FOR
  231.                 END IF
  232.             END IF
  233.  
  234.             IF p = 2 THEN
  235.                 FOR i = 0 TO 99
  236.                     IF i <> home(id) AND star(i).o = id THEN
  237.                         IF star(i).t > 49 THEN
  238.                             ok = 1
  239.                             FOR j = 0 TO 99
  240.                                 IF star(j).o <> id AND star(j).o <> 0 THEN
  241.                                     dist = SQR(ABS(star(i).x - star(j).x) ^ 2 + ABS(star(i).y - star(j).y) ^ 2)
  242.                                     IF dist <= 350 * ratio THEN
  243.                                         ok = 0
  244.                                         EXIT FOR
  245.                                     END IF
  246.                                 END IF
  247.                             NEXT
  248.                             IF ok = 1 THEN
  249.                                 SendFleet i, home(id), star(i).t
  250.                                 EXIT FOR
  251.                             END IF
  252.                         END IF
  253.                     END IF
  254.                 NEXT
  255.                 IF ok = 1 THEN EXIT FOR
  256.             END IF
  257.  
  258.             IF p = 3 THEN
  259.                 ok = 0
  260.                 FOR i = 0 TO 99
  261.                     IF i <> home(id) AND star(i).o = id THEN
  262.                         IF star(i).t > LL * 1.5 + star(i).p * 50 THEN
  263.                             ok = 1
  264.                             EXIT FOR
  265.                         END IF
  266.                     END IF
  267.                 NEXT
  268.                 IF ok = 1 THEN
  269.                     SendFleet i, home(id), star(i).t / 4
  270.                     EXIT FOR
  271.                 END IF
  272.             END IF
  273.  
  274.         NEXT
  275.  
  276.         count = fltcnt
  277.         i = 0
  278.         WHILE count
  279.             IF fleet(i).o <> 0 THEN
  280.                 count = count - 1
  281.                 IF fleet(i).x2 > fleet(i).x1 THEN
  282.                     fleet(i).x1 = fleet(i).x1 + 1
  283.                 END IF
  284.                 IF fleet(i).x2 < fleet(i).x1 THEN
  285.                     fleet(i).x1 = fleet(i).x1 - 1
  286.                 END IF
  287.                 IF fleet(i).y2 > fleet(i).y1 THEN
  288.                     fleet(i).y1 = fleet(i).y1 + 1
  289.                 END IF
  290.                 IF fleet(i).y2 < fleet(i).y1 THEN
  291.                     fleet(i).y1 = fleet(i).y1 - 1
  292.                 END IF
  293.                 IF fleet(i).x1 = fleet(i).x2 AND fleet(i).y1 = fleet(i).y2 THEN
  294.                     dest = fleet(i).d
  295.                     IF star(dest).o = fleet(i).o THEN
  296.                         star(dest).t = star(dest).t + fleet(i).t
  297.                         fleet(i).o = 0
  298.                         fltcnt = fltcnt - 1
  299.                     ELSE
  300.                         IF fleet(i).t > star(dest).t * 0.6 THEN
  301.                             alive = 1
  302.                             WHILE alive
  303.                                 alive = 0
  304.                                 damorg = fleet(i).t / 10 + 1
  305.                                 damdst = star(dest).t / 9 + 1
  306.                                 fleet(i).t = fleet(i).t - damdst
  307.                                 star(dest).t = star(dest).t - damorg
  308.                                 IF fleet(i).t > 0 AND star(dest).t > 0 THEN
  309.                                     alive = 1
  310.                                 END IF
  311.                             WEND
  312.                             IF star(dest).t < 1 THEN
  313.                                 hate(star(dest).o, fleet(i).o) = hate(star(dest).o, fleet(i).o) + 1
  314.                                 star(dest).t = fleet(i).t
  315.                                 star(dest).o = fleet(i).o
  316.                             END IF
  317.                             fleet(i).o = 0
  318.                             fltcnt = fltcnt - 1
  319.                         ELSE
  320.                             k = 100
  321.                             shortest = 10000
  322.                             FOR j = 0 TO 99
  323.                                 IF star(j).o = fleet(i).o THEN
  324.                                     dist = SQR(ABS(star(j).x - fleet(i).x1) ^ 2 + ABS(star(j).y - fleet(i).y1) ^ 2)
  325.                                     IF dist < shortest THEN
  326.                                         shortest = dist
  327.                                         k = j
  328.                                     END IF
  329.                                 END IF
  330.                             NEXT
  331.                             IF k < 100 THEN
  332.                                 fleet(i).x2 = star(k).x
  333.                                 fleet(i).y2 = star(k).y
  334.                                 fleet(i).d = k
  335.                             END IF
  336.                         END IF
  337.                     END IF
  338.                 END IF
  339.             END IF
  340.             i = i + 1
  341.         WEND
  342.     END IF
  343.  
  344. SUB GetInput
  345.  
  346.     IF ch = CHR$(27) THEN repeat = 0
  347.     IF ch = "n" THEN NewGame
  348.     IF ch = "t" THEN tt = 1 - tt
  349.     IF ch = "p" THEN paused = 1 - paused
  350.     ch = INKEY$
  351.  
  352.     lclk = 0
  353.     rclk = 0
  354.  
  355.  
  356.         x = _MOUSEX
  357.         y = _MOUSEY
  358.         lmb = _MOUSEBUTTON(1)
  359.         rmb = _MOUSEBUTTON(2)
  360.  
  361.         IF lmb AND lcx = sw THEN lcx = x
  362.         IF rmb AND rcx = sw THEN rcx = x
  363.     WEND
  364.  
  365.     IF lmb = 0 AND lcx < sw THEN lclk = 1
  366.     IF rmb = 0 AND rcx < sw THEN rclk = 1
  367.  
  368.     lcx = sw
  369.     rcx = sw
  370.  
  371.     x = _MOUSEX
  372.     y = _MOUSEY
  373.  
  374.     IF rclk = 1 THEN
  375.         i = Identify
  376.         IF i = 100 THEN
  377.             IF src = 100 THEN
  378.                 paused = 1 - paused
  379.                 ch = ""
  380.             ELSE
  381.                 src = 100
  382.                 oact = 0
  383.                 pact = 0
  384.             END IF
  385.             rclk = 0
  386.         END IF
  387.         IF pact = 1 OR oact = 1 THEN
  388.             rclk = 0
  389.         END IF
  390.     END IF
  391.  
  392.  
  393. FUNCTION Identify
  394.     ii = 100
  395.     FOR i = 0 TO 99
  396.         dx = star(i).x - x
  397.         dy = star(i).y - y
  398.         IF ABS(dx) <= star(i).s + 8 AND ABS(dy) <= star(i).s + 8 THEN
  399.             ii = i
  400.             EXIT FOR
  401.         END IF
  402.     NEXT
  403.     Identify = ii
  404.  
  405. SUB OrderPanel (i)
  406.     x1 = star(i).x - 420 * ratio
  407.     IF star(i).x < sw / 2 THEN x1 = star(i).x + 20 * ratio
  408.     x2 = x1 + 400 * ratio
  409.     y1 = star(i).y
  410.     IF y1 > sh - 225 * ratio THEN y1 = sh - 225 * ratio
  411.     y2 = y1 + 225 * ratio
  412.     _DEST op
  413.     CLS 0, 8
  414.     COLOR 0, 8
  415.     _FONT ttf72
  416.     n$ = RTRIM$(star(i).n)
  417.     l = _PRINTWIDTH(n$)
  418.     _PRINTSTRING ((400 * ratio - l) / 2, 4 * ratio), n$, op
  419.     LINE (20 * ratio, 76 * ratio)-(380 * ratio, 76 * ratio), 0
  420.     _PRINTSTRING (20 * ratio, 80 * ratio), "0123456789", op
  421.     COLOR 7, 8
  422.     _FONT ttf36
  423.     IF box = 0 THEN
  424.         _PRINTSTRING (20 * ratio, 166 * ratio), "If Over", op
  425.         xo = 142 * ratio: xd = 250 * ratio: yo = 166 * ratio: yd = 200 * ratio
  426.         LINE (xo, yo)-(xd, yd), 7, BF
  427.         xo = 268 * ratio: xd = 314 * ratio: yo = 166 * ratio: yd = 200 * ratio
  428.         LINE (xo, yo)-(xd, yd), 7, BF
  429.         xo = 332 * ratio: xd = 366 * ratio: yo = 166 * ratio: yd = 200 * ratio
  430.         LINE (xo, yo)-(xd, yd), 7, BF
  431.         n$ = RTRIM$(strng0)
  432.         COLOR 0, 7
  433.         _FONT ttf24
  434.         _PRINTSTRING (148 * ratio, 172 * ratio), n$, op
  435.         _PRINTSTRING (273 * ratio, 172 * ratio), "OK", op
  436.         _PRINTSTRING (341 * ratio, 172 * ratio), "X", op
  437.     END IF
  438.     IF box = 1 THEN
  439.         _PRINTSTRING (20 * ratio, 166 * ratio), "Then Send", op
  440.         xo = 198 * ratio: xd = 278 * ratio: yo = 166 * ratio: yd = 200 * ratio
  441.         LINE (xo, yo)-(xd, yd), 7, BF
  442.         xo = 294 * ratio: xd = 340 * ratio: yo = 166 * ratio: yd = 200 * ratio
  443.         LINE (xo, yo)-(xd, yd), 7, BF
  444.         xo = 356 * ratio: xd = 390 * ratio: yo = 166 * ratio: yd = 200 * ratio
  445.         LINE (xo, yo)-(xd, yd), 7, BF
  446.         n$ = RTRIM$(strng1)
  447.         COLOR 0, 7
  448.         _FONT ttf24
  449.         _PRINTSTRING (200 * ratio, 172 * ratio), n$, op
  450.         _PRINTSTRING (299 * ratio, 172 * ratio), "OK", op
  451.         _PRINTSTRING (365 * ratio, 172 * ratio), "X", op
  452.     END IF
  453.     _PUTIMAGE (x1, y1), op, 0, (0, 0)-(400 * ratio, 225 * ratio)
  454.     _DEST 0
  455.     oanx = x1: oany = y1
  456.  
  457. SUB PaintBackground
  458.     x = RND * sw
  459.     y = RND * sh
  460.     c = RND * 14 + 1
  461.     PSET (x, y), c
  462.     RANDOMIZE USING seed
  463.     FOR i = 1 TO 600 * ratio
  464.         x = RND * sw
  465.         y = RND * sh
  466.         c = RND * 14 + 1
  467.         PSET (x, y), c
  468.     NEXT
  469.  
  470. SUB PaintFleet
  471.     count = fltcnt
  472.     i = 0
  473.     WHILE count
  474.         IF fleet(i).o <> 0 THEN
  475.             CIRCLE (fleet(i).x1, fleet(i).y1), 3, fleet(i).o + 8
  476.             count = count - 1
  477.         END IF
  478.         i = i + 1
  479.     WEND
  480.  
  481. SUB PaintStars
  482.     FOR i = 0 TO 99
  483.         c = star(i).c
  484.         x = star(i).x
  485.         y = star(i).y
  486.         o = star(i).o
  487.         CIRCLE (x, y), (star(i).s + 8) * ratio, c
  488.         COLOR 15
  489.         IF o > 0 THEN
  490.             PAINT (x, y), o + 8, c
  491.         END IF
  492.         _FONT ttf16
  493.         IF tt THEN
  494.             n$ = star(i).n
  495.             n$ = RTRIM$(n$)
  496.             l = _PRINTWIDTH(n$)
  497.             _PRINTSTRING (x + 10, y), STR$(star(i).p), 0
  498.         ELSE
  499.             n$ = STR$(star(i).t)
  500.             l = _PRINTWIDTH(n$)
  501.         END IF
  502.         _PRINTSTRING (x - l / 2, y + 14), n$, 0
  503.     NEXT
  504.  
  505. SUB Player
  506.     'Add new order to standing orders
  507.     IF ord.src <> 100 THEN
  508.         i = ord.src
  509.         IF ord.shp = 0 THEN
  510.             order(i).src = 100
  511.         ELSE
  512.             order(i) = ord
  513.         END IF
  514.         src = 100
  515.         ord.src = 100
  516.     END IF
  517.  
  518.     'execute standing orders
  519.     FOR i = 0 TO 99
  520.         IF order(i).src <> 100 THEN
  521.             IF star(i).o <> 1 THEN
  522.                 order(i).src = 100
  523.             ELSE
  524.                 LINE (star(i).x, star(i).y)-(star(order(i).dst).x, star(order(i).dst).y), 17
  525.                 IF star(i).t >= order(i).ovr THEN
  526.                     SendFleet order(i).src, order(i).dst, order(i).shp
  527.                 END IF
  528.             END IF
  529.         END IF
  530.     NEXT
  531.  
  532.     IF pact = 0 AND oact = 0 THEN
  533.  
  534.         'If there is no source star see if we can get one
  535.         IF src = 100 THEN
  536.             IF lclk = 1 OR rclk = 1 THEN
  537.                 lclk = 0
  538.                 rclk = 0
  539.                 src = Identify
  540.             END IF
  541.         END IF
  542.  
  543.         ' If there is a source star then look for a right click else draw a range line
  544.         IF src <> 100 THEN
  545.             c = 12
  546.             FOR i = 0 TO 99
  547.                 IF star(i).o = 1 THEN
  548.                     dist = SQR(ABS(star(i).x - x) ^ 2 + ABS(star(i).y - y) ^ 2)
  549.                     IF dist <= 250 * ratio THEN
  550.                         c = 10
  551.                         EXIT FOR
  552.                     END IF
  553.                 END IF
  554.             NEXT
  555.             i = Identify
  556.             IF i <> 100 THEN
  557.                 x = star(i).x
  558.                 y = star(i).y
  559.             END IF
  560.             rang = SQR(ABS(star(src).x - x) ^ 2 + ABS(star(src).y - y) ^ 2)
  561.             LINE (star(src).x, star(src).y)-(x, y), c
  562.             n$ = STR$(INT(rang))
  563.             _FONT ttf16
  564.             _PRINTSTRING (x + 20, y), n$, 0
  565.         END IF
  566.  
  567.         'If we have a source star see if we clicked on a destination star
  568.         IF src <> 100 THEN
  569.             IF lclk = 1 OR rclk = 1 THEN
  570.                 i = Identify
  571.                 IF i < 100 AND i <> src THEN
  572.                     IF lclk = 1 THEN
  573.                         lclk = 0
  574.                         FOR j = 0 TO 99
  575.                             IF star(j).o = 1 THEN
  576.                                 dist = SQR(ABS(star(i).x - star(j).x) ^ 2 + ABS(star(i).y - star(j).y) ^ 2)
  577.                                 IF dist <= 250 THEN
  578.                                     dst = i
  579.                                     pact = 1
  580.                                     EXIT FOR
  581.                                 END IF
  582.                             END IF
  583.                         NEXT
  584.                     ELSE
  585.                         rclk = 0
  586.                         dst = i
  587.                         IF star(i).o = 1 THEN
  588.                             oact = 1
  589.                         END IF
  590.                     END IF
  591.                 END IF
  592.             END IF
  593.         END IF
  594.  
  595.     END IF
  596.  
  597.     'If the star standing orders panel is active
  598.     IF oact = 1 THEN
  599.  
  600.         IF star(src).o = 1 THEN
  601.             OrderPanel dst
  602.         END IF
  603.  
  604.         IF rclk = 1 THEN oact = 0
  605.  
  606.         IF box = 0 THEN
  607.             tmp$ = RTRIM$(strng0)
  608.         ELSE
  609.             tmp$ = RTRIM$(strng1)
  610.         END IF
  611.  
  612.         IF lclk = 1 THEN
  613.  
  614.             x1 = oanx: x2 = oanx + 400 * ratio
  615.             y1 = oany: y2 = oany + 540 * ratio
  616.  
  617.             IF y > y1 + 80 * ratio AND y < y1 + 152 * ratio THEN
  618.                 IF x > x1 + 20 * ratio AND x < x1 + 380 * ratio THEN
  619.                     dig = (x - x1 - 32 * ratio) / (37 * ratio)
  620.                     IF box = 0 THEN
  621.                         n$ = RTRIM$(strng0)
  622.                         l = LEN(n$)
  623.                         IF l < 8 THEN strng0 = tmp$ + STR$(dig)
  624.                     ELSE
  625.                         n$ = RTRIM$(strng1)
  626.                         l = LEN(n$)
  627.                         IF l < 8 THEN strng1 = tmp$ + STR$(dig)
  628.                     END IF
  629.                 END IF
  630.             END IF
  631.  
  632.             IF y > y1 + 166 * ratio AND y < y1 + 200 * ratio THEN
  633.  
  634.                 IF box = 0 THEN
  635.  
  636.                     IF x > x1 + 268 * ratio AND x < x1 + 314 * ratio THEN
  637.                         ord.ovr = INT(VAL(strng0))
  638.                         box = 1
  639.                     END IF
  640.  
  641.                     IF x > x1 + 332 * ratio AND x < x1 + 366 * ratio THEN
  642.                         strng0 = ""
  643.                     END IF
  644.  
  645.                 ELSE
  646.  
  647.                     IF x > x1 + 294 * ratio AND x < x1 + 340 * ratio THEN
  648.                         IF INT(VAL(strng1)) > ord.ovr THEN
  649.                             strng1 = ""
  650.                         ELSE
  651.                             box = 0
  652.                             oact = 0
  653.                             ord.src = src
  654.                             ord.dst = dst
  655.                             ord.shp = VAL(strng1)
  656.                             strng0 = ""
  657.                             strng1 = ""
  658.                         END IF
  659.                     END IF
  660.  
  661.                     IF x > x1 + 356 * ratio AND x < x1 + 390 * ratio THEN
  662.                         strng0 = ""
  663.                         strng1 = ""
  664.                         box = 0
  665.                     END IF
  666.  
  667.                 END IF
  668.  
  669.             END IF
  670.         END IF
  671.         x1 = 10000: y1 = 10000
  672.  
  673.     END IF
  674.  
  675.  
  676.     'If the fleet send panel is active
  677.     IF pact = 1 THEN
  678.         IF rclk = 1 THEN pact = 0
  679.         IF star(src).o = 1 THEN
  680.             ShowPanel dst
  681.         END IF
  682.         IF lclk = 1 THEN
  683.             tmp$ = RTRIM$(strng)
  684.  
  685.             x1 = panx: x2 = panx + 400 * ratio
  686.             y1 = pany: y2 = pany + 540 * ratio
  687.  
  688.             IF y > y1 + 256 * ratio AND y < y1 + 328 * ratio THEN
  689.                 IF x > x1 + 20 * ratio AND x < x1 + 380 * ratio THEN
  690.                     dig = (x - x1 - 32 * ratio) / (37 * ratio)
  691.                     strng = tmp$ + STR$(dig)
  692.                 END IF
  693.             END IF
  694.  
  695.             IF y > y1 + 334 * ratio AND y < y1 + 374 * ratio THEN
  696.                 IF x > x1 + 20 * ratio AND x < x1 + 84 * ratio THEN
  697.                     pact = 0
  698.                     value = star(src).t
  699.                     SendFleet src, dst, value
  700.                     src = 100
  701.                 END IF
  702.                 IF x > x1 + 102 * ratio AND x < x1 + 184 * ratio THEN
  703.                     pact = 0
  704.                     value = star(src).t / 2
  705.                     SendFleet src, dst, value
  706.                     src = 100
  707.                 END IF
  708.                 IF x > x1 + 202 * ratio AND x < x1 + 282 * ratio THEN
  709.                     pact = 0
  710.                     value = star(src).t / 3
  711.                     SendFleet src, dst, value
  712.                     src = 100
  713.                 END IF
  714.                 IF x > x1 + 300 * ratio AND x < x1 + 380 * ratio THEN
  715.                     strng = ""
  716.                 END IF
  717.             END IF
  718.  
  719.             IF y > y1 + 460 * ratio AND y < y1 + 530 * ratio THEN
  720.                 IF x > x1 + 32 * ratio AND x < x1 + 182 * ratio THEN
  721.                     value = VAL(strng)
  722.                     strng = ""
  723.                     pact = 0
  724.                     IF value <= star(src).t THEN
  725.                         SendFleet src, dst, value
  726.                     END IF
  727.                     src = 100
  728.                 END IF
  729.                 IF x > x1 + 212 * ratio AND x < x1 + 362 * ratio THEN
  730.                     pact = 0
  731.                     src = 100
  732.                     strng = ""
  733.                 END IF
  734.             END IF
  735.         END IF
  736.     END IF
  737.  
  738. SUB SendFleet (src, dst, ships)
  739.     FOR i = 0 TO 999
  740.         IF fleet(i).o = 0 THEN
  741.             fleet(i).o = star(src).o
  742.             fleet(i).d = dst
  743.             fleet(i).x1 = star(src).x
  744.             fleet(i).y1 = star(src).y
  745.             fleet(i).x2 = star(dst).x
  746.             fleet(i).y2 = star(dst).y
  747.             fleet(i).t = ships
  748.             star(src).t = star(src).t - ships
  749.             fltcnt = fltcnt + 1
  750.             EXIT FOR
  751.         END IF
  752.     NEXT
  753.     LL = LL + 1
  754.  
  755. SUB ShowPanel (i)
  756.     x1 = star(i).x - 420 * ratio
  757.     IF star(i).x < sw / 2 THEN x1 = star(i).x + 20 * ratio
  758.     x2 = x1 + 400 * ratio
  759.     y1 = star(i).y
  760.     IF y1 > sh - 560 * ratio THEN y1 = sh - 560 * ratio
  761.     y2 = y1 + 540 * ratio
  762.     _DEST sp
  763.     CLS 0, 8
  764.     COLOR 0, 8
  765.     _FONT ttf72
  766.     n$ = RTRIM$(star(src).n)
  767.     l = _PRINTWIDTH(n$)
  768.     _PRINTSTRING ((400 * ratio - l) / 2, 12 * ratio), n$, sp
  769.     n$ = "to"
  770.     l = _PRINTWIDTH(n$)
  771.     _PRINTSTRING ((400 * ratio - l) / 2, 80 * ratio), n$, sp
  772.     n$ = RTRIM$(star(dst).n)
  773.     l = _PRINTWIDTH(n$)
  774.     _PRINTSTRING ((400 * ratio - l) / 2, 152 * ratio), n$, sp
  775.     LINE (20 * ratio, 239 * ratio)-(380 * ratio, 239 * ratio), 0
  776.     _PRINTSTRING (20 * ratio, 256 * ratio), "0123456789", sp
  777.     n$ = RTRIM$(strng)
  778.     l = _PRINTWIDTH(n$)
  779.     _PRINTSTRING ((400 * ratio - l) / 2, 383 * ratio), n$, sp
  780.     xo = 20 * ratio: xd = 84 * ratio: yo = 334 * ratio: yd = 374 * ratio
  781.     LINE (xo, yo)-(xd, yd), 7, BF
  782.     xo = 102 * ratio: xd = 184 * ratio: yo = 334 * ratio: yd = 374 * ratio
  783.     LINE (xo, yo)-(xd, yd), 7, BF
  784.     xo = 202 * ratio: xd = 282 * ratio: yo = 334 * ratio: yd = 374 * ratio
  785.     LINE (xo, yo)-(xd, yd), 7, BF
  786.     xo = 300 * ratio: xd = 380 * ratio: yo = 334 * ratio: yd = 374 * ratio
  787.     LINE (xo, yo)-(xd, yd), 7, BF
  788.     xo = 32 * ratio: xd = 182 * ratio: yo = 458 * ratio: yd = 530 * ratio
  789.     LINE (xo, yo)-(xd, yd), 7, BF
  790.     xo = 212 * ratio: xd = 362 * ratio: yo = 458 * ratio: yd = 530 * ratio
  791.     LINE (xo, yo)-(xd, yd), 7, BF
  792.     _FONT ttf24
  793.     COLOR 7, 8
  794.     n$ = RTRIM$(STR$(star(src).t))
  795.     l = _PRINTWIDTH(n$)
  796.     _PRINTSTRING (120 * ratio - l, 112 * ratio), n$, sp
  797.     n$ = RTRIM$(STR$(star(dst).t))
  798.     l = _PRINTWIDTH(n$)
  799.     _PRINTSTRING (300 * ratio - l, 112 * ratio), n$, sp
  800.     _FONT ttf16
  801.     COLOR 0, 7
  802.     _PRINTSTRING (38 * ratio, 347 * ratio), "ALL", sp
  803.     _PRINTSTRING (122 * ratio, 347 * ratio), "HALF", sp
  804.     _PRINTSTRING (214 * ratio, 347 * ratio), "THIRD", sp
  805.     _PRINTSTRING (312 * ratio, 347 * ratio), "CLEAR", sp
  806.     _FONT ttf72
  807.     _PRINTSTRING (60 * ratio, 458 * ratio), "Ok", sp
  808.     _PRINTSTRING (216 * ratio, 458 * ratio), "Quit", sp
  809.     _PUTIMAGE (x1, y1), sp, 0, (0, 0)-(400 * ratio, 540 * ratio)
  810.     panx = x1: pany = y1
  811.     _DEST 0
  812.  
  813. SUB NewGame
  814.     DIM k AS INTEGER
  815.     DIM r AS INTEGER
  816.     DIM dx AS INTEGER
  817.     DIM dy AS INTEGER
  818.     DIM n AS STRING * 10
  819.     paused = 1
  820.     FOR i = 0 TO 999
  821.         fleet(i).o = 0
  822.     NEXT
  823.     slct = 0
  824.     fltcnt = 0
  825.     LL = 25
  826.     seed = RND * 1000
  827.     FOR i = 0 TO 99
  828.         k = 1
  829.         WHILE k
  830.             k = 0
  831.             x = RND * (sw - sww) + swn
  832.             y = RND * (sh - shw) + shn
  833.             r = INT(RND * 200)
  834.             n = names(r)
  835.             FOR j = 0 TO i - 1
  836.                 dx = x - star(j).x
  837.                 dy = y - star(j).y
  838.                 IF ABS(dx) < sww AND ABS(dy) < shw THEN
  839.                     k = 1
  840.                 END IF
  841.                 IF n = star(j).n THEN
  842.                     k = 1
  843.                 END IF
  844.             NEXT
  845.         WEND
  846.         star(i).n = n
  847.         star(i).x = x
  848.         star(i).y = y
  849.         star(i).c = RND * 6 + 9
  850.         star(i).s = RND * 5
  851.         star(i).o = 0
  852.         star(i).p = star(i).s + (RND * 5) + 3
  853.         star(i).t = 0
  854.         order(i).src = 100
  855.     NEXT
  856.     FOR i = 1 TO 6
  857.         ok = 0
  858.         WHILE (ok < 1)
  859.             ok = 1
  860.             j = RND * 100
  861.             FOR k = 1 TO i - 1
  862.                 dist = SQR(ABS(star(j).x - star(home(k)).x) ^ 2 + ABS(star(j).y - star(home(k)).y) ^ 2)
  863.                 IF dist < 500 * ratio THEN
  864.                     ok = 0
  865.                     EXIT FOR
  866.                 END IF
  867.             NEXT
  868.             IF ok = 1 THEN
  869.                 ok = -1
  870.                 FOR k = 0 TO 99
  871.                     dist = SQR(ABS(star(j).x - star(k).x) ^ 2 + ABS(star(j).y - star(k).y) ^ 2)
  872.                     IF dist <= 200 THEN ok = ok + 1
  873.                     IF ok = 1 THEN EXIT FOR
  874.                 NEXT
  875.             END IF
  876.         WEND
  877.         home(i) = j
  878.         star(j).o = i
  879.         star(j).p = 10
  880.         star(j).t = 100
  881.         star(j).s = 4
  882.     NEXT
  883.     star(home(1)).n = "Sol"
  884.     star(home(1)).c = 14
  885.     away = 0
  886.     from = home(1)
  887.     FOR i = 2 TO 6
  888.         too = home(i)
  889.         dist = SQR(ABS(star(from).x - star(too).x ^ 2 - ABS(star(from).y - star(too).y) ^ 2))
  890.         IF dist > away THEN
  891.             away = dist
  892.             hid = i
  893.         END IF
  894.     NEXT
  895.  
  896. ' A lot of star names I made up
  897.  
  898. SUB StarNames
  899.     names(0) = "Acamar"
  900.     names(1) = "Arcab"
  901.     names(2) = "Acrux"
  902.     names(3) = "Adhara"
  903.     names(4) = "Arneb"
  904.     names(5) = "Antares"
  905.     names(6) = "Arcturus"
  906.     names(7) = "Atria"
  907.     names(8) = "Beid"
  908.     names(9) = "Betelgeuse"
  909.     names(10) = "Botein"
  910.     names(11) = "Beemim"
  911.     names(12) = "Bellatrix"
  912.     names(13) = "Bharani"
  913.     names(14) = "Biham"
  914.     names(15) = "Brachium"
  915.     names(16) = "Canopus"
  916.     names(17) = "Capella"
  917.     names(18) = "Castor"
  918.     names(19) = "Chara"
  919.     names(20) = "Cursa"
  920.     names(21) = "Copernicus"
  921.     names(22) = "Chalawan"
  922.     names(23) = "Chertan"
  923.     names(24) = "Dabih"
  924.     names(25) = "Dalim"
  925.     names(26) = "Deneb"
  926.     names(27) = "Denebola"
  927.     names(28) = "Diadem"
  928.     names(29) = "Diphda"
  929.     names(30) = "Dschubba"
  930.     names(31) = "Dziban"
  931.     names(32) = "Edasich"
  932.     names(33) = "Electra"
  933.     names(34) = "Elgafar"
  934.     names(35) = "Elkurud"
  935.     names(36) = "Elnath"
  936.     names(37) = "Eltanin"
  937.     names(38) = "Enif"
  938.     names(39) = "Errai"
  939.     names(40) = "Fafnir"
  940.     names(41) = "Fang"
  941.     names(42) = "Fawaris"
  942.     names(43) = "Felis"
  943.     names(44) = "Fomalhaut"
  944.     names(45) = "Fulu"
  945.     names(46) = "Fumal"
  946.     names(47) = "Furud"
  947.     names(48) = "Garnet"
  948.     names(49) = "Giausar"
  949.     names(50) = "Gienah"
  950.     names(51) = "Ginan"
  951.     names(52) = "Gomeisa"
  952.     names(53) = "Graffias"
  953.     names(54) = "Grumium"
  954.     names(55) = "Gudja"
  955.     names(56) = "Hadar"
  956.     names(57) = "Haedus"
  957.     names(58) = "Hamal"
  958.     names(59) = "Hassaleh"
  959.     names(60) = "Hatysa"
  960.     names(61) = "Helvetios"
  961.     names(62) = "Heze"
  962.     names(63) = "Homan"
  963.     names(64) = "Iklil"
  964.     names(65) = "Imai"
  965.     names(66) = "Intercrus"
  966.     names(67) = "Izar"
  967.     names(68) = "Iccar"
  968.     names(69) = "Inar"
  969.     names(70) = "Iaeth"
  970.     names(71) = "Imaous"
  971.     names(72) = "Jabbah"
  972.     names(73) = "Jishui"
  973.     names(74) = "Jax"
  974.     names(75) = "Jalae"
  975.     names(76) = "Jewel"
  976.     names(77) = "Jumbo"
  977.     names(78) = "Jerue"
  978.     names(79) = "Jabear"
  979.     names(80) = "Kakkab"
  980.     names(81) = "Kang"
  981.     names(82) = "Kekouan"
  982.     names(83) = "Keid"
  983.     names(84) = "Kitalpha"
  984.     names(85) = "Kochab"
  985.     names(86) = "Kolob"
  986.     names(87) = "Kobol"
  987.     names(88) = "Larawag"
  988.     names(89) = "Lesath"
  989.     names(90) = "Libertas"
  990.     names(91) = "Lich"
  991.     names(92) = "Lilly"
  992.     names(93) = "Laddel"
  993.     names(94) = "Luminous"
  994.     names(95) = "Lasacious"
  995.     names(96) = "Mizar"
  996.     names(97) = "Markab"
  997.     names(98) = "Matar"
  998.     names(99) = "Mintaka"
  999.     names(100) = "Meleph"
  1000.     names(101) = "Menkar"
  1001.     names(102) = "Merga"
  1002.     names(103) = "Merope"
  1003.     names(104) = "Nahn"
  1004.     names(105) = "Naos"
  1005.     names(106) = "Nashira"
  1006.     names(107) = "Navi"
  1007.     names(108) = "Nekkar"
  1008.     names(109) = "Nembus"
  1009.     names(110) = "Nihal"
  1010.     names(111) = "Nunki"
  1011.     names(112) = "Ogma"
  1012.     names(113) = "Okab"
  1013.     names(114) = "Ohmy"
  1014.     names(115) = "Oragami"
  1015.     names(116) = "Origen"
  1016.     names(117) = "Omanii"
  1017.     names(118) = "Obytewa"
  1018.     names(119) = "Oglok"
  1019.     names(120) = "Phact"
  1020.     names(121) = "Pherkad"
  1021.     names(122) = "Pleione"
  1022.     names(122) = "Polaris"
  1023.     names(123) = "Pollux"
  1024.     names(124) = "Procyon"
  1025.     names(125) = "Proxima"
  1026.     names(126) = "Polis"
  1027.     names(127) = "Quaint"
  1028.     names(128) = "Quazzat"
  1029.     names(129) = "Quetzal"
  1030.     names(130) = "Qussol"
  1031.     names(131) = "Quella"
  1032.     names(132) = "Quyaeo"
  1033.     names(133) = "Ququdas"
  1034.     names(134) = "Quekak"
  1035.     names(135) = "Rasalas"
  1036.     names(136) = "Regor"
  1037.     names(137) = "Regulus"
  1038.     names(138) = "Rigel"
  1039.     names(139) = "Revati"
  1040.     names(140) = "Rotenev"
  1041.     names(141) = "Rukbat"
  1042.     names(142) = "Rastaban"
  1043.     names(143) = "Sabik"
  1044.     names(144) = "Sadr"
  1045.     names(145) = "Saiph"
  1046.     names(146) = "Sargas"
  1047.     names(147) = "Sarin"
  1048.     names(148) = "Syrma"
  1049.     names(149) = "Spica"
  1050.     names(150) = "Sirius"
  1051.     names(151) = "Tarazed"
  1052.     names(152) = "Taygeta"
  1053.     names(153) = "Tejat"
  1054.     names(154) = "Thabit"
  1055.     names(155) = "Thuban"
  1056.     names(156) = "Tiaki"
  1057.     names(157) = "Toliman"
  1058.     names(158) = "Torcular"
  1059.     names(157) = "Umala"
  1060.     names(158) = "Ulatte"
  1061.     names(159) = "Ubbessa"
  1062.     names(160) = "Unoless"
  1063.     names(161) = "Umaddem"
  1064.     names(162) = "Ummbra"
  1065.     names(162) = "Uniqu"
  1066.     names(163) = "Uzzaal"
  1067.     names(164) = "Vega"
  1068.     names(165) = "Veritate"
  1069.     names(166) = "Vindetrix"
  1070.     names(167) = "Vedas"
  1071.     names(168) = "Vergg"
  1072.     names(169) = "Vacant"
  1073.     names(170) = "Vucae"
  1074.     names(171) = "Vicar"
  1075.     names(172) = "Wasat"
  1076.     names(173) = "Wazn"
  1077.     names(174) = "Wezen"
  1078.     names(175) = "Waiten"
  1079.     names(176) = "Wachar"
  1080.     names(177) = "Wheelz"
  1081.     names(178) = "Whatsp"
  1082.     names(179) = "Wassand"
  1083.     names(180) = "Xenno"
  1084.     names(181) = "Xyphod"
  1085.     names(182) = "Xu"
  1086.     names(183) = "Xaal"
  1087.     names(184) = "Xyross"
  1088.     names(185) = "Xiggot"
  1089.     names(186) = "Xirrks"
  1090.     names(187) = "Yed"
  1091.     names(188) = "Yildun"
  1092.     names(189) = "Yundun"
  1093.     names(190) = "Yavyo"
  1094.     names(191) = "Yotrac"
  1095.     names(192) = "Yxzoqu"
  1096.     names(193) = "Ynnot"
  1097.     names(194) = "Zaniah"
  1098.     names(195) = "Zaurak"
  1099.     names(196) = "Zhang"
  1100.     names(197) = "Zibal"
  1101.     names(198) = "Zosma"
  1102.     names(199) = "Zuben"
  1103.  
My name is Michael, but you can call me Mike :)

Offline romichess

  • Forum Regular
  • Posts: 145
    • View Profile
Re: Beyond Sol
« Reply #27 on: December 30, 2019, 07:25:47 pm »
 The instructions are in the attachment.

Starbases are still in development. To do them well is proving more difficult than expected. When and where to build them is not easy. Unless one gets off to a good start it is very hard to beat the computer. If beating the computer is too difficult I may add starbases for the human player first.

Code: QB64: [Select]
  1. TYPE stars
  2.     n AS STRING * 10 '                 Name of star
  3.     x AS INTEGER '                     x-position
  4.     y AS INTEGER '                     y-position
  5.     o AS INTEGER '                     Owner
  6.     c AS INTEGER '                     Color
  7.     s AS INTEGER '                     Size
  8.     t AS LONG '                        Ships
  9.     p AS INTEGER '
  10.     d AS INTEGER '                   (Population) For now ships production
  11.  
  12. TYPE FLEETS
  13.     t AS LONG
  14.     x1 AS INTEGER
  15.     y1 AS INTEGER
  16.     x2 AS INTEGER
  17.     y2 AS INTEGER
  18.     o AS INTEGER
  19.     d AS INTEGER
  20.  
  21. TYPE ORDERS
  22.     src AS LONG
  23.     ovr AS LONG
  24.     shp AS LONG
  25.     dst AS LONG
  26.  
  27. ' Global variables shared because they are needed in more than one routine
  28. DIM SHARED sw AS INTEGER '             Screen Width
  29. DIM SHARED sh AS INTEGER '             Screen Height
  30. DIM SHARED sww AS INTEGER '            Screen Width Wide margin
  31. DIM SHARED swn AS INTEGER '            Screen Width Narrow adjustment
  32. DIM SHARED shw AS INTEGER '            Screen Height Wide margine
  33. DIM SHARED shn AS INTEGER '            Screen Height Narrow adjustment
  34. DIM SHARED nw AS INTEGER '             games Natural screen Width
  35. DIM SHARED nh AS INTEGER '             games Natural screen Height
  36. DIM SHARED ratio AS _FLOAT '           the Ratio of the games natural screen width to the actual
  37. DIM SHARED star(100) AS stars '        100 stars - may change
  38. DIM SHARED names(200) AS STRING * 10 ' 200 star names
  39. DIM SHARED seed AS INTEGER '           Seed to prime the Randomizer to display identical background each frame
  40. DIM SHARED home(7) AS INTEGER '        The starting star for each player. The human always has star(0), Sol
  41. DIM SHARED tt AS INTEGER '             tt = 0 star names displayed, tt = 0 star names not didplayed
  42. DIM SHARED ch AS STRING * 1 '          Game loop key input variable
  43. DIM SHARED repeat AS INTEGER '         Game loop control variable
  44. DIM SHARED fleet(2000) AS FLEETS
  45. DIM SHARED panx, pany AS INTEGER
  46. DIM SHARED oanx, oany AS INTEGER
  47. DIM SHARED strng AS STRING * 14
  48. 'DIM SHARED hate(7, 7) AS INTEGER
  49. DIM SHARED strng0 AS STRING * 10
  50. DIM SHARED strng1 AS STRING * 10
  51. DIM SHARED order(100) AS ORDERS
  52. DIM SHARED ord AS ORDERS
  53. DIM SHARED hate(7, 7) AS LONG
  54.  
  55.  
  56. sw = _DESKTOPWIDTH '                   native video with of syatem
  57. sww = sw / 24 '                        margin based on native video width to keep stars away from edge
  58. swn = sw / 48 '                        adjustment that works with sww to keep stars away from left and top of screen
  59. nw = 1920
  60.  
  61. ratio = sw / 1920 '                    Used to adjust distances and sizes for various screen modes
  62.  
  63. shw = sh / 20
  64. shn = sh / 40
  65. nh = 1080
  66.  
  67. tt = 0
  68. lcx = sw
  69. rcx = sw
  70. cp = 100
  71. h = 100
  72. ar = 0
  73. rng = 200
  74. slct = 0
  75. strng = ""
  76. strng0 = ""
  77. strng1 = ""
  78. src = 100
  79. dst = 100
  80. ord.src = 100
  81.  
  82. SCREEN _NEWIMAGE(sw, sh, 256) '        creates a screen the resolution of the users native system
  83.  
  84.  
  85. sp = _NEWIMAGE(400 * ratio, 540 * ratio, 256)
  86. op = _NEWIMAGE(400 * ratio, 225 * ratio, 256)
  87.  
  88. StarNames '                            Routine to load star names into string array stars(200)
  89.  
  90. NewGame
  91.  
  92. ttf16 = _LOADFONT("cyberbit.ttf", 16 * ratio, "BOLD")
  93. ttf24 = _LOADFONT("cyberbit.ttf", 24 * ratio, "BOLD")
  94. ttf36 = _LOADFONT("cyberbit.ttf", 36 * ratio, "BOLD")
  95. ttf72 = _LOADFONT("cyberbit.ttf", 72 * ratio, "BOLD")
  96.  
  97. repeat = 1
  98.  
  99. WHILE repeat
  100.  
  101.     id = INT(RND * 5 + 2)
  102.  
  103.     CLS
  104.  
  105.     PaintBackground
  106.  
  107.     PaintStars
  108.  
  109.     PaintFleet
  110.  
  111.     FOR it = 0 TO speed
  112.  
  113.         GetInput
  114.  
  115.         Player
  116.  
  117.         Computer
  118.  
  119.     NEXT
  120.  
  121.     PRINT LL
  122.  
  123.     _DISPLAY
  124.  
  125.  
  126.  
  127. SUB Computer
  128.  
  129.     IF paused = 0 THEN
  130.         RANDOMIZE TIMER
  131.         FOR i = 0 TO 99
  132.             r = INT(RND * 60)
  133.             IF r < star(i).p THEN
  134.                 IF star(i).o > 0 THEN
  135.                     star(i).t = star(i).t + 1
  136.                 ELSE
  137.                     IF INT(RND * 10) < 3 THEN
  138.                         star(i).t = star(i).t + 1
  139.                     END IF
  140.                 END IF
  141.             END IF
  142.         NEXT
  143.  
  144.         i = home(id)
  145.         IF star(i).o <> id THEN
  146.             FOR j = 0 TO 99
  147.                 IF star(j).o = id THEN home(id) = j: i = j: EXIT FOR
  148.             NEXT
  149.         END IF
  150.  
  151.         dis = 0
  152.         hid = 0
  153.         FOR j = 1 TO 6
  154.             IF j <> id THEN
  155.                 IF hate(id, j) > dis THEN
  156.                     dis = hate(id, j)
  157.                     hid = j
  158.                 END IF
  159.             END IF
  160.         NEXT
  161.  
  162.         FOR p = 0 TO 3
  163.  
  164.             IF p = 0 THEN
  165.                 IF star(i).t > LL THEN
  166.                     away = 10000
  167.                     jay = 100
  168.                     FOR j = 0 TO 99
  169.                         IF star(j).d > 0 THEN
  170.                             star(j).d = star(j).d - 1
  171.                         ELSE
  172.                             IF star(j).o = hid THEN th = 3 ELSE th = 4
  173.                             IF star(j).o <> id AND star(i).t > star(j).t * th THEN
  174.                                 ok = 0
  175.                                 FOR k = 0 TO 99
  176.                                     IF star(k).o = id THEN
  177.                                         dist = SQR(ABS(star(j).x - star(k).x) ^ 2 + ABS(star(j).y - star(k).y) ^ 2)
  178.                                         IF dist < 251 THEN
  179.                                             ok = 1
  180.                                             EXIT FOR
  181.                                         END IF
  182.                                     END IF
  183.                                 NEXT
  184.                                 IF ok = 1 THEN
  185.                                     dist = SQR(ABS(star(j).x - star(i).x) ^ 2 + ABS(star(j).y - star(i).y) ^ 2)
  186.                                     IF dist < away THEN
  187.                                         away = dist
  188.                                         jay = j
  189.                                     END IF
  190.                                 END IF
  191.                             END IF
  192.                         END IF
  193.                     NEXT
  194.                     IF jay < 100 THEN
  195.                         SendFleet i, jay, star(i).t / 1.5
  196.                         star(jay).d = 1000
  197.                     END IF
  198.                 END IF
  199.             END IF
  200.  
  201.             IF p = 1 THEN
  202.                 sf2 = 100
  203.                 FOR i = 0 TO 99
  204.                     IF star(i).o = id AND i <> home(id) AND star(i).t > LL * 1.5 THEN
  205.                         sf3 = star(i).t / 2
  206.                         FOR j = 0 TO 99
  207.                             IF star(j).d > 0 THEN
  208.                                 star(j).d = star(j).d - 1
  209.                             ELSE
  210.                                 IF star(j).o <> id AND star(i).t > star(j).t * 4 THEN
  211.                                     FOR k = 0 TO 99
  212.                                         IF star(k).o = id THEN
  213.                                             dist = SQR(ABS(star(k).x - star(j).x) ^ 2 + ABS(star(k).y - star(j).y) ^ 2)
  214.                                             IF dist <= 250 * ratio THEN
  215.                                                 sf1 = i
  216.                                                 sf2 = j
  217.                                                 EXIT FOR
  218.                                             END IF
  219.                                         END IF
  220.                                     NEXT
  221.                                 END IF
  222.                             END IF
  223.                         NEXT
  224.                         IF sf2 < 100 THEN EXIT FOR
  225.                     END IF
  226.                 NEXT
  227.                 IF sf2 < 100 THEN
  228.                     SendFleet sf1, sf2, sf3
  229.                     star(sf2).d = 1000
  230.                     EXIT FOR
  231.                 END IF
  232.             END IF
  233.  
  234.             IF p = 2 THEN
  235.                 FOR i = 0 TO 99
  236.                     IF i <> home(id) AND star(i).o = id THEN
  237.                         IF star(i).t > LL / 2 THEN
  238.                             ok = 1
  239.                             FOR j = 0 TO 99
  240.                                 IF star(j).o <> id AND star(j).o <> 0 THEN
  241.                                     dist = SQR(ABS(star(i).x - star(j).x) ^ 2 + ABS(star(i).y - star(j).y) ^ 2)
  242.                                     IF dist <= 350 * ratio THEN
  243.                                         ok = 0
  244.                                         EXIT FOR
  245.                                     END IF
  246.                                 END IF
  247.                             NEXT
  248.                             IF ok = 1 THEN
  249.                                 SendFleet i, home(id), star(i).t / 2
  250.                                 EXIT FOR
  251.                             END IF
  252.                         END IF
  253.                     END IF
  254.                 NEXT
  255.                 IF ok = 1 THEN EXIT FOR
  256.             END IF
  257.  
  258.             IF p = 3 THEN
  259.                 ok = 0
  260.                 FOR i = 0 TO 99
  261.                     IF i <> home(id) AND star(i).o = id THEN
  262.                         IF star(i).t > LL * 1.5 + star(i).p * 50 THEN
  263.                             ok = 1
  264.                             EXIT FOR
  265.                         END IF
  266.                     END IF
  267.                 NEXT
  268.                 IF ok = 1 THEN
  269.                     SendFleet i, home(id), star(i).t / 4
  270.                     EXIT FOR
  271.                 END IF
  272.             END IF
  273.  
  274.         NEXT
  275.  
  276.         count = fltcnt
  277.         i = 0
  278.         WHILE count
  279.             IF fleet(i).o <> 0 THEN
  280.                 count = count - 1
  281.                 IF fleet(i).x2 > fleet(i).x1 THEN
  282.                     fleet(i).x1 = fleet(i).x1 + 1
  283.                 END IF
  284.                 IF fleet(i).x2 < fleet(i).x1 THEN
  285.                     fleet(i).x1 = fleet(i).x1 - 1
  286.                 END IF
  287.                 IF fleet(i).y2 > fleet(i).y1 THEN
  288.                     fleet(i).y1 = fleet(i).y1 + 1
  289.                 END IF
  290.                 IF fleet(i).y2 < fleet(i).y1 THEN
  291.                     fleet(i).y1 = fleet(i).y1 - 1
  292.                 END IF
  293.                 IF fleet(i).x1 = fleet(i).x2 AND fleet(i).y1 = fleet(i).y2 THEN
  294.                     dest = fleet(i).d
  295.                     IF star(dest).o = fleet(i).o THEN
  296.                         star(dest).t = star(dest).t + fleet(i).t
  297.                         fleet(i).o = 0
  298.                         fltcnt = fltcnt - 1
  299.                     ELSE
  300.                         o = star(dest).o
  301.                         IF o > 0 AND star(dest).t < fleet(i).t * 0.6 THEN
  302.                             SendFleet dest, home(o), star(dest).t * 0.9
  303.                             star(dest).t = 0
  304.                             star(dest).o = fleet(i).o
  305.                             star(dest).t = fleet(i).t
  306.                             star(dest).o = fleet(i).o
  307.                             fleet(i).o = 0
  308.                             fltcnt = fltcnt - 1
  309.                         ELSE
  310.                             IF fleet(i).t * 1.1 > star(dest).t THEN
  311.                                 alive = 1
  312.                                 WHILE alive
  313.                                     alive = 0
  314.                                     damorg = fleet(i).t / 10 + 1
  315.                                     damdst = star(dest).t / 8 + 1
  316.                                     fleet(i).t = fleet(i).t - damdst
  317.                                     star(dest).t = star(dest).t - damorg
  318.                                     IF fleet(i).t > 0 AND star(dest).t > 0 THEN
  319.                                         alive = 1
  320.                                     END IF
  321.                                 WEND
  322.                                 IF star(dest).t < 1 THEN
  323.                                     star(dest).t = fleet(i).t
  324.                                     star(dest).o = fleet(i).o
  325.                                 END IF
  326.                                 fleet(i).o = 0
  327.                                 fltcnt = fltcnt - 1
  328.                             ELSE
  329.                                 k = 100
  330.                                 shortest = 10000
  331.                                 FOR j = 0 TO 99
  332.                                     IF star(j).o = fleet(i).o THEN
  333.                                         dist = SQR(ABS(star(j).x - fleet(i).x1) ^ 2 + ABS(star(j).y - fleet(i).y1) ^ 2)
  334.                                         IF dist < shortest THEN
  335.                                             shortest = dist
  336.                                             k = j
  337.                                         END IF
  338.                                     END IF
  339.                                 NEXT
  340.                                 IF k < 100 THEN
  341.                                     fleet(i).x2 = star(k).x
  342.                                     fleet(i).y2 = star(k).y
  343.                                     fleet(i).d = k
  344.                                 ELSE
  345.                                     fleet(i).o = 0
  346.                                     fltcnt = fltcnt - 1
  347.                                 END IF
  348.                             END IF
  349.                         END IF
  350.                     END IF
  351.                 END IF
  352.             END IF
  353.             i = i + 1
  354.         WEND
  355.     END IF
  356.  
  357. SUB GetInput
  358.  
  359.     IF ch = CHR$(27) THEN repeat = 0
  360.     IF ch = "n" THEN NewGame
  361.     IF ch = "t" THEN tt = 1 - tt
  362.     IF ch = "p" THEN paused = 1 - paused
  363.     IF ch = "+" THEN
  364.         IF speed < 10 THEN speed = speed + 1
  365.     END IF
  366.     IF ch = "-" THEN
  367.         IF speed > 0 THEN speed = speed - 1
  368.     END IF
  369.     ch = INKEY$
  370.  
  371.  
  372.     lclk = 0
  373.     rclk = 0
  374.  
  375.  
  376.         x = _MOUSEX
  377.         y = _MOUSEY
  378.         lmb = _MOUSEBUTTON(1)
  379.         rmb = _MOUSEBUTTON(2)
  380.  
  381.         IF lmb AND lcx = sw THEN lcx = x
  382.         IF rmb AND rcx = sw THEN rcx = x
  383.     WEND
  384.  
  385.     IF lmb = 0 AND lcx < sw THEN lclk = 1
  386.     IF rmb = 0 AND rcx < sw THEN rclk = 1
  387.  
  388.     lcx = sw
  389.     rcx = sw
  390.  
  391.     x = _MOUSEX
  392.     y = _MOUSEY
  393.  
  394.     IF rclk = 1 THEN
  395.         i = Identify
  396.         IF i = 100 THEN
  397.             IF src = 100 THEN
  398.                 paused = 1 - paused
  399.                 ch = ""
  400.             ELSE
  401.                 src = 100
  402.                 oact = 0
  403.                 pact = 0
  404.             END IF
  405.             rclk = 0
  406.         END IF
  407.         IF pact = 1 OR oact = 1 THEN
  408.             rclk = 0
  409.         END IF
  410.     END IF
  411.  
  412.  
  413. FUNCTION Identify
  414.     ii = 100
  415.     FOR i = 0 TO 99
  416.         dx = star(i).x - x
  417.         dy = star(i).y - y
  418.         IF ABS(dx) <= star(i).s + 8 AND ABS(dy) <= star(i).s + 8 THEN
  419.             ii = i
  420.             EXIT FOR
  421.         END IF
  422.     NEXT
  423.     Identify = ii
  424.  
  425. SUB OrderPanel (i)
  426.     x1 = star(i).x - 420 * ratio
  427.     IF star(i).x < sw / 2 THEN x1 = star(i).x + 20 * ratio
  428.     x2 = x1 + 400 * ratio
  429.     y1 = star(i).y
  430.     IF y1 > sh - 225 * ratio THEN y1 = sh - 225 * ratio
  431.     y2 = y1 + 225 * ratio
  432.     _DEST op
  433.     CLS 0, 8
  434.     COLOR 0, 8
  435.     _FONT ttf72
  436.     n$ = RTRIM$(star(i).n)
  437.     l = _PRINTWIDTH(n$)
  438.     _PRINTSTRING ((400 * ratio - l) / 2, 4 * ratio), n$, op
  439.     LINE (20 * ratio, 76 * ratio)-(380 * ratio, 76 * ratio), 0
  440.     _PRINTSTRING (20 * ratio, 80 * ratio), "0123456789", op
  441.     COLOR 7, 8
  442.     _FONT ttf36
  443.     IF box = 0 THEN
  444.         _PRINTSTRING (20 * ratio, 166 * ratio), "If Over", op
  445.         xo = 142 * ratio: xd = 250 * ratio: yo = 166 * ratio: yd = 200 * ratio
  446.         LINE (xo, yo)-(xd, yd), 7, BF
  447.         xo = 268 * ratio: xd = 314 * ratio: yo = 166 * ratio: yd = 200 * ratio
  448.         LINE (xo, yo)-(xd, yd), 7, BF
  449.         xo = 332 * ratio: xd = 366 * ratio: yo = 166 * ratio: yd = 200 * ratio
  450.         LINE (xo, yo)-(xd, yd), 7, BF
  451.         n$ = RTRIM$(strng0)
  452.         COLOR 0, 7
  453.         _FONT ttf24
  454.         _PRINTSTRING (148 * ratio, 172 * ratio), n$, op
  455.         _PRINTSTRING (273 * ratio, 172 * ratio), "OK", op
  456.         _PRINTSTRING (341 * ratio, 172 * ratio), "X", op
  457.     END IF
  458.     IF box = 1 THEN
  459.         _PRINTSTRING (20 * ratio, 166 * ratio), "Then Send", op
  460.         xo = 198 * ratio: xd = 278 * ratio: yo = 166 * ratio: yd = 200 * ratio
  461.         LINE (xo, yo)-(xd, yd), 7, BF
  462.         xo = 294 * ratio: xd = 340 * ratio: yo = 166 * ratio: yd = 200 * ratio
  463.         LINE (xo, yo)-(xd, yd), 7, BF
  464.         xo = 356 * ratio: xd = 390 * ratio: yo = 166 * ratio: yd = 200 * ratio
  465.         LINE (xo, yo)-(xd, yd), 7, BF
  466.         n$ = RTRIM$(strng1)
  467.         COLOR 0, 7
  468.         _FONT ttf24
  469.         _PRINTSTRING (200 * ratio, 172 * ratio), n$, op
  470.         _PRINTSTRING (299 * ratio, 172 * ratio), "OK", op
  471.         _PRINTSTRING (365 * ratio, 172 * ratio), "X", op
  472.     END IF
  473.     _PUTIMAGE (x1, y1), op, 0, (0, 0)-(400 * ratio, 225 * ratio)
  474.     _DEST 0
  475.     oanx = x1: oany = y1
  476.  
  477. SUB PaintBackground
  478.     x = RND * sw
  479.     y = RND * sh
  480.     c = RND * 14 + 1
  481.     PSET (x, y), c
  482.     RANDOMIZE USING seed
  483.     FOR i = 1 TO 600 * ratio
  484.         x = RND * sw
  485.         y = RND * sh
  486.         c = RND * 14 + 1
  487.         PSET (x, y), c
  488.     NEXT
  489.  
  490. SUB PaintFleet
  491.     count = fltcnt
  492.     i = 0
  493.     WHILE count
  494.         IF fleet(i).o <> 0 THEN
  495.             CIRCLE (fleet(i).x1, fleet(i).y1), 3, fleet(i).o + 8
  496.             count = count - 1
  497.         END IF
  498.         i = i + 1
  499.     WEND
  500.  
  501. SUB PaintStars
  502.     FOR i = 0 TO 99
  503.         c = star(i).c
  504.         x = star(i).x
  505.         y = star(i).y
  506.         o = star(i).o
  507.         CIRCLE (x, y), (star(i).s + 8) * ratio, c
  508.         COLOR 15
  509.         IF o > 0 THEN
  510.             PAINT (x, y), o + 8, c
  511.         END IF
  512.         _FONT ttf16
  513.         IF tt THEN
  514.             n$ = star(i).n
  515.             n$ = RTRIM$(n$)
  516.             l = _PRINTWIDTH(n$)
  517.             _PRINTSTRING (x + 10, y), STR$(star(i).p), 0
  518.         ELSE
  519.             n$ = STR$(star(i).t)
  520.             l = _PRINTWIDTH(n$)
  521.         END IF
  522.         _PRINTSTRING (x - l / 2, y + 14), n$, 0
  523.     NEXT
  524.  
  525. SUB Player
  526.     'Add new order to standing orders
  527.     IF ord.src <> 100 THEN
  528.         i = ord.src
  529.         IF ord.shp = 0 THEN
  530.             order(i).src = 100
  531.         ELSE
  532.             order(i) = ord
  533.         END IF
  534.         src = 100
  535.         ord.src = 100
  536.     END IF
  537.  
  538.     'execute standing orders
  539.     FOR i = 0 TO 99
  540.         IF order(i).src <> 100 THEN
  541.             IF star(i).o <> 1 OR star(order(i).dst).o <> 1 THEN
  542.                 order(i).src = 100
  543.             ELSE
  544.                 LINE (star(i).x, star(i).y)-(star(order(i).dst).x, star(order(i).dst).y), 17
  545.                 IF star(i).t >= order(i).ovr THEN
  546.                     SendFleet order(i).src, order(i).dst, order(i).shp
  547.                 END IF
  548.             END IF
  549.         END IF
  550.     NEXT
  551.  
  552.     IF pact = 0 AND oact = 0 THEN
  553.  
  554.         'If there is no source star see if we can get one
  555.         IF src = 100 THEN
  556.             IF lclk = 1 OR rclk = 1 THEN
  557.                 lclk = 0
  558.                 rclk = 0
  559.                 src = Identify
  560.             END IF
  561.         END IF
  562.  
  563.         ' If there is a source star then look for a right click else draw a range line
  564.         IF src <> 100 THEN
  565.             c = 12
  566.             FOR i = 0 TO 99
  567.                 IF star(i).o = 1 THEN
  568.                     dist = SQR(ABS(star(i).x - x) ^ 2 + ABS(star(i).y - y) ^ 2)
  569.                     IF dist <= 251 * ratio THEN
  570.                         c = 10
  571.                         EXIT FOR
  572.                     END IF
  573.                 END IF
  574.             NEXT
  575.             i = Identify
  576.             IF i <> 100 THEN
  577.                 x = star(i).x
  578.                 y = star(i).y
  579.             END IF
  580.             rang = SQR(ABS(star(src).x - x) ^ 2 + ABS(star(src).y - y) ^ 2)
  581.             LINE (star(src).x, star(src).y)-(x, y), c
  582.             n$ = STR$(INT(rang))
  583.             _FONT ttf16
  584.             _PRINTSTRING (x + 20, y), n$, 0
  585.         END IF
  586.  
  587.         'If we have a source star see if we clicked on a destination star
  588.         IF src <> 100 THEN
  589.             IF lclk = 1 OR rclk = 1 THEN
  590.                 i = Identify
  591.                 IF i < 100 AND i <> src THEN
  592.                     IF lclk = 1 THEN
  593.                         lclk = 0
  594.                         FOR j = 0 TO 99
  595.                             IF star(j).o = 1 THEN
  596.                                 dist = SQR(ABS(star(i).x - star(j).x) ^ 2 + ABS(star(i).y - star(j).y) ^ 2)
  597.                                 IF dist <= 250 THEN
  598.                                     dst = i
  599.                                     pact = 1
  600.                                     EXIT FOR
  601.                                 END IF
  602.                             END IF
  603.                         NEXT
  604.                     ELSE
  605.                         rclk = 0
  606.                         dst = i
  607.                         IF star(i).o = 1 THEN
  608.                             oact = 1
  609.                         END IF
  610.                     END IF
  611.                 END IF
  612.             END IF
  613.         END IF
  614.  
  615.     END IF
  616.  
  617.     'If the star standing orders panel is active
  618.     IF oact = 1 THEN
  619.  
  620.         IF star(src).o = 1 THEN
  621.             OrderPanel dst
  622.         END IF
  623.  
  624.         IF rclk = 1 THEN oact = 0
  625.  
  626.         IF box = 0 THEN
  627.             tmp$ = RTRIM$(strng0)
  628.         ELSE
  629.             tmp$ = RTRIM$(strng1)
  630.         END IF
  631.  
  632.         IF lclk = 1 THEN
  633.  
  634.             x1 = oanx: x2 = oanx + 400 * ratio
  635.             y1 = oany: y2 = oany + 540 * ratio
  636.  
  637.             IF y > y1 + 80 * ratio AND y < y1 + 152 * ratio THEN
  638.                 IF x > x1 + 20 * ratio AND x < x1 + 380 * ratio THEN
  639.                     dig = (x - x1 - 32 * ratio) / (37 * ratio)
  640.                     IF box = 0 THEN
  641.                         n$ = RTRIM$(strng0)
  642.                         l = LEN(n$)
  643.                         IF l < 8 THEN strng0 = tmp$ + STR$(dig)
  644.                     ELSE
  645.                         n$ = RTRIM$(strng1)
  646.                         l = LEN(n$)
  647.                         IF l < 8 THEN strng1 = tmp$ + STR$(dig)
  648.                     END IF
  649.                 END IF
  650.             END IF
  651.  
  652.             IF y > y1 + 166 * ratio AND y < y1 + 200 * ratio THEN
  653.  
  654.                 IF box = 0 THEN
  655.  
  656.                     IF x > x1 + 268 * ratio AND x < x1 + 314 * ratio THEN
  657.                         ord.ovr = INT(VAL(strng0))
  658.                         box = 1
  659.                     END IF
  660.  
  661.                     IF x > x1 + 332 * ratio AND x < x1 + 366 * ratio THEN
  662.                         strng0 = ""
  663.                     END IF
  664.  
  665.                 ELSE
  666.  
  667.                     IF x > x1 + 294 * ratio AND x < x1 + 340 * ratio THEN
  668.                         IF INT(VAL(strng1)) > ord.ovr THEN
  669.                             strng1 = ""
  670.                         ELSE
  671.                             box = 0
  672.                             oact = 0
  673.                             ord.src = src
  674.                             ord.dst = dst
  675.                             ord.shp = VAL(strng1)
  676.                             strng0 = ""
  677.                             strng1 = ""
  678.                         END IF
  679.                     END IF
  680.  
  681.                     IF x > x1 + 356 * ratio AND x < x1 + 390 * ratio THEN
  682.                         strng0 = ""
  683.                         strng1 = ""
  684.                         box = 0
  685.                     END IF
  686.  
  687.                 END IF
  688.  
  689.             END IF
  690.         END IF
  691.         x1 = 10000: y1 = 10000
  692.  
  693.     END IF
  694.  
  695.  
  696.     'If the fleet send panel is active
  697.     IF pact = 1 THEN
  698.         IF rclk = 1 THEN pact = 0
  699.         IF star(src).o = 1 THEN
  700.             ShowPanel dst
  701.         END IF
  702.         IF lclk = 1 THEN
  703.             tmp$ = RTRIM$(strng)
  704.  
  705.             x1 = panx: x2 = panx + 400 * ratio
  706.             y1 = pany: y2 = pany + 540 * ratio
  707.  
  708.             IF y > y1 + 256 * ratio AND y < y1 + 328 * ratio THEN
  709.                 IF x > x1 + 20 * ratio AND x < x1 + 380 * ratio THEN
  710.                     dig = (x - x1 - 32 * ratio) / (37 * ratio)
  711.                     strng = tmp$ + STR$(dig)
  712.                 END IF
  713.             END IF
  714.  
  715.             IF y > y1 + 334 * ratio AND y < y1 + 374 * ratio THEN
  716.                 IF x > x1 + 20 * ratio AND x < x1 + 84 * ratio THEN
  717.                     pact = 0
  718.                     value = star(src).t
  719.                     SendFleet src, dst, value
  720.                     src = 100
  721.                 END IF
  722.                 IF x > x1 + 102 * ratio AND x < x1 + 184 * ratio THEN
  723.                     pact = 0
  724.                     value = star(src).t / 2
  725.                     SendFleet src, dst, value
  726.                     src = 100
  727.                 END IF
  728.                 IF x > x1 + 202 * ratio AND x < x1 + 282 * ratio THEN
  729.                     pact = 0
  730.                     value = star(src).t / 3
  731.                     SendFleet src, dst, value
  732.                     src = 100
  733.                 END IF
  734.                 IF x > x1 + 300 * ratio AND x < x1 + 380 * ratio THEN
  735.                     strng = ""
  736.                 END IF
  737.             END IF
  738.  
  739.             IF y > y1 + 460 * ratio AND y < y1 + 530 * ratio THEN
  740.                 IF x > x1 + 32 * ratio AND x < x1 + 182 * ratio THEN
  741.                     value = VAL(strng)
  742.                     strng = ""
  743.                     pact = 0
  744.                     IF value <= star(src).t AND star(src).t <> o THEN
  745.                         SendFleet src, dst, value
  746.                     END IF
  747.                     src = 100
  748.                 END IF
  749.                 IF x > x1 + 212 * ratio AND x < x1 + 362 * ratio THEN
  750.                     pact = 0
  751.                     src = 100
  752.                     strng = ""
  753.                 END IF
  754.             END IF
  755.         END IF
  756.     END IF
  757.  
  758. SUB SendFleet (src, dst, ships)
  759.     IF fltcnt < 2000 THEN
  760.         hate(star(src).o, star(dst).o) = hate(star(src).o, star(dst).o) + 1
  761.         FOR i = 0 TO 1999
  762.             IF fleet(i).o = 0 THEN
  763.                 fleet(i).o = star(src).o
  764.                 fleet(i).d = dst
  765.                 fleet(i).x1 = star(src).x
  766.                 fleet(i).y1 = star(src).y
  767.                 fleet(i).x2 = star(dst).x
  768.                 fleet(i).y2 = star(dst).y
  769.                 fleet(i).t = ships
  770.                 star(src).t = star(src).t - ships
  771.                 fltcnt = fltcnt + 1
  772.                 EXIT FOR
  773.             END IF
  774.         NEXT
  775.         LL = LL + 1
  776.         IF LL > 20000 THEN LL = 20000
  777.     END IF
  778.  
  779. SUB ShowPanel (i)
  780.     x1 = star(i).x - 420 * ratio
  781.     IF star(i).x < sw / 2 THEN x1 = star(i).x + 20 * ratio
  782.     x2 = x1 + 400 * ratio
  783.     y1 = star(i).y
  784.     IF y1 > sh - 560 * ratio THEN y1 = sh - 560 * ratio
  785.     y2 = y1 + 540 * ratio
  786.     _DEST sp
  787.     CLS 0, 8
  788.     COLOR 0, 8
  789.     _FONT ttf72
  790.     n$ = RTRIM$(star(src).n)
  791.     l = _PRINTWIDTH(n$)
  792.     _PRINTSTRING ((400 * ratio - l) / 2, 12 * ratio), n$, sp
  793.     n$ = "to"
  794.     l = _PRINTWIDTH(n$)
  795.     _PRINTSTRING ((400 * ratio - l) / 2, 80 * ratio), n$, sp
  796.     n$ = RTRIM$(star(dst).n)
  797.     l = _PRINTWIDTH(n$)
  798.     _PRINTSTRING ((400 * ratio - l) / 2, 152 * ratio), n$, sp
  799.     LINE (20 * ratio, 239 * ratio)-(380 * ratio, 239 * ratio), 0
  800.     _PRINTSTRING (20 * ratio, 256 * ratio), "0123456789", sp
  801.     n$ = RTRIM$(strng)
  802.     l = _PRINTWIDTH(n$)
  803.     _PRINTSTRING ((400 * ratio - l) / 2, 383 * ratio), n$, sp
  804.     xo = 20 * ratio: xd = 84 * ratio: yo = 334 * ratio: yd = 374 * ratio
  805.     LINE (xo, yo)-(xd, yd), 7, BF
  806.     xo = 102 * ratio: xd = 184 * ratio: yo = 334 * ratio: yd = 374 * ratio
  807.     LINE (xo, yo)-(xd, yd), 7, BF
  808.     xo = 202 * ratio: xd = 282 * ratio: yo = 334 * ratio: yd = 374 * ratio
  809.     LINE (xo, yo)-(xd, yd), 7, BF
  810.     xo = 300 * ratio: xd = 380 * ratio: yo = 334 * ratio: yd = 374 * ratio
  811.     LINE (xo, yo)-(xd, yd), 7, BF
  812.     xo = 32 * ratio: xd = 182 * ratio: yo = 458 * ratio: yd = 530 * ratio
  813.     LINE (xo, yo)-(xd, yd), 7, BF
  814.     xo = 212 * ratio: xd = 362 * ratio: yo = 458 * ratio: yd = 530 * ratio
  815.     LINE (xo, yo)-(xd, yd), 7, BF
  816.     _FONT ttf24
  817.     COLOR 7, 8
  818.     n$ = RTRIM$(STR$(star(src).t))
  819.     l = _PRINTWIDTH(n$)
  820.     _PRINTSTRING (120 * ratio - l, 112 * ratio), n$, sp
  821.     n$ = RTRIM$(STR$(star(dst).t))
  822.     l = _PRINTWIDTH(n$)
  823.     _PRINTSTRING (300 * ratio - l, 112 * ratio), n$, sp
  824.     _FONT ttf16
  825.     COLOR 0, 7
  826.     _PRINTSTRING (38 * ratio, 347 * ratio), "ALL", sp
  827.     _PRINTSTRING (122 * ratio, 347 * ratio), "HALF", sp
  828.     _PRINTSTRING (214 * ratio, 347 * ratio), "THIRD", sp
  829.     _PRINTSTRING (312 * ratio, 347 * ratio), "CLEAR", sp
  830.     _FONT ttf72
  831.     _PRINTSTRING (60 * ratio, 458 * ratio), "Ok", sp
  832.     _PRINTSTRING (216 * ratio, 458 * ratio), "Quit", sp
  833.     _PUTIMAGE (x1, y1), sp, 0, (0, 0)-(400 * ratio, 540 * ratio)
  834.     panx = x1: pany = y1
  835.     _DEST 0
  836.  
  837. SUB NewGame
  838.     DIM k AS INTEGER
  839.     DIM r AS INTEGER
  840.     DIM dx AS INTEGER
  841.     DIM dy AS INTEGER
  842.     DIM n AS STRING * 10
  843.     paused = 1
  844.     FOR i = 0 TO 999
  845.         fleet(i).o = 0
  846.     NEXT
  847.     slct = 0
  848.     fltcnt = 0
  849.     LL = 25
  850.     seed = RND * 1000
  851.     FOR i = 0 TO 99
  852.         k = 1
  853.         WHILE k
  854.             k = 0
  855.             x = RND * (sw - sww) + swn
  856.             y = RND * (sh - shw) + shn
  857.             r = INT(RND * 200)
  858.             n = names(r)
  859.             FOR j = 0 TO i - 1
  860.                 dx = x - star(j).x
  861.                 dy = y - star(j).y
  862.                 IF ABS(dx) < sww AND ABS(dy) < shw THEN
  863.                     k = 1
  864.                 END IF
  865.                 IF n = star(j).n THEN
  866.                     k = 1
  867.                 END IF
  868.             NEXT
  869.         WEND
  870.         star(i).n = n
  871.         star(i).x = x
  872.         star(i).y = y
  873.         star(i).c = RND * 6 + 9
  874.         star(i).s = RND * 5
  875.         star(i).o = 0
  876.         star(i).p = star(i).s + (RND * 5) + 3
  877.         star(i).t = 0
  878.         order(i).src = 100
  879.     NEXT
  880.     FOR i = 1 TO 6
  881.         ok = 0
  882.         WHILE (ok < 1)
  883.             ok = 1
  884.             j = RND * 100
  885.             FOR k = 1 TO i - 1
  886.                 dist = SQR(ABS(star(j).x - star(home(k)).x) ^ 2 + ABS(star(j).y - star(home(k)).y) ^ 2)
  887.                 IF dist < 500 * ratio THEN
  888.                     ok = 0
  889.                     EXIT FOR
  890.                 END IF
  891.             NEXT
  892.             IF ok = 1 THEN
  893.                 ok = -1
  894.                 FOR k = 0 TO 99
  895.                     dist = SQR(ABS(star(j).x - star(k).x) ^ 2 + ABS(star(j).y - star(k).y) ^ 2)
  896.                     IF dist <= 200 THEN ok = ok + 1
  897.                     IF ok = 2 THEN EXIT FOR
  898.                 NEXT
  899.             END IF
  900.         WEND
  901.         home(i) = j
  902.         star(j).o = i
  903.         star(j).p = 10
  904.         star(j).t = 100
  905.         star(j).s = 4
  906.     NEXT
  907.     star(home(1)).n = "Sol"
  908.     star(home(1)).c = 14
  909.  
  910. ' A lot of star names I made up
  911.  
  912. SUB StarNames
  913.     names(0) = "Acamar"
  914.     names(1) = "Arcab"
  915.     names(2) = "Acrux"
  916.     names(3) = "Adhara"
  917.     names(4) = "Arneb"
  918.     names(5) = "Antares"
  919.     names(6) = "Arcturus"
  920.     names(7) = "Atria"
  921.     names(8) = "Beid"
  922.     names(9) = "Betelgeuse"
  923.     names(10) = "Botein"
  924.     names(11) = "Beemim"
  925.     names(12) = "Bellatrix"
  926.     names(13) = "Bharani"
  927.     names(14) = "Biham"
  928.     names(15) = "Brachium"
  929.     names(16) = "Canopus"
  930.     names(17) = "Capella"
  931.     names(18) = "Castor"
  932.     names(19) = "Chara"
  933.     names(20) = "Cursa"
  934.     names(21) = "Copernicus"
  935.     names(22) = "Chalawan"
  936.     names(23) = "Chertan"
  937.     names(24) = "Dabih"
  938.     names(25) = "Dalim"
  939.     names(26) = "Deneb"
  940.     names(27) = "Denebola"
  941.     names(28) = "Diadem"
  942.     names(29) = "Diphda"
  943.     names(30) = "Dschubba"
  944.     names(31) = "Dziban"
  945.     names(32) = "Edasich"
  946.     names(33) = "Electra"
  947.     names(34) = "Elgafar"
  948.     names(35) = "Elkurud"
  949.     names(36) = "Elnath"
  950.     names(37) = "Eltanin"
  951.     names(38) = "Enif"
  952.     names(39) = "Errai"
  953.     names(40) = "Fafnir"
  954.     names(41) = "Fang"
  955.     names(42) = "Fawaris"
  956.     names(43) = "Felis"
  957.     names(44) = "Fomalhaut"
  958.     names(45) = "Fulu"
  959.     names(46) = "Fumal"
  960.     names(47) = "Furud"
  961.     names(48) = "Garnet"
  962.     names(49) = "Giausar"
  963.     names(50) = "Gienah"
  964.     names(51) = "Ginan"
  965.     names(52) = "Gomeisa"
  966.     names(53) = "Graffias"
  967.     names(54) = "Grumium"
  968.     names(55) = "Gudja"
  969.     names(56) = "Hadar"
  970.     names(57) = "Haedus"
  971.     names(58) = "Hamal"
  972.     names(59) = "Hassaleh"
  973.     names(60) = "Hatysa"
  974.     names(61) = "Helvetios"
  975.     names(62) = "Heze"
  976.     names(63) = "Homan"
  977.     names(64) = "Iklil"
  978.     names(65) = "Imai"
  979.     names(66) = "Intercrus"
  980.     names(67) = "Izar"
  981.     names(68) = "Iccar"
  982.     names(69) = "Inar"
  983.     names(70) = "Iaeth"
  984.     names(71) = "Imaous"
  985.     names(72) = "Jabbah"
  986.     names(73) = "Jishui"
  987.     names(74) = "Jax"
  988.     names(75) = "Jalae"
  989.     names(76) = "Jewel"
  990.     names(77) = "Jumbo"
  991.     names(78) = "Jerue"
  992.     names(79) = "Jabear"
  993.     names(80) = "Kakkab"
  994.     names(81) = "Kang"
  995.     names(82) = "Kekouan"
  996.     names(83) = "Keid"
  997.     names(84) = "Kitalpha"
  998.     names(85) = "Kochab"
  999.     names(86) = "Kolob"
  1000.     names(87) = "Kobol"
  1001.     names(88) = "Larawag"
  1002.     names(89) = "Lesath"
  1003.     names(90) = "Libertas"
  1004.     names(91) = "Lich"
  1005.     names(92) = "Lilly"
  1006.     names(93) = "Laddel"
  1007.     names(94) = "Luminous"
  1008.     names(95) = "Lasacious"
  1009.     names(96) = "Mizar"
  1010.     names(97) = "Markab"
  1011.     names(98) = "Matar"
  1012.     names(99) = "Mintaka"
  1013.     names(100) = "Meleph"
  1014.     names(101) = "Menkar"
  1015.     names(102) = "Merga"
  1016.     names(103) = "Merope"
  1017.     names(104) = "Nahn"
  1018.     names(105) = "Naos"
  1019.     names(106) = "Nashira"
  1020.     names(107) = "Navi"
  1021.     names(108) = "Nekkar"
  1022.     names(109) = "Nembus"
  1023.     names(110) = "Nihal"
  1024.     names(111) = "Nunki"
  1025.     names(112) = "Ogma"
  1026.     names(113) = "Okab"
  1027.     names(114) = "Ohmy"
  1028.     names(115) = "Oragami"
  1029.     names(116) = "Origen"
  1030.     names(117) = "Omanii"
  1031.     names(118) = "Obytewa"
  1032.     names(119) = "Oglok"
  1033.     names(120) = "Phact"
  1034.     names(121) = "Pherkad"
  1035.     names(122) = "Pleione"
  1036.     names(122) = "Polaris"
  1037.     names(123) = "Pollux"
  1038.     names(124) = "Procyon"
  1039.     names(125) = "Proxima"
  1040.     names(126) = "Polis"
  1041.     names(127) = "Quaint"
  1042.     names(128) = "Quazzat"
  1043.     names(129) = "Quetzal"
  1044.     names(130) = "Qussol"
  1045.     names(131) = "Quella"
  1046.     names(132) = "Quyaeo"
  1047.     names(133) = "Ququdas"
  1048.     names(134) = "Quekak"
  1049.     names(135) = "Rasalas"
  1050.     names(136) = "Regor"
  1051.     names(137) = "Regulus"
  1052.     names(138) = "Rigel"
  1053.     names(139) = "Revati"
  1054.     names(140) = "Rotenev"
  1055.     names(141) = "Rukbat"
  1056.     names(142) = "Rastaban"
  1057.     names(143) = "Sabik"
  1058.     names(144) = "Sadr"
  1059.     names(145) = "Saiph"
  1060.     names(146) = "Sargas"
  1061.     names(147) = "Sarin"
  1062.     names(148) = "Syrma"
  1063.     names(149) = "Spica"
  1064.     names(150) = "Sirius"
  1065.     names(151) = "Tarazed"
  1066.     names(152) = "Taygeta"
  1067.     names(153) = "Tejat"
  1068.     names(154) = "Thabit"
  1069.     names(155) = "Thuban"
  1070.     names(156) = "Tiaki"
  1071.     names(157) = "Toliman"
  1072.     names(158) = "Torcular"
  1073.     names(157) = "Umala"
  1074.     names(158) = "Ulatte"
  1075.     names(159) = "Ubbessa"
  1076.     names(160) = "Unoless"
  1077.     names(161) = "Umaddem"
  1078.     names(162) = "Ummbra"
  1079.     names(162) = "Uniqu"
  1080.     names(163) = "Uzzaal"
  1081.     names(164) = "Vega"
  1082.     names(165) = "Veritate"
  1083.     names(166) = "Vindetrix"
  1084.     names(167) = "Vedas"
  1085.     names(168) = "Vergg"
  1086.     names(169) = "Vacant"
  1087.     names(170) = "Vucae"
  1088.     names(171) = "Vicar"
  1089.     names(172) = "Wasat"
  1090.     names(173) = "Wazn"
  1091.     names(174) = "Wezen"
  1092.     names(175) = "Waiten"
  1093.     names(176) = "Wachar"
  1094.     names(177) = "Wheelz"
  1095.     names(178) = "Whatsp"
  1096.     names(179) = "Wassand"
  1097.     names(180) = "Xenno"
  1098.     names(181) = "Xyphod"
  1099.     names(182) = "Xu"
  1100.     names(183) = "Xaal"
  1101.     names(184) = "Xyross"
  1102.     names(185) = "Xiggot"
  1103.     names(186) = "Xirrks"
  1104.     names(187) = "Yed"
  1105.     names(188) = "Yildun"
  1106.     names(189) = "Yundun"
  1107.     names(190) = "Yavyo"
  1108.     names(191) = "Yotrac"
  1109.     names(192) = "Yxzoqu"
  1110.     names(193) = "Ynnot"
  1111.     names(194) = "Zaniah"
  1112.     names(195) = "Zaurak"
  1113.     names(196) = "Zhang"
  1114.     names(197) = "Zibal"
  1115.     names(198) = "Zosma"
  1116.     names(199) = "Zuben"
  1117.  


My name is Michael, but you can call me Mike :)

Offline romichess

  • Forum Regular
  • Posts: 145
    • View Profile
Re: Beyond Sol
« Reply #28 on: December 30, 2019, 07:46:47 pm »
Updated Readme

"Beyond Sol - Pre Alpha Version

A space 4x conquest game by Michael Sherwin

Every thing so far in the game

Game starts off paused but when paused one can still enter orders
Right clicking the mouse on the map will pause unpause the game
If a panel is displayed right clicking will cancel the panel
Left or right clicking on a star brings up the distance line
If the distance line is green ships can be sent
To send ships left click on a destination star and the send panel will appear
Click on the numbers to send ships by then clicking "OK"
The "clear" button clears the numbers
The "All" button sends all ships
There is a send "Half" and send "Third" button as well
The "Quit" button quits the panel
Right clicking on a self owned destination brings up the standing orders panel
Enter number that ships must be greator than in order to send, click "OK"
Or click "X" to clear
Then enter number of ships to send, click "OK" or click "X" to start over
For now untill a "Cancel" button is added just enter 0 and 0 to cancel
The "+" and "-" keys will speed up and slow down the game
If attacking fleets are too out matched they will turn around
If defending fleets are too out matched they will evacuate
The computer player will hate the player that has attacked them the most
A hated player will more likely be attacked
Pressing "p" will pause and unpause the game
Pressing "t" will show star names and production
"t" can be pressed while game is paused
And pressing "Esc" exits the game, no questions asked, so be careful
Pressing "n" stars a new game, no questions asked, be careful
More work needed, remember it is still pre alpha!

The computer is now a very dangerous opponent. However, if one gets off to a very good start the game is not that difficult
There are many features left to be added before it reaches, alpha"
My name is Michael, but you can call me Mike :)

Offline romichess

  • Forum Regular
  • Posts: 145
    • View Profile
Re: Beyond Sol
« Reply #29 on: December 30, 2019, 08:58:21 pm »
Oh no! I just discovered that there is a game on Steam that is already named Beyond Sol. And I thought I was being so original, LOL. Back to the name hunt!
My name is Michael, but you can call me Mike :)