QB64.org Forum

Active Forums => Programs => Topic started by: romichess on December 04, 2019, 03:40:55 PM

Title: MOO
Post by: romichess on December 04, 2019, 03:40:55 PM
This is my first graphics project ever. My only meaningful work so far was writing RomiChess which has received praise from a handful of people due to its playing style and unique learning algorithm labeled as "famous" on the chess programming wiki. Okay, enough of that.

Anyway, my fav game of all time is MOO (Master Of Orion) 1. It is a DOS game from 1993. There have been dozens of attempts to emulate and improve upon it, including MOO 2, MOO 3 and MOO 2016. All add complexity and add to the micromanagement necessities of playing the game, successfully. I personally am of the Risk generation. Risk is a great game because it is super simple and easy to play. And yet one can put in as much deep thought and strategic planning as they want. MOO is a lot like that. Except MOO does have some problems that make it problematic to get a fair starting position. Sometimes one enemy or more are right on top of the players starting position while another enemy has a large portion of the map to themselves. Those games are often over before they begin. The micromanagement was rather simple in MOO but it could still be very time consuming.

My dream ever since the 90's was to create my own space conquest game similar to MOO but in the spirit of Risk, i.e., keep the micromanagement under control. It is to be real time instead of turn based and have a modern GUI. And by modern I mean one of my vision. Even though I taught myself to program in C in 2004 so I could write RomiChess anything more than a console based C application was beyond my ability. The reason for that was the complexity of installing and using graphics libraries with myriads of mind boggling function names and cryptic parameters. I spent months with some packages just to determine that they don't really do what I need to be done.

A couple of weeks ago I stumbled upon QB64. I was not immediately impressed. I have no need nor desire to do anything in less than 1080p. And all the examples were in less than 1080p. Then I stumbled upon a YT vid that was in a 1080p window. That got my attention. The presenter in the vid mentioned that _FULLSCREEN could be used but he'd leave that up to the viewer to implement. Okay, so I had to investigate. I downloaded QB64 and entered the YT presenters code and modified it to run _FULLSCREEN. For the first time ever I had in my hands a tool chain that would do what I wanted to do without exhausting myself trying to understand it. So I started a few days ago writing my game Beyond Sol.

My vision of the GUI is no visible GUI until requested. My example code gives the flavor. It displays the game, not the interface. In the example when a star is moused over it displays the name of the Star. Eventually it will display a panel. The panel will appear and disappear as stars (or fleets) are moused over. The panel will stay displayed if the star is clicked. I got a late start today so I have not cleaned up the code or commented it yet. I will do that next. Then I will find a way to display panels and print to them.

There is one thing I need to know. Does this work on 2k and 4k displays and is the scaling okay. Also any suggestions to make the game or code better are welcome. Even really cool star names would be nice. I just copied star names from a list and made a few up along the way. Can you spot the ones I made up, :)? For those following me on my initial thread I added a micro amount of graphical bling and initiated the 6 starting positions.

Code: QB64: [Select]
  1. TYPE stars
  2.     n AS STRING * 10
  3.     x AS INTEGER
  4.     y AS INTEGER
  5.     o AS INTEGER
  6.     c AS INTEGER
  7.     s AS INTEGER
  8.     t AS INTEGER
  9.     p AS INTEGER
  10.  
  11. DECLARE SUB NewGame
  12. DECLARE SUB PutStars
  13. DECLARE SUB GiveName
  14. DECLARE SUB ShowPanel (i)
  15. DECLARE SUB Identify (x, y)
  16. DECLARE SUB PutBackground
  17.  
  18. DIM repeat AS INTEGER
  19. DIM SHARED star(100) AS stars
  20. DIM ch AS STRING * 1
  21. DIM SHARED names(200) AS STRING * 10
  22.  
  23. repeat = 1
  24.  
  25. sww = sw / 24
  26. swn = sw / 48
  27. nw = 1920
  28.  
  29. ratio = sw / 1920
  30.  
  31. shw = sh / 20
  32. shn = sh / 40
  33. nh = 1080
  34.  
  35. SCREEN _NEWIMAGE(sw, sh, 256)
  36.  
  37.  
  38. GiveName
  39.  
  40. NewGame
  41.  
  42. WHILE repeat
  43.  
  44.     _LIMIT 60
  45.  
  46.     CLS
  47.  
  48.     PutBackground
  49.  
  50.     PutStars
  51.  
  52.  
  53.     x = _MOUSEX
  54.     y = _MOUSEY
  55.     mb = _MOUSEBUTTON(1)
  56.  
  57.     Identify x, y
  58.  
  59.     _DISPLAY
  60.  
  61.     ch = INKEY$
  62.     IF ch = CHR$(27) THEN repeat = 0
  63.     IF ch = "n" THEN NewGame
  64.     ch = ""
  65.  
  66.  
  67.  
  68. SUB PutBackground
  69.     x = RND * sw
  70.     y = RND * sh
  71.     c = RND * 14 + 1
  72.     PSET (x, y), c
  73.     RANDOMIZE USING seed
  74.     FOR i = 1 TO 600
  75.         x = RND * sw
  76.         y = RND * sh
  77.         c = RND * 14 + 1
  78.         PSET (x, y), c
  79.     NEXT
  80.  
  81. SUB Identify (x, y)
  82.     FOR i = 0 TO 99
  83.         dx = star(i).x - x
  84.         dy = star(i).y - y
  85.         IF ABS(dx) <= star(i).s + 6 AND ABS(dy) <= star(i).s + 6 THEN
  86.             ShowPanel i
  87.         END IF
  88.     NEXT
  89.  
  90. SUB ShowPanel (i)
  91.     PRINT star(i).n
  92.  
  93. SUB PutStars
  94.     FOR i = 0 TO 99
  95.         c = star(i).c
  96.         x = star(i).x
  97.         y = star(i).y
  98.         CIRCLE (x, y), (star(i).s + 6) * ratio, c
  99.         IF star(i).o > 0 THEN
  100.             PAINT (x, y), star(i).o + 8, c
  101.         END IF
  102.     NEXT
  103.  
  104. SUB NewGame
  105.     DIM k AS INTEGER
  106.     DIM r AS INTEGER
  107.     DIM dx AS INTEGER
  108.     DIM dy AS INTEGER
  109.     DIM n AS STRING * 10
  110.     seed = RND * 1000
  111.     star(0).n = "Sol"
  112.     star(0).x = RND * (sw - sww) + swn
  113.     star(0).y = RND * (sh - shw) + shn
  114.     star(0).c = 14
  115.     star(0).s = 3
  116.     star(0).o = 1
  117.     home(0) = 0
  118.     FOR i = 1 TO 99
  119.         k = 1
  120.         WHILE k
  121.             k = 0
  122.             x = RND * (sw - sww) + swn
  123.             y = RND * (sh - shw) + shn
  124.             r = INT(RND * 200)
  125.             n = names(r)
  126.             FOR j = 0 TO i - 1
  127.                 dx = x - star(j).x
  128.                 dy = y - star(j).y
  129.                 IF ABS(dx) < sww AND ABS(dy) < shw THEN
  130.                     k = 1
  131.                 END IF
  132.                 IF n = star(j).n THEN
  133.                     k = 1
  134.                 END IF
  135.             NEXT
  136.         WEND
  137.         star(i).n = n
  138.         star(i).x = x
  139.         star(i).y = y
  140.         star(i).c = RND * 7 + 9
  141.         star(i).s = RND * 5
  142.         star(i).o = 0
  143.     NEXT
  144.     FOR i = 2 TO 6
  145.         k = 1
  146.         WHILE k
  147.             k = 0
  148.             r = RND * 100
  149.             FOR j = 1 TO i - 1
  150.                 IF r = home(j) THEN k = 1
  151.                 x = star(0).x
  152.                 y = star(0).y
  153.                 dx = ABS(star(r).x - x)
  154.                 dy = ABS(star(r).y - y)
  155.                 IF dx < sw / 4 AND dy < sh / 4 THEN k = 1
  156.             NEXT
  157.         WEND
  158.         home(i) = r
  159.         star(r).o = i
  160.     NEXT
  161.  
  162. ' A lot of star names I made up
  163.  
  164. SUB GiveName
  165.     names(0) = "Acamar"
  166.     names(1) = "Arcab"
  167.     names(2) = "Acrux"
  168.     names(3) = "Adhara"
  169.     names(4) = "Arneb"
  170.     names(5) = "Antares"
  171.     names(6) = "Arcturus"
  172.     names(7) = "Atria"
  173.     names(8) = "Beid"
  174.     names(9) = "Betelgeuse"
  175.     names(10) = "Botein"
  176.     names(11) = "Beemim"
  177.     names(12) = "Bellatrix"
  178.     names(13) = "Bharani"
  179.     names(14) = "Biham"
  180.     names(15) = "Brachium"
  181.     names(16) = "Canopus"
  182.     names(17) = "Capella"
  183.     names(18) = "Castor"
  184.     names(19) = "Chara"
  185.     names(20) = "Cursa"
  186.     names(21) = "Copernicus"
  187.     names(22) = "Chalawan"
  188.     names(23) = "Chertan"
  189.     names(24) = "Dabih"
  190.     names(25) = "Dalim"
  191.     names(26) = "Deneb"
  192.     names(27) = "Denebola"
  193.     names(28) = "Diadem"
  194.     names(29) = "Diphda"
  195.     names(30) = "Dschubba"
  196.     names(31) = "Dziban"
  197.     names(32) = "Edasich"
  198.     names(33) = "Electra"
  199.     names(34) = "Elgafar"
  200.     names(35) = "Elkurud"
  201.     names(36) = "Elnath"
  202.     names(37) = "Eltanin"
  203.     names(38) = "Enif"
  204.     names(39) = "Errai"
  205.     names(40) = "Fafnir"
  206.     names(41) = "Fang"
  207.     names(42) = "Fawaris"
  208.     names(43) = "Felis"
  209.     names(44) = "Fomalhaut"
  210.     names(45) = "Fulu"
  211.     names(46) = "Fumal"
  212.     names(47) = "Furud"
  213.     names(48) = "Garnet"
  214.     names(49) = "Giausar"
  215.     names(50) = "Gienah"
  216.     names(51) = "Ginan"
  217.     names(52) = "Gomeisa"
  218.     names(53) = "Graffias"
  219.     names(54) = "Grumium"
  220.     names(55) = "Gudja"
  221.     names(56) = "Hadar"
  222.     names(57) = "Haedus"
  223.     names(58) = "Hamal"
  224.     names(59) = "Hassaleh"
  225.     names(60) = "Hatysa"
  226.     names(61) = "Helvetios"
  227.     names(62) = "Heze"
  228.     names(63) = "Homan"
  229.     names(64) = "Iklil"
  230.     names(65) = "Imai"
  231.     names(66) = "Intercrus"
  232.     names(67) = "Izar"
  233.     names(68) = "Iccar"
  234.     names(69) = "Inar"
  235.     names(70) = "Iaeth"
  236.     names(71) = "Imaous"
  237.     names(72) = "Jabbah"
  238.     names(73) = "Jishui"
  239.     names(74) = "Jax"
  240.     names(75) = "Jalae"
  241.     names(76) = "Jewel"
  242.     names(77) = "Jumbo"
  243.     names(78) = "Jerue"
  244.     names(79) = "Jabear"
  245.     names(80) = "Kakkab"
  246.     names(81) = "Kang"
  247.     names(82) = "Kekouan"
  248.     names(83) = "Keid"
  249.     names(84) = "Kitalpha"
  250.     names(85) = "Kochab"
  251.     names(86) = "Kolob"
  252.     names(87) = "Kobol"
  253.     names(88) = "Larawag"
  254.     names(89) = "Lesath"
  255.     names(90) = "Libertas"
  256.     names(91) = "Lich"
  257.     names(92) = "Lilly"
  258.     names(93) = "Laddel"
  259.     names(94) = "Luminous"
  260.     names(95) = "Lasacious"
  261.     names(96) = "Mizar"
  262.     names(97) = "Markab"
  263.     names(98) = "Matar"
  264.     names(99) = "Mintaka"
  265.     names(100) = "Meleph"
  266.     names(101) = "Menkar"
  267.     names(102) = "Merga"
  268.     names(103) = "Merope"
  269.     names(104) = "Nahn"
  270.     names(105) = "Naos"
  271.     names(106) = "Nashira"
  272.     names(107) = "Navi"
  273.     names(108) = "Nekkar"
  274.     names(109) = "Nembus"
  275.     names(110) = "Nihal"
  276.     names(111) = "Nunki"
  277.     names(112) = "Ogma"
  278.     names(113) = "Okab"
  279.     names(114) = "Ohmy"
  280.     names(115) = "Oragami"
  281.     names(116) = "Origen"
  282.     names(117) = "Omanii"
  283.     names(118) = "Obytewa"
  284.     names(119) = "Oglok"
  285.     names(120) = "Phact"
  286.     names(121) = "Pherkad"
  287.     names(122) = "Pleione"
  288.     names(122) = "Polaris"
  289.     names(123) = "Pollux"
  290.     names(124) = "Procyon"
  291.     names(125) = "Proxima"
  292.     names(126) = "Polis"
  293.     names(127) = "Quaint"
  294.     names(128) = "Quazzat"
  295.     names(129) = "Quetzal"
  296.     names(130) = "Qussol"
  297.     names(131) = "Quella"
  298.     names(132) = "Quyaeo"
  299.     names(133) = "Ququdas"
  300.     names(134) = "Quekak"
  301.     names(135) = "Rasalas"
  302.     names(136) = "Regor"
  303.     names(137) = "Regulus"
  304.     names(138) = "Rigel"
  305.     names(139) = "Revati"
  306.     names(140) = "Rotenev"
  307.     names(141) = "Rukbat"
  308.     names(142) = "Rastaban"
  309.     names(143) = "Sabik"
  310.     names(144) = "Sadr"
  311.     names(145) = "Saiph"
  312.     names(146) = "Sargas"
  313.     names(147) = "Sarin"
  314.     names(148) = "Syrma"
  315.     names(149) = "Spica"
  316.     names(150) = "Sirius"
  317.     names(151) = "Tarazed"
  318.     names(152) = "Taygeta"
  319.     names(153) = "Tejat"
  320.     names(154) = "Thabit"
  321.     names(155) = "Thuban"
  322.     names(156) = "Tiaki"
  323.     names(157) = "Toliman"
  324.     names(158) = "Torcular"
  325.     names(157) = "Umala"
  326.     names(158) = "Ulatte"
  327.     names(159) = "Ubbessa"
  328.     names(160) = "Unoless"
  329.     names(161) = "Umaddem"
  330.     names(162) = "Ummbra"
  331.     names(162) = "Uniqu"
  332.     names(163) = "Uzzaal"
  333.     names(164) = "Vega"
  334.     names(165) = "Veritate"
  335.     names(166) = "Vindetrix"
  336.     names(167) = "Vedas"
  337.     names(168) = "Vergg"
  338.     names(169) = "Vacant"
  339.     names(170) = "Vucae"
  340.     names(171) = "Vicar"
  341.     names(172) = "Wasat"
  342.     names(173) = "Wazn"
  343.     names(174) = "Wezen"
  344.     names(175) = "Waiten"
  345.     names(176) = "Wachar"
  346.     names(177) = "Wheelz"
  347.     names(178) = "Whatsp"
  348.     names(179) = "Wassand"
  349.     names(180) = "Xenno"
  350.     names(181) = "Xyphod"
  351.     names(182) = "Xu"
  352.     names(183) = "Xaal"
  353.     names(184) = "Xyross"
  354.     names(185) = "Xiggot"
  355.     names(186) = "Xirrks"
  356.     names(187) = "Yed"
  357.     names(188) = "Yildun"
  358.     names(189) = "yundun"
  359.     names(190) = "Yavyo"
  360.     names(191) = "Yotrac"
  361.     names(192) = "Yxzoqu"
  362.     names(193) = "Ynnot"
  363.     names(194) = "Zaniah"
  364.     names(195) = "Zaurak"
  365.     names(196) = "Zhang"
  366.     names(197) = "Zibal"
  367.     names(198) = "Zosma"
  368.     names(199) = "Zuben"
  369.  
  370.  
  371.  
Title: Re: MOO
Post by: Richard on December 04, 2019, 08:11:43 PM
Regarding:-

"Does this work on 2k and 4k displays and is the scaling okay?"

I do not know if the following is helpful for you but :-

I ran your program (without any changes what so ever) on my laptop which has 3200 x 1800 display and took a Windows 10 screenshot (attached as 1-3200x1800...)

I then imported this screenshot into Windows Paint and viewed at 800% (maximum), took a screenshot (attached as 2-3200x1800...).

I also imported the original screenshot into Windows Paint3D and viewed at 6400% (maximum), took a screenshot (attached as 3-3200x1800...)

And finally imported the screenshot above (i.e. 3-3200x1800...) into Paint and viewed at 800% (maximum), took a screenshot (attached as 4-3200x1800...)

Windows Paint allowed pixel coordinates of cursor and grid lines - however Windows Paint3D does not (and is a real pain to use because of this).

My display (3200x1800) is classified as 3k (by some) and in every QB64 graphics application I have wrote etc - I DO NOT GET THE FULL DISPLAY RESOLUTION ( I only seem to get 1600x900 - i.e. all pixels instead of being 1x1 become 2x2 - and alternate pixels are not displayed (in x or y positioning).

As far as I can tell (at this stage) the display electronically appears to be working correctly and when I view say File Explorer page with an actual 10x magnifying glass (not the silly Windows 10 magnifier which seems to optically distort the display image) it would seem to be okay - however it is difficult to find anything that is actually only 1 pixel wide (say) so I cannot confirm if pixels are preserved as 1x1 or that they are converted to 2x2 (which kind of defeats the purpose of having a higher resolution display).

Previously (Page 7 of Discussion) I started a post "3200 x 1800 display problem" which you may want to read. I am still trying to sort out my problem.

In summary, I do not get 1x1 pixel resolution (I get 2x2 pixel resolution) and I may be missing 75% of the "pin point stars" (if they are unlucky to be located on the alternate x and y coordinate positions).

I would be happy to re-run your program if you (slightly) rewrite it to directly access 3200 x 1800 display (as fullscreen) and if you cram various possibilities in say the very extreme top left hand corner (the easiest area for me to access using the silly painful Windows 10 Paint3d at 6400%) and throw in some fixed grid references (so actual pixel coordinates can be confirmed).

From all of above I assumed you were interested in the resolution capabilities of the display to your star maps.

Hope this may be of use to you.
Title: Re: MOO
Post by: romichess on December 04, 2019, 10:03:06 PM
Hi Richard,

Thanks for all the work. Much appreciation! While the game is being developed on a 1080p system it does not set up the graphics for anything other than the native resolution of the users system. The only thing the scaling does is decide how big to draw the circles. The x and y coordinates use the full native range of the users system. That means that when the program starts on your 3200 x 1800 system if that really is the true _DESKTOPWIDTH and _DESKTOPHEIGHT of your monitor as it appears to be because it appears to look and scale correctly.

One thing to consider is the graphics adapter in your system. If it is set to 1600 x 900 it will double the pixel x and y dimensions to fill the monitor. I have seen that problem before. A friend had a monitor with a higher resolution than his graphics card would do. Just some thoughts.

Anyway, thanks again!

 
Title: Re: MOO
Post by: romichess on December 04, 2019, 10:22:21 PM
It took a while to wade through all the information and to find the right combination to do exactly what was needed. And of course there was a couple of hours of frustration trying to figure out what I was doing wrong and why it would not work correctly. However, it works now, yay! The panel is up and working and the star name is on the panel. Next I have to figure out fonts and font sizing. And add a bit more functionality to the panel.

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 INTEGER '                     Type of planetary system; terran, frozen, radiated, toxic, etc.
  9.     p AS INTEGER '                     Population
  10.  
  11. DECLARE SUB NewGame
  12. DECLARE SUB PaintStars
  13. DECLARE SUB StarNames
  14. DECLARE SUB ShowPanel (i)
  15. DECLARE SUB Identify (x, y)
  16. DECLARE SUB PaintBackground
  17.  
  18. ' Global variables shared because they are needed in more than one routine
  19. DIM SHARED sw AS INTEGER '             Screen Width
  20. DIM SHARED sh AS INTEGER '             Screen Height
  21. DIM SHARED sww AS INTEGER '            Screen Width Wide margin
  22. DIM SHARED swn AS INTEGER '            Screen Width Narrow adjustment
  23. DIM SHARED shw AS INTEGER '            Screen Height Wide margine
  24. DIM SHARED shn AS INTEGER '            Screen Height Narrow adjustment
  25. DIM SHARED nw AS INTEGER '             games Natural screen Width
  26. DIM SHARED nh AS INTEGER '             games Natural screen Height
  27. DIM SHARED ratio AS _FLOAT '           the Ratio of the games natural screen width to the actual
  28. DIM SHARED star(100) AS stars '        100 stars - may change
  29. DIM SHARED names(200) AS STRING * 10 ' 200 star names
  30. DIM SHARED seed AS INTEGER '           Seed to prime the Randomizer to display identical background each frame
  31. DIM SHARED home(6) AS INTEGER '        The starting star for each player. The human always has star(0), Sol
  32.  
  33. ' Simple variables
  34. DIM repeat AS INTEGER '                Game loop control variable
  35. DIM ch AS STRING * 1 '                 Game loop key input variable
  36.  
  37. repeat = 1
  38.  
  39. sw = _DESKTOPWIDTH '                   native video with of syatem
  40. sww = sw / 24 '                        margin based on native video width to keep stars away from edge
  41. swn = sw / 48 '                        adjustment that works with sww to keep stars away from left and top of screen
  42. nw = 1920
  43.  
  44. ratio = sw / 1920 '                    Used to adjust distances and sizes for various screen modes
  45.  
  46. shw = sh / 20
  47. shn = sh / 40
  48. nh = 1080
  49.  
  50. SCREEN _NEWIMAGE(sw, sh, 256) '        creates a screen the resolution of the users native system
  51.  
  52.  
  53. StarNames '                            Routine to load star names into string array stars(200)
  54.  
  55. NewGame
  56.  
  57. WHILE repeat
  58.  
  59.     _LIMIT 60 '                        Set to 60 frames per second
  60.  
  61.     CLS
  62.  
  63.     WHILE _MOUSEINPUT: WEND '          Eat all the mice but keep last mouse to toy with
  64.  
  65.     x = _MOUSEX
  66.     y = _MOUSEY
  67.     mb = _MOUSEBUTTON(1)
  68.  
  69.     PaintBackground
  70.  
  71.     PaintStars
  72.  
  73.     Identify x, y '                    Identify star mouse is over if any
  74.  
  75.     _DISPLAY
  76.  
  77.     ch = INKEY$
  78.     IF ch = CHR$(27) THEN repeat = 0
  79.     IF ch = "n" THEN NewGame
  80.     ch = ""
  81.  
  82.  
  83.  
  84. SUB PaintBackground
  85.     x = RND * sw
  86.     y = RND * sh
  87.     c = RND * 14 + 1
  88.     PSET (x, y), c
  89.     RANDOMIZE USING seed
  90.     FOR i = 1 TO 600 * ratio
  91.         x = RND * sw
  92.         y = RND * sh
  93.         c = RND * 14 + 1
  94.         PSET (x, y), c
  95.     NEXT
  96.  
  97. SUB Identify (x, y)
  98.     FOR i = 0 TO 99
  99.         dx = star(i).x - x
  100.         dy = star(i).y - y
  101.         IF ABS(dx) <= star(i).s + 6 AND ABS(dy) <= star(i).s + 6 THEN
  102.             ShowPanel i
  103.         END IF
  104.     NEXT
  105.  
  106. SUB ShowPanel (i)
  107.     DIM ps AS LONG
  108.     DIM x AS INTEGER
  109.     DIM y AS INTEGER
  110.     x = star(i).x - 420 * ratio
  111.     IF star(i).x < sw / 2 THEN x = star(i).x + 20
  112.     y = star(i).y
  113.     IF y > sh - 540 * ratio THEN y = sh - 540 * ratio
  114.     ps = _NEWIMAGE(400 * ratio, 540 * ratio, 256)
  115.     _DEST ps
  116.     CLS 0, 8
  117.     PRINT star(i).n
  118.     _PUTIMAGE (x, y), ps, 0, (0, 0)-(400 * ratio, 540 * ratio)
  119.     _DEST 0
  120.  
  121. SUB PaintStars
  122.     FOR i = 0 TO 99
  123.         c = star(i).c
  124.         x = star(i).x
  125.         y = star(i).y
  126.         CIRCLE (x, y), (star(i).s + 6) * ratio, c
  127.         IF star(i).o > 0 THEN
  128.             PAINT (x, y), star(i).o + 8, c
  129.         END IF
  130.     NEXT
  131.  
  132. SUB NewGame
  133.     DIM k AS INTEGER
  134.     DIM r AS INTEGER
  135.     DIM dx AS INTEGER
  136.     DIM dy AS INTEGER
  137.     DIM n AS STRING * 10
  138.     seed = RND * 1000
  139.     star(0).n = "Sol"
  140.     star(0).x = RND * (sw - sww) + swn
  141.     star(0).y = RND * (sh - shw) + shn
  142.     star(0).c = 14
  143.     star(0).s = 3
  144.     star(0).o = 1
  145.     home(0) = 0
  146.     FOR i = 1 TO 99
  147.         k = 1
  148.         WHILE k
  149.             k = 0
  150.             x = RND * (sw - sww) + swn
  151.             y = RND * (sh - shw) + shn
  152.             r = INT(RND * 200)
  153.             n = names(r)
  154.             FOR j = 0 TO i - 1
  155.                 dx = x - star(j).x
  156.                 dy = y - star(j).y
  157.                 IF ABS(dx) < sww AND ABS(dy) < shw THEN
  158.                     k = 1
  159.                 END IF
  160.                 IF n = star(j).n THEN
  161.                     k = 1
  162.                 END IF
  163.             NEXT
  164.         WEND
  165.         star(i).n = n
  166.         star(i).x = x
  167.         star(i).y = y
  168.         star(i).c = RND * 7 + 9
  169.         star(i).s = RND * 5
  170.         star(i).o = 0
  171.     NEXT
  172.     FOR i = 2 TO 6
  173.         k = 1
  174.         WHILE k
  175.             k = 0
  176.             r = RND * 100
  177.             FOR j = 1 TO i - 1
  178.                 IF r = home(j) THEN k = 1
  179.                 x = star(0).x
  180.                 y = star(0).y
  181.                 dx = ABS(star(r).x - x)
  182.                 dy = ABS(star(r).y - y)
  183.                 IF dx < sw / 4 AND dy < sh / 4 THEN k = 1
  184.             NEXT
  185.         WEND
  186.         home(i) = r
  187.         star(r).o = i
  188.     NEXT
  189.  
  190. ' A lot of star names I made up
  191.  
  192. SUB StarNames
  193.     names(0) = "Acamar"
  194.     names(1) = "Arcab"
  195.     names(2) = "Acrux"
  196.     names(3) = "Adhara"
  197.     names(4) = "Arneb"
  198.     names(5) = "Antares"
  199.     names(6) = "Arcturus"
  200.     names(7) = "Atria"
  201.     names(8) = "Beid"
  202.     names(9) = "Betelgeuse"
  203.     names(10) = "Botein"
  204.     names(11) = "Beemim"
  205.     names(12) = "Bellatrix"
  206.     names(13) = "Bharani"
  207.     names(14) = "Biham"
  208.     names(15) = "Brachium"
  209.     names(16) = "Canopus"
  210.     names(17) = "Capella"
  211.     names(18) = "Castor"
  212.     names(19) = "Chara"
  213.     names(20) = "Cursa"
  214.     names(21) = "Copernicus"
  215.     names(22) = "Chalawan"
  216.     names(23) = "Chertan"
  217.     names(24) = "Dabih"
  218.     names(25) = "Dalim"
  219.     names(26) = "Deneb"
  220.     names(27) = "Denebola"
  221.     names(28) = "Diadem"
  222.     names(29) = "Diphda"
  223.     names(30) = "Dschubba"
  224.     names(31) = "Dziban"
  225.     names(32) = "Edasich"
  226.     names(33) = "Electra"
  227.     names(34) = "Elgafar"
  228.     names(35) = "Elkurud"
  229.     names(36) = "Elnath"
  230.     names(37) = "Eltanin"
  231.     names(38) = "Enif"
  232.     names(39) = "Errai"
  233.     names(40) = "Fafnir"
  234.     names(41) = "Fang"
  235.     names(42) = "Fawaris"
  236.     names(43) = "Felis"
  237.     names(44) = "Fomalhaut"
  238.     names(45) = "Fulu"
  239.     names(46) = "Fumal"
  240.     names(47) = "Furud"
  241.     names(48) = "Garnet"
  242.     names(49) = "Giausar"
  243.     names(50) = "Gienah"
  244.     names(51) = "Ginan"
  245.     names(52) = "Gomeisa"
  246.     names(53) = "Graffias"
  247.     names(54) = "Grumium"
  248.     names(55) = "Gudja"
  249.     names(56) = "Hadar"
  250.     names(57) = "Haedus"
  251.     names(58) = "Hamal"
  252.     names(59) = "Hassaleh"
  253.     names(60) = "Hatysa"
  254.     names(61) = "Helvetios"
  255.     names(62) = "Heze"
  256.     names(63) = "Homan"
  257.     names(64) = "Iklil"
  258.     names(65) = "Imai"
  259.     names(66) = "Intercrus"
  260.     names(67) = "Izar"
  261.     names(68) = "Iccar"
  262.     names(69) = "Inar"
  263.     names(70) = "Iaeth"
  264.     names(71) = "Imaous"
  265.     names(72) = "Jabbah"
  266.     names(73) = "Jishui"
  267.     names(74) = "Jax"
  268.     names(75) = "Jalae"
  269.     names(76) = "Jewel"
  270.     names(77) = "Jumbo"
  271.     names(78) = "Jerue"
  272.     names(79) = "Jabear"
  273.     names(80) = "Kakkab"
  274.     names(81) = "Kang"
  275.     names(82) = "Kekouan"
  276.     names(83) = "Keid"
  277.     names(84) = "Kitalpha"
  278.     names(85) = "Kochab"
  279.     names(86) = "Kolob"
  280.     names(87) = "Kobol"
  281.     names(88) = "Larawag"
  282.     names(89) = "Lesath"
  283.     names(90) = "Libertas"
  284.     names(91) = "Lich"
  285.     names(92) = "Lilly"
  286.     names(93) = "Laddel"
  287.     names(94) = "Luminous"
  288.     names(95) = "Lasacious"
  289.     names(96) = "Mizar"
  290.     names(97) = "Markab"
  291.     names(98) = "Matar"
  292.     names(99) = "Mintaka"
  293.     names(100) = "Meleph"
  294.     names(101) = "Menkar"
  295.     names(102) = "Merga"
  296.     names(103) = "Merope"
  297.     names(104) = "Nahn"
  298.     names(105) = "Naos"
  299.     names(106) = "Nashira"
  300.     names(107) = "Navi"
  301.     names(108) = "Nekkar"
  302.     names(109) = "Nembus"
  303.     names(110) = "Nihal"
  304.     names(111) = "Nunki"
  305.     names(112) = "Ogma"
  306.     names(113) = "Okab"
  307.     names(114) = "Ohmy"
  308.     names(115) = "Oragami"
  309.     names(116) = "Origen"
  310.     names(117) = "Omanii"
  311.     names(118) = "Obytewa"
  312.     names(119) = "Oglok"
  313.     names(120) = "Phact"
  314.     names(121) = "Pherkad"
  315.     names(122) = "Pleione"
  316.     names(122) = "Polaris"
  317.     names(123) = "Pollux"
  318.     names(124) = "Procyon"
  319.     names(125) = "Proxima"
  320.     names(126) = "Polis"
  321.     names(127) = "Quaint"
  322.     names(128) = "Quazzat"
  323.     names(129) = "Quetzal"
  324.     names(130) = "Qussol"
  325.     names(131) = "Quella"
  326.     names(132) = "Quyaeo"
  327.     names(133) = "Ququdas"
  328.     names(134) = "Quekak"
  329.     names(135) = "Rasalas"
  330.     names(136) = "Regor"
  331.     names(137) = "Regulus"
  332.     names(138) = "Rigel"
  333.     names(139) = "Revati"
  334.     names(140) = "Rotenev"
  335.     names(141) = "Rukbat"
  336.     names(142) = "Rastaban"
  337.     names(143) = "Sabik"
  338.     names(144) = "Sadr"
  339.     names(145) = "Saiph"
  340.     names(146) = "Sargas"
  341.     names(147) = "Sarin"
  342.     names(148) = "Syrma"
  343.     names(149) = "Spica"
  344.     names(150) = "Sirius"
  345.     names(151) = "Tarazed"
  346.     names(152) = "Taygeta"
  347.     names(153) = "Tejat"
  348.     names(154) = "Thabit"
  349.     names(155) = "Thuban"
  350.     names(156) = "Tiaki"
  351.     names(157) = "Toliman"
  352.     names(158) = "Torcular"
  353.     names(157) = "Umala"
  354.     names(158) = "Ulatte"
  355.     names(159) = "Ubbessa"
  356.     names(160) = "Unoless"
  357.     names(161) = "Umaddem"
  358.     names(162) = "Ummbra"
  359.     names(162) = "Uniqu"
  360.     names(163) = "Uzzaal"
  361.     names(164) = "Vega"
  362.     names(165) = "Veritate"
  363.     names(166) = "Vindetrix"
  364.     names(167) = "Vedas"
  365.     names(168) = "Vergg"
  366.     names(169) = "Vacant"
  367.     names(170) = "Vucae"
  368.     names(171) = "Vicar"
  369.     names(172) = "Wasat"
  370.     names(173) = "Wazn"
  371.     names(174) = "Wezen"
  372.     names(175) = "Waiten"
  373.     names(176) = "Wachar"
  374.     names(177) = "Wheelz"
  375.     names(178) = "Whatsp"
  376.     names(179) = "Wassand"
  377.     names(180) = "Xenno"
  378.     names(181) = "Xyphod"
  379.     names(182) = "Xu"
  380.     names(183) = "Xaal"
  381.     names(184) = "Xyross"
  382.     names(185) = "Xiggot"
  383.     names(186) = "Xirrks"
  384.     names(187) = "Yed"
  385.     names(188) = "Yildun"
  386.     names(189) = "yundun"
  387.     names(190) = "Yavyo"
  388.     names(191) = "Yotrac"
  389.     names(192) = "Yxzoqu"
  390.     names(193) = "Ynnot"
  391.     names(194) = "Zaniah"
  392.     names(195) = "Zaurak"
  393.     names(196) = "Zhang"
  394.     names(197) = "Zibal"
  395.     names(198) = "Zosma"
  396.     names(199) = "Zuben"
  397.  
Title: Re: MOO
Post by: SierraKen on December 04, 2019, 10:48:50 PM
Interesting start of a space simulator game you got there. I've thought of similar things. Back in the 80's I had a store-bought game that let you fly to different planets on my Apple 2e compatible computer. I see you mention GUI's a bit. I don't know if you know, but QB64 does have a GUI add-on if you want to use it. It's called InForm and it's on the main page or directly here: https://www.qb64.org/inform/ (https://www.qb64.org/inform/) I'm just starting out on that myself and I've used QB64 for almost half a year now. There's also a forum area for that as well here: https://www.qb64.org/forum/index.php?board=13.0 (https://www.qb64.org/forum/index.php?board=13.0) with some examples. There's some examples and info on the download page as well.
That's really awesome you made a Chess game. I've never programmed something that intense, but recently I made a Tic-Tac-Toe game against the computer. My website so far has 33 examples of QB64 programs and games if you want to check it out, here: http://www.KensPrograms.com/ (http://www.KensPrograms.com/) Most of them you copy/paste the .txt files to your own QB64 language. That URL is also below on all my forum posts.
I've been using this forum here since I started QB64 in the Summer and there's a lot of great helpers here if you need anything. I've learned that screen size matters a lot if you make specified window sizes. I have my Brick Smasher game on my website that uses _FULLSCREEN which you can check out too. I've seen that people rarely use FULLSCREEN on this forum though, probably because of the ease to turn off a game by clicking X and also the fact that you can use the _TITLE command anywhere in your program to add and change the name of that window in the bar above. Anyway, I won't talk here forever but if you need help or have any questions, please ask. By the way, since I'm an old school programmer from the 80's, I don't usually do a lot of what everyone else does, like DIM all of the variables and use SUB's. Although I am slowly learning I think. 
Title: Re: MOO
Post by: SierraKen on December 04, 2019, 10:58:49 PM
I just tried your second post with the panels, great job! If you want to add text to any graphic coordinate area, I would use _PRINTSTRING which can be found here: https://qb64.org/wiki/PRINTSTRING (https://qb64.org/wiki/PRINTSTRING)
Title: Re: MOO
Post by: romichess on December 04, 2019, 11:33:23 PM
I just tried your second post with the panels, great job! If you want to add text to any graphic coordinate area, I would use _PRINTSTRING which can be found here: https://qb64.org/wiki/PRINTSTRING (https://qb64.org/wiki/PRINTSTRING)

Oh wow! Thank you for the information, kind words and encouragement. I too am torn about all the DIM's. I find myself getting lazy and not using them everywhere. In C it is mandatory practice. C is strongly type checked which prevents tricky bugs that are hard to find. I think that my philosophy if I were writing a compiler is that INTEGERS never need DIM and everything else does. Thank you for the invite to ask questions. I will surely take advantage of that offer when I get stuck! :))
Title: Re: MOO
Post by: OldMoses on December 05, 2019, 08:45:33 AM
For printing text in graphics areas, there is one that Petr made that I use frequently in my projects. It's quite versatile for spacing, both horizontal and vertical, as well as resizing. Thought you might find it interesting.

He posted the code here.
https://www.qb64.org/forum/index.php?topic=498.msg3458#msg3458
Title: Re: MOO
Post by: romichess on December 05, 2019, 10:23:11 AM
For printing text in graphics areas, there is one that Petr made that I use frequently in my projects. It's quite versatile for spacing, both horizontal and vertical, as well as resizing. Thought you might find it interesting.

He posted the code here.
https://www.qb64.org/forum/index.php?topic=498.msg3458#msg3458

Yes! Very helpful link. Thank you.
Title: Re: MOO
Post by: bplus on December 05, 2019, 11:18:42 AM
I am kind of curious, for a new QB64 program why limit yourself to 256 color system? why not 32 bit color system 16 million colors with Alpha transparencies.
Title: Re: MOO
Post by: romichess on December 05, 2019, 01:26:04 PM
I am kind of curious, for a new QB64 program why limit yourself to 256 color system? why not 32 bit color system 16 million colors with Alpha transparencies.

Fair question! It is because I am a new QB64 programmer and 32 bit color adds a level of complexity. Also this is just a rough draft, proof of concept, build and 256 colors is more than enough. And to be honest I do not see this program ever needing more than 256 colors. And I already know how to do pallette cycling animations.
Title: Re: MOO
Post by: romichess on December 05, 2019, 01:42:04 PM
Some rather nice progress showing better how the GUI will work. Also pressing 't' will toggle the star names on and off underneath the stars. Now when a star is clicked the panel will stay on the screen. Clicking inside the panel will call the ProcessPanel routine. Nothing happens yet except the panel remains on screen. Clicking anywhere else and the panel will close. Next a right click anywhere will be added that brings up a game panel for loading, saving, quitting, etc.
 
Once I get the GUI portion complete to the point that I understand all the necessities of the system I'll being doing a rewrite using longer variable names and a cleaner design. Please let me know what you think of "the feel" of the interface. Suggestions welcomed!

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 INTEGER '                     Type of planetary system; terran, frozen, radiated, toxic, etc.
  9.     p AS INTEGER '                     Population
  10.  
  11. DECLARE SUB NewGame
  12. DECLARE SUB PaintStars
  13. DECLARE SUB StarNames
  14. DECLARE SUB ShowPanel (i)
  15. DECLARE SUB Identify (x, y)
  16. DECLARE SUB PaintBackground
  17. DECLARE SUB GetInput
  18.  
  19. ' Global variables shared because they are needed in more than one routine
  20. DIM SHARED sw AS INTEGER '             Screen Width
  21. DIM SHARED sh AS INTEGER '             Screen Height
  22. DIM SHARED sww AS INTEGER '            Screen Width Wide margin
  23. DIM SHARED swn AS INTEGER '            Screen Width Narrow adjustment
  24. DIM SHARED shw AS INTEGER '            Screen Height Wide margine
  25. DIM SHARED shn AS INTEGER '            Screen Height Narrow adjustment
  26. DIM SHARED nw AS INTEGER '             games Natural screen Width
  27. DIM SHARED nh AS INTEGER '             games Natural screen Height
  28. DIM SHARED ratio AS _FLOAT '           the Ratio of the games natural screen width to the actual
  29. DIM SHARED star(100) AS stars '        100 stars - may change
  30. DIM SHARED names(200) AS STRING * 10 ' 200 star names
  31. DIM SHARED seed AS INTEGER '           Seed to prime the Randomizer to display identical background each frame
  32. DIM SHARED home(6) AS INTEGER '        The starting star for each player. The human always has star(0), Sol
  33. DIM SHARED f1 AS LONG '                Font 1
  34. DIM SHARED tt AS INTEGER '             tt = 0 star names displayed, tt = 0 star names not didplayed
  35. DIM SHARED ch AS STRING * 1 '                 Game loop key input variable
  36. DIM SHARED repeat AS INTEGER '                Game loop control variable
  37.  
  38. repeat = 1
  39.  
  40.  
  41. sw = _DESKTOPWIDTH '                   native video with of syatem
  42. sww = sw / 24 '                        margin based on native video width to keep stars away from edge
  43. swn = sw / 48 '                        adjustment that works with sww to keep stars away from left and top of screen
  44. nw = 1920
  45.  
  46. ratio = sw / 1920 '                    Used to adjust distances and sizes for various screen modes
  47.  
  48. shw = sh / 20
  49. shn = sh / 40
  50. nh = 1080
  51.  
  52. tt = 0
  53. cx = sw
  54. cp = 100
  55. h = 100
  56. ar = 0
  57.  
  58. SCREEN _NEWIMAGE(sw, sh, 256) '        creates a screen the resolution of the users native system
  59.  
  60.  
  61. f1 = _LOADFONT("C:\Windows\Fonts\Ebrima.ttf", 12, "BOLD")
  62.  
  63. ps = _NEWIMAGE(400 * ratio, 540 * ratio, 256)
  64.  
  65. StarNames '                            Routine to load star names into string array stars(200)
  66.  
  67. NewGame
  68.  
  69. WHILE repeat
  70.  
  71.     _LIMIT 60 '                        Set to 60 frames per second
  72.  
  73.     CLS
  74.  
  75.     PaintBackground
  76.  
  77.     PaintStars
  78.  
  79.     GetInput
  80.  
  81.     Identify x, y '                    Identify star mouse is over if any
  82.  
  83.     _DISPLAY
  84.  
  85.  
  86.  
  87. SUB GetInput
  88.     WHILE _MOUSEINPUT: WEND '          Eat all the mice but keep last mouse to toy with
  89.  
  90.     x = _MOUSEX
  91.     y = _MOUSEY
  92.     mb = _MOUSEBUTTON(1)
  93.     clk = 0
  94.  
  95.     IF mb = -1 AND cx = sw THEN
  96.         cx = x
  97.         cy = y
  98.     END IF
  99.  
  100.     IF mb = 0 AND cx < sw THEN
  101.         IF ABS(x - cx) < 4 AND ABS(y - cy) < 4 THEN
  102.             clk = 1
  103.         END IF
  104.         cx = sw
  105.     END IF
  106.  
  107.     ch = INKEY$
  108.     IF ch = CHR$(27) THEN repeat = 0
  109.     IF ch = "n" THEN NewGame
  110.     IF ch = "t" THEN tt = 1 - tt
  111.     ch = ""
  112.  
  113.  
  114. SUB PaintBackground
  115.     x = RND * sw
  116.     y = RND * sh
  117.     c = RND * 14 + 1
  118.     PSET (x, y), c
  119.     RANDOMIZE USING seed
  120.     FOR i = 1 TO 600 * ratio
  121.         x = RND * sw
  122.         y = RND * sh
  123.         c = RND * 14 + 1
  124.         PSET (x, y), c
  125.     NEXT
  126.  
  127. SUB ProcessPanel
  128.  
  129.  
  130. SUB Identify (x, y)
  131.     IF ar = 1 THEN
  132.         ShowPanel h
  133.         IF clk THEN
  134.             IF x >= x1 AND x <= x2 AND y >= y1 AND y <= y2 THEN
  135.                 ProcessPanel
  136.             ELSE
  137.                 ar = 0
  138.             END IF
  139.         END IF
  140.     END IF
  141.     IF ar = 0 THEN
  142.         FOR i = 0 TO 99
  143.             dx = star(i).x - x
  144.             dy = star(i).y - y
  145.             IF ABS(dx) <= star(i).s + 6 AND ABS(dy) <= star(i).s + 6 THEN
  146.                 ShowPanel i
  147.                 IF clk THEN
  148.                     clk = 0
  149.                     h = i
  150.                     ar = 1
  151.                     ax = x
  152.                 END IF
  153.             END IF
  154.         NEXT
  155.     END IF
  156.  
  157. SUB ShowPanel (i)
  158.     DIM x AS INTEGER
  159.     DIM y AS INTEGER
  160.     x1 = star(i).x - 420 * ratio
  161.     IF star(i).x < sw / 2 THEN x1 = star(i).x + 20
  162.     x2 = x1 + 400 * ratio
  163.     y1 = star(i).y
  164.     IF y1 > sh - 560 * ratio THEN y1 = sh - 560 * ratio
  165.     y2 = y1 + 540 * ratio
  166.     _DEST ps
  167.     CLS 0, 8
  168.     PRINT star(i).n
  169.     _PUTIMAGE (x1, y1), ps, 0, (0, 0)-(400 * ratio, 540 * ratio)
  170.     _DEST 0
  171.  
  172. SUB PaintStars
  173.     FOR i = 0 TO 99
  174.         c = star(i).c
  175.         x = star(i).x
  176.         y = star(i).y
  177.         o = star(i).o
  178.         CIRCLE (x, y), (star(i).s + 6) * ratio, c
  179.         COLOR 15
  180.         IF o > 0 THEN
  181.             PAINT (x, y), o + 8, c
  182.             COLOR o + 8
  183.         END IF
  184.         IF tt THEN
  185.             _FONT f1
  186.             _PRINTSTRING (x - 10, y + 12), star(i).n, 0
  187.         END IF
  188.     NEXT
  189.  
  190. SUB NewGame
  191.     DIM k AS INTEGER
  192.     DIM r AS INTEGER
  193.     DIM dx AS INTEGER
  194.     DIM dy AS INTEGER
  195.     DIM n AS STRING * 10
  196.     seed = RND * 1000
  197.     star(0).n = "Sol"
  198.     star(0).x = RND * (sw - sww) + swn
  199.     star(0).y = RND * (sh - shw) + shn
  200.     star(0).c = 14
  201.     star(0).s = 3
  202.     star(0).o = 1
  203.     home(0) = 0
  204.     FOR i = 1 TO 99
  205.         k = 1
  206.         WHILE k
  207.             k = 0
  208.             x = RND * (sw - sww) + swn
  209.             y = RND * (sh - shw) + shn
  210.             r = INT(RND * 200)
  211.             n = names(r)
  212.             FOR j = 0 TO i - 1
  213.                 dx = x - star(j).x
  214.                 dy = y - star(j).y
  215.                 IF ABS(dx) < sww AND ABS(dy) < shw THEN
  216.                     k = 1
  217.                 END IF
  218.                 IF n = star(j).n THEN
  219.                     k = 1
  220.                 END IF
  221.             NEXT
  222.         WEND
  223.         star(i).n = n
  224.         star(i).x = x
  225.         star(i).y = y
  226.         star(i).c = RND * 6 + 9
  227.         star(i).s = RND * 5
  228.         star(i).o = 0
  229.     NEXT
  230.     FOR i = 2 TO 6
  231.         k = 1
  232.         WHILE k
  233.             k = 0
  234.             r = RND * 100
  235.             FOR j = 1 TO i - 1
  236.                 IF r = home(j) THEN k = 1
  237.                 x = star(0).x
  238.                 y = star(0).y
  239.                 dx = ABS(star(r).x - x)
  240.                 dy = ABS(star(r).y - y)
  241.                 IF dx < sw / 4 AND dy < sh / 4 THEN k = 1
  242.             NEXT
  243.         WEND
  244.         home(i) = r
  245.         star(r).o = i
  246.     NEXT
  247.  
  248. ' A lot of star names I made up
  249.  
  250. SUB StarNames
  251.     names(0) = "Acamar"
  252.     names(1) = "Arcab"
  253.     names(2) = "Acrux"
  254.     names(3) = "Adhara"
  255.     names(4) = "Arneb"
  256.     names(5) = "Antares"
  257.     names(6) = "Arcturus"
  258.     names(7) = "Atria"
  259.     names(8) = "Beid"
  260.     names(9) = "Betelgeuse"
  261.     names(10) = "Botein"
  262.     names(11) = "Beemim"
  263.     names(12) = "Bellatrix"
  264.     names(13) = "Bharani"
  265.     names(14) = "Biham"
  266.     names(15) = "Brachium"
  267.     names(16) = "Canopus"
  268.     names(17) = "Capella"
  269.     names(18) = "Castor"
  270.     names(19) = "Chara"
  271.     names(20) = "Cursa"
  272.     names(21) = "Copernicus"
  273.     names(22) = "Chalawan"
  274.     names(23) = "Chertan"
  275.     names(24) = "Dabih"
  276.     names(25) = "Dalim"
  277.     names(26) = "Deneb"
  278.     names(27) = "Denebola"
  279.     names(28) = "Diadem"
  280.     names(29) = "Diphda"
  281.     names(30) = "Dschubba"
  282.     names(31) = "Dziban"
  283.     names(32) = "Edasich"
  284.     names(33) = "Electra"
  285.     names(34) = "Elgafar"
  286.     names(35) = "Elkurud"
  287.     names(36) = "Elnath"
  288.     names(37) = "Eltanin"
  289.     names(38) = "Enif"
  290.     names(39) = "Errai"
  291.     names(40) = "Fafnir"
  292.     names(41) = "Fang"
  293.     names(42) = "Fawaris"
  294.     names(43) = "Felis"
  295.     names(44) = "Fomalhaut"
  296.     names(45) = "Fulu"
  297.     names(46) = "Fumal"
  298.     names(47) = "Furud"
  299.     names(48) = "Garnet"
  300.     names(49) = "Giausar"
  301.     names(50) = "Gienah"
  302.     names(51) = "Ginan"
  303.     names(52) = "Gomeisa"
  304.     names(53) = "Graffias"
  305.     names(54) = "Grumium"
  306.     names(55) = "Gudja"
  307.     names(56) = "Hadar"
  308.     names(57) = "Haedus"
  309.     names(58) = "Hamal"
  310.     names(59) = "Hassaleh"
  311.     names(60) = "Hatysa"
  312.     names(61) = "Helvetios"
  313.     names(62) = "Heze"
  314.     names(63) = "Homan"
  315.     names(64) = "Iklil"
  316.     names(65) = "Imai"
  317.     names(66) = "Intercrus"
  318.     names(67) = "Izar"
  319.     names(68) = "Iccar"
  320.     names(69) = "Inar"
  321.     names(70) = "Iaeth"
  322.     names(71) = "Imaous"
  323.     names(72) = "Jabbah"
  324.     names(73) = "Jishui"
  325.     names(74) = "Jax"
  326.     names(75) = "Jalae"
  327.     names(76) = "Jewel"
  328.     names(77) = "Jumbo"
  329.     names(78) = "Jerue"
  330.     names(79) = "Jabear"
  331.     names(80) = "Kakkab"
  332.     names(81) = "Kang"
  333.     names(82) = "Kekouan"
  334.     names(83) = "Keid"
  335.     names(84) = "Kitalpha"
  336.     names(85) = "Kochab"
  337.     names(86) = "Kolob"
  338.     names(87) = "Kobol"
  339.     names(88) = "Larawag"
  340.     names(89) = "Lesath"
  341.     names(90) = "Libertas"
  342.     names(91) = "Lich"
  343.     names(92) = "Lilly"
  344.     names(93) = "Laddel"
  345.     names(94) = "Luminous"
  346.     names(95) = "Lasacious"
  347.     names(96) = "Mizar"
  348.     names(97) = "Markab"
  349.     names(98) = "Matar"
  350.     names(99) = "Mintaka"
  351.     names(100) = "Meleph"
  352.     names(101) = "Menkar"
  353.     names(102) = "Merga"
  354.     names(103) = "Merope"
  355.     names(104) = "Nahn"
  356.     names(105) = "Naos"
  357.     names(106) = "Nashira"
  358.     names(107) = "Navi"
  359.     names(108) = "Nekkar"
  360.     names(109) = "Nembus"
  361.     names(110) = "Nihal"
  362.     names(111) = "Nunki"
  363.     names(112) = "Ogma"
  364.     names(113) = "Okab"
  365.     names(114) = "Ohmy"
  366.     names(115) = "Oragami"
  367.     names(116) = "Origen"
  368.     names(117) = "Omanii"
  369.     names(118) = "Obytewa"
  370.     names(119) = "Oglok"
  371.     names(120) = "Phact"
  372.     names(121) = "Pherkad"
  373.     names(122) = "Pleione"
  374.     names(122) = "Polaris"
  375.     names(123) = "Pollux"
  376.     names(124) = "Procyon"
  377.     names(125) = "Proxima"
  378.     names(126) = "Polis"
  379.     names(127) = "Quaint"
  380.     names(128) = "Quazzat"
  381.     names(129) = "Quetzal"
  382.     names(130) = "Qussol"
  383.     names(131) = "Quella"
  384.     names(132) = "Quyaeo"
  385.     names(133) = "Ququdas"
  386.     names(134) = "Quekak"
  387.     names(135) = "Rasalas"
  388.     names(136) = "Regor"
  389.     names(137) = "Regulus"
  390.     names(138) = "Rigel"
  391.     names(139) = "Revati"
  392.     names(140) = "Rotenev"
  393.     names(141) = "Rukbat"
  394.     names(142) = "Rastaban"
  395.     names(143) = "Sabik"
  396.     names(144) = "Sadr"
  397.     names(145) = "Saiph"
  398.     names(146) = "Sargas"
  399.     names(147) = "Sarin"
  400.     names(148) = "Syrma"
  401.     names(149) = "Spica"
  402.     names(150) = "Sirius"
  403.     names(151) = "Tarazed"
  404.     names(152) = "Taygeta"
  405.     names(153) = "Tejat"
  406.     names(154) = "Thabit"
  407.     names(155) = "Thuban"
  408.     names(156) = "Tiaki"
  409.     names(157) = "Toliman"
  410.     names(158) = "Torcular"
  411.     names(157) = "Umala"
  412.     names(158) = "Ulatte"
  413.     names(159) = "Ubbessa"
  414.     names(160) = "Unoless"
  415.     names(161) = "Umaddem"
  416.     names(162) = "Ummbra"
  417.     names(162) = "Uniqu"
  418.     names(163) = "Uzzaal"
  419.     names(164) = "Vega"
  420.     names(165) = "Veritate"
  421.     names(166) = "Vindetrix"
  422.     names(167) = "Vedas"
  423.     names(168) = "Vergg"
  424.     names(169) = "Vacant"
  425.     names(170) = "Vucae"
  426.     names(171) = "Vicar"
  427.     names(172) = "Wasat"
  428.     names(173) = "Wazn"
  429.     names(174) = "Wezen"
  430.     names(175) = "Waiten"
  431.     names(176) = "Wachar"
  432.     names(177) = "Wheelz"
  433.     names(178) = "Whatsp"
  434.     names(179) = "Wassand"
  435.     names(180) = "Xenno"
  436.     names(181) = "Xyphod"
  437.     names(182) = "Xu"
  438.     names(183) = "Xaal"
  439.     names(184) = "Xyross"
  440.     names(185) = "Xiggot"
  441.     names(186) = "Xirrks"
  442.     names(187) = "Yed"
  443.     names(188) = "Yildun"
  444.     names(189) = "yundun"
  445.     names(190) = "Yavyo"
  446.     names(191) = "Yotrac"
  447.     names(192) = "Yxzoqu"
  448.     names(193) = "Ynnot"
  449.     names(194) = "Zaniah"
  450.     names(195) = "Zaurak"
  451.     names(196) = "Zhang"
  452.     names(197) = "Zibal"
  453.     names(198) = "Zosma"
  454.     names(199) = "Zuben"
  455.  
Title: Re: MOO
Post by: romichess on December 05, 2019, 02:35:54 PM
I forgot about the likely font issue. I'm using the Ebrima.ttf bold font because it is very easy to read. So if one does not have that font pressing 't' to toggle the star names won't work. I will fix that problem right now.
Title: Re: MOO
Post by: romichess on December 05, 2019, 03:08:07 PM
For this prototype version I'll just stick to the default font. It's not all that bad. :)
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 INTEGER '                     Type of planetary system; terran, frozen, radiated, toxic, etc.
  9.     p AS INTEGER '                     Population
  10.  
  11. DECLARE SUB NewGame
  12. DECLARE SUB PaintStars
  13. DECLARE SUB StarNames
  14. DECLARE SUB ShowPanel (i)
  15. DECLARE SUB Identify (x, y)
  16. DECLARE SUB PaintBackground
  17. DECLARE SUB GetInput
  18.  
  19. ' Global variables shared because they are needed in more than one routine
  20. DIM SHARED sw AS INTEGER '             Screen Width
  21. DIM SHARED sh AS INTEGER '             Screen Height
  22. DIM SHARED sww AS INTEGER '            Screen Width Wide margin
  23. DIM SHARED swn AS INTEGER '            Screen Width Narrow adjustment
  24. DIM SHARED shw AS INTEGER '            Screen Height Wide margine
  25. DIM SHARED shn AS INTEGER '            Screen Height Narrow adjustment
  26. DIM SHARED nw AS INTEGER '             games Natural screen Width
  27. DIM SHARED nh AS INTEGER '             games Natural screen Height
  28. DIM SHARED ratio AS _FLOAT '           the Ratio of the games natural screen width to the actual
  29. DIM SHARED star(100) AS stars '        100 stars - may change
  30. DIM SHARED names(200) AS STRING * 10 ' 200 star names
  31. DIM SHARED seed AS INTEGER '           Seed to prime the Randomizer to display identical background each frame
  32. DIM SHARED home(6) AS INTEGER '        The starting star for each player. The human always has star(0), Sol
  33. DIM SHARED tt AS INTEGER '             tt = 0 star names displayed, tt = 0 star names not didplayed
  34. DIM SHARED ch AS STRING * 1 '                 Game loop key input variable
  35. DIM SHARED repeat AS INTEGER '                Game loop control variable
  36.  
  37. repeat = 1
  38.  
  39.  
  40. sw = _DESKTOPWIDTH '                   native video with of syatem
  41. sww = sw / 24 '                        margin based on native video width to keep stars away from edge
  42. swn = sw / 48 '                        adjustment that works with sww to keep stars away from left and top of screen
  43. nw = 1920
  44.  
  45. ratio = sw / 1920 '                    Used to adjust distances and sizes for various screen modes
  46.  
  47. shw = sh / 20
  48. shn = sh / 40
  49. nh = 1080
  50.  
  51. tt = 0
  52. cx = sw
  53. cp = 100
  54. h = 100
  55. ar = 0
  56.  
  57. SCREEN _NEWIMAGE(sw, sh, 256) '        creates a screen the resolution of the users native system
  58.  
  59.  
  60. ps = _NEWIMAGE(400 * ratio, 540 * ratio, 256)
  61.  
  62. StarNames '                            Routine to load star names into string array stars(200)
  63.  
  64. NewGame
  65.  
  66. WHILE repeat
  67.  
  68.     _LIMIT 60 '                        Set to 60 frames per second
  69.  
  70.     CLS
  71.  
  72.     PaintBackground
  73.  
  74.     PaintStars
  75.  
  76.     GetInput
  77.  
  78.     Identify x, y '                    Identify star mouse is over if any
  79.  
  80.     _DISPLAY
  81.  
  82.  
  83.  
  84. SUB GetInput
  85.     WHILE _MOUSEINPUT: WEND '          Eat all the mice but keep last mouse to toy with
  86.  
  87.     x = _MOUSEX
  88.     y = _MOUSEY
  89.     mb = _MOUSEBUTTON(1)
  90.     clk = 0
  91.  
  92.     IF mb = -1 AND cx = sw THEN
  93.         cx = x
  94.         cy = y
  95.     END IF
  96.  
  97.     IF mb = 0 AND cx < sw THEN
  98.         IF ABS(x - cx) < 4 AND ABS(y - cy) < 4 THEN
  99.             clk = 1
  100.         END IF
  101.         cx = sw
  102.     END IF
  103.  
  104.     ch = INKEY$
  105.     IF ch = CHR$(27) THEN repeat = 0
  106.     IF ch = "n" THEN NewGame
  107.     IF ch = "t" THEN tt = 1 - tt
  108.     ch = ""
  109.  
  110.  
  111. SUB PaintBackground
  112.     x = RND * sw
  113.     y = RND * sh
  114.     c = RND * 14 + 1
  115.     PSET (x, y), c
  116.     RANDOMIZE USING seed
  117.     FOR i = 1 TO 600 * ratio
  118.         x = RND * sw
  119.         y = RND * sh
  120.         c = RND * 14 + 1
  121.         PSET (x, y), c
  122.     NEXT
  123.  
  124. SUB ProcessPanel
  125.  
  126.  
  127. SUB Identify (x, y)
  128.     IF ar = 1 THEN
  129.         ShowPanel h
  130.         IF clk THEN
  131.             IF x >= x1 AND x <= x2 AND y >= y1 AND y <= y2 THEN
  132.                 ProcessPanel
  133.             ELSE
  134.                 ar = 0
  135.             END IF
  136.         END IF
  137.     END IF
  138.     IF ar = 0 THEN
  139.         FOR i = 0 TO 99
  140.             dx = star(i).x - x
  141.             dy = star(i).y - y
  142.             IF ABS(dx) <= star(i).s + 6 AND ABS(dy) <= star(i).s + 6 THEN
  143.                 ShowPanel i
  144.                 IF clk THEN
  145.                     clk = 0
  146.                     h = i
  147.                     ar = 1
  148.                     ax = x
  149.                 END IF
  150.             END IF
  151.         NEXT
  152.     END IF
  153.  
  154. SUB ShowPanel (i)
  155.     DIM x AS INTEGER
  156.     DIM y AS INTEGER
  157.     x1 = star(i).x - 420 * ratio
  158.     IF star(i).x < sw / 2 THEN x1 = star(i).x + 20
  159.     x2 = x1 + 400 * ratio
  160.     y1 = star(i).y
  161.     IF y1 > sh - 560 * ratio THEN y1 = sh - 560 * ratio
  162.     y2 = y1 + 540 * ratio
  163.     _DEST ps
  164.     CLS 0, 8
  165.     PRINT star(i).n
  166.     _PUTIMAGE (x1, y1), ps, 0, (0, 0)-(400 * ratio, 540 * ratio)
  167.     _DEST 0
  168.  
  169. SUB PaintStars
  170.     FOR i = 0 TO 99
  171.         c = star(i).c
  172.         x = star(i).x
  173.         y = star(i).y
  174.         o = star(i).o
  175.         CIRCLE (x, y), (star(i).s + 6) * ratio, c
  176.         COLOR 15
  177.         IF o > 0 THEN
  178.             PAINT (x, y), o + 8, c
  179.             COLOR o + 8
  180.         END IF
  181.         IF tt THEN
  182.             _PRINTSTRING (x - 10, y + 12), star(i).n, 0
  183.         END IF
  184.     NEXT
  185.  
  186. SUB NewGame
  187.     DIM k AS INTEGER
  188.     DIM r AS INTEGER
  189.     DIM dx AS INTEGER
  190.     DIM dy AS INTEGER
  191.     DIM n AS STRING * 10
  192.     seed = RND * 1000
  193.     star(0).n = "Sol"
  194.     star(0).x = RND * (sw - sww) + swn
  195.     star(0).y = RND * (sh - shw) + shn
  196.     star(0).c = 14
  197.     star(0).s = 3
  198.     star(0).o = 1
  199.     home(0) = 0
  200.     FOR i = 1 TO 99
  201.         k = 1
  202.         WHILE k
  203.             k = 0
  204.             x = RND * (sw - sww) + swn
  205.             y = RND * (sh - shw) + shn
  206.             r = INT(RND * 200)
  207.             n = names(r)
  208.             FOR j = 0 TO i - 1
  209.                 dx = x - star(j).x
  210.                 dy = y - star(j).y
  211.                 IF ABS(dx) < sww AND ABS(dy) < shw THEN
  212.                     k = 1
  213.                 END IF
  214.                 IF n = star(j).n THEN
  215.                     k = 1
  216.                 END IF
  217.             NEXT
  218.         WEND
  219.         star(i).n = n
  220.         star(i).x = x
  221.         star(i).y = y
  222.         star(i).c = RND * 6 + 9
  223.         star(i).s = RND * 5
  224.         star(i).o = 0
  225.     NEXT
  226.     FOR i = 2 TO 6
  227.         k = 1
  228.         WHILE k
  229.             k = 0
  230.             r = RND * 100
  231.             FOR j = 1 TO i - 1
  232.                 IF r = home(j) THEN k = 1
  233.                 x = star(0).x
  234.                 y = star(0).y
  235.                 dx = ABS(star(r).x - x)
  236.                 dy = ABS(star(r).y - y)
  237.                 IF dx < sw / 4 AND dy < sh / 4 THEN k = 1
  238.             NEXT
  239.         WEND
  240.         home(i) = r
  241.         star(r).o = i
  242.     NEXT
  243.  
  244. ' A lot of star names I made up
  245.  
  246. SUB StarNames
  247.     names(0) = "Acamar"
  248.     names(1) = "Arcab"
  249.     names(2) = "Acrux"
  250.     names(3) = "Adhara"
  251.     names(4) = "Arneb"
  252.     names(5) = "Antares"
  253.     names(6) = "Arcturus"
  254.     names(7) = "Atria"
  255.     names(8) = "Beid"
  256.     names(9) = "Betelgeuse"
  257.     names(10) = "Botein"
  258.     names(11) = "Beemim"
  259.     names(12) = "Bellatrix"
  260.     names(13) = "Bharani"
  261.     names(14) = "Biham"
  262.     names(15) = "Brachium"
  263.     names(16) = "Canopus"
  264.     names(17) = "Capella"
  265.     names(18) = "Castor"
  266.     names(19) = "Chara"
  267.     names(20) = "Cursa"
  268.     names(21) = "Copernicus"
  269.     names(22) = "Chalawan"
  270.     names(23) = "Chertan"
  271.     names(24) = "Dabih"
  272.     names(25) = "Dalim"
  273.     names(26) = "Deneb"
  274.     names(27) = "Denebola"
  275.     names(28) = "Diadem"
  276.     names(29) = "Diphda"
  277.     names(30) = "Dschubba"
  278.     names(31) = "Dziban"
  279.     names(32) = "Edasich"
  280.     names(33) = "Electra"
  281.     names(34) = "Elgafar"
  282.     names(35) = "Elkurud"
  283.     names(36) = "Elnath"
  284.     names(37) = "Eltanin"
  285.     names(38) = "Enif"
  286.     names(39) = "Errai"
  287.     names(40) = "Fafnir"
  288.     names(41) = "Fang"
  289.     names(42) = "Fawaris"
  290.     names(43) = "Felis"
  291.     names(44) = "Fomalhaut"
  292.     names(45) = "Fulu"
  293.     names(46) = "Fumal"
  294.     names(47) = "Furud"
  295.     names(48) = "Garnet"
  296.     names(49) = "Giausar"
  297.     names(50) = "Gienah"
  298.     names(51) = "Ginan"
  299.     names(52) = "Gomeisa"
  300.     names(53) = "Graffias"
  301.     names(54) = "Grumium"
  302.     names(55) = "Gudja"
  303.     names(56) = "Hadar"
  304.     names(57) = "Haedus"
  305.     names(58) = "Hamal"
  306.     names(59) = "Hassaleh"
  307.     names(60) = "Hatysa"
  308.     names(61) = "Helvetios"
  309.     names(62) = "Heze"
  310.     names(63) = "Homan"
  311.     names(64) = "Iklil"
  312.     names(65) = "Imai"
  313.     names(66) = "Intercrus"
  314.     names(67) = "Izar"
  315.     names(68) = "Iccar"
  316.     names(69) = "Inar"
  317.     names(70) = "Iaeth"
  318.     names(71) = "Imaous"
  319.     names(72) = "Jabbah"
  320.     names(73) = "Jishui"
  321.     names(74) = "Jax"
  322.     names(75) = "Jalae"
  323.     names(76) = "Jewel"
  324.     names(77) = "Jumbo"
  325.     names(78) = "Jerue"
  326.     names(79) = "Jabear"
  327.     names(80) = "Kakkab"
  328.     names(81) = "Kang"
  329.     names(82) = "Kekouan"
  330.     names(83) = "Keid"
  331.     names(84) = "Kitalpha"
  332.     names(85) = "Kochab"
  333.     names(86) = "Kolob"
  334.     names(87) = "Kobol"
  335.     names(88) = "Larawag"
  336.     names(89) = "Lesath"
  337.     names(90) = "Libertas"
  338.     names(91) = "Lich"
  339.     names(92) = "Lilly"
  340.     names(93) = "Laddel"
  341.     names(94) = "Luminous"
  342.     names(95) = "Lasacious"
  343.     names(96) = "Mizar"
  344.     names(97) = "Markab"
  345.     names(98) = "Matar"
  346.     names(99) = "Mintaka"
  347.     names(100) = "Meleph"
  348.     names(101) = "Menkar"
  349.     names(102) = "Merga"
  350.     names(103) = "Merope"
  351.     names(104) = "Nahn"
  352.     names(105) = "Naos"
  353.     names(106) = "Nashira"
  354.     names(107) = "Navi"
  355.     names(108) = "Nekkar"
  356.     names(109) = "Nembus"
  357.     names(110) = "Nihal"
  358.     names(111) = "Nunki"
  359.     names(112) = "Ogma"
  360.     names(113) = "Okab"
  361.     names(114) = "Ohmy"
  362.     names(115) = "Oragami"
  363.     names(116) = "Origen"
  364.     names(117) = "Omanii"
  365.     names(118) = "Obytewa"
  366.     names(119) = "Oglok"
  367.     names(120) = "Phact"
  368.     names(121) = "Pherkad"
  369.     names(122) = "Pleione"
  370.     names(122) = "Polaris"
  371.     names(123) = "Pollux"
  372.     names(124) = "Procyon"
  373.     names(125) = "Proxima"
  374.     names(126) = "Polis"
  375.     names(127) = "Quaint"
  376.     names(128) = "Quazzat"
  377.     names(129) = "Quetzal"
  378.     names(130) = "Qussol"
  379.     names(131) = "Quella"
  380.     names(132) = "Quyaeo"
  381.     names(133) = "Ququdas"
  382.     names(134) = "Quekak"
  383.     names(135) = "Rasalas"
  384.     names(136) = "Regor"
  385.     names(137) = "Regulus"
  386.     names(138) = "Rigel"
  387.     names(139) = "Revati"
  388.     names(140) = "Rotenev"
  389.     names(141) = "Rukbat"
  390.     names(142) = "Rastaban"
  391.     names(143) = "Sabik"
  392.     names(144) = "Sadr"
  393.     names(145) = "Saiph"
  394.     names(146) = "Sargas"
  395.     names(147) = "Sarin"
  396.     names(148) = "Syrma"
  397.     names(149) = "Spica"
  398.     names(150) = "Sirius"
  399.     names(151) = "Tarazed"
  400.     names(152) = "Taygeta"
  401.     names(153) = "Tejat"
  402.     names(154) = "Thabit"
  403.     names(155) = "Thuban"
  404.     names(156) = "Tiaki"
  405.     names(157) = "Toliman"
  406.     names(158) = "Torcular"
  407.     names(157) = "Umala"
  408.     names(158) = "Ulatte"
  409.     names(159) = "Ubbessa"
  410.     names(160) = "Unoless"
  411.     names(161) = "Umaddem"
  412.     names(162) = "Ummbra"
  413.     names(162) = "Uniqu"
  414.     names(163) = "Uzzaal"
  415.     names(164) = "Vega"
  416.     names(165) = "Veritate"
  417.     names(166) = "Vindetrix"
  418.     names(167) = "Vedas"
  419.     names(168) = "Vergg"
  420.     names(169) = "Vacant"
  421.     names(170) = "Vucae"
  422.     names(171) = "Vicar"
  423.     names(172) = "Wasat"
  424.     names(173) = "Wazn"
  425.     names(174) = "Wezen"
  426.     names(175) = "Waiten"
  427.     names(176) = "Wachar"
  428.     names(177) = "Wheelz"
  429.     names(178) = "Whatsp"
  430.     names(179) = "Wassand"
  431.     names(180) = "Xenno"
  432.     names(181) = "Xyphod"
  433.     names(182) = "Xu"
  434.     names(183) = "Xaal"
  435.     names(184) = "Xyross"
  436.     names(185) = "Xiggot"
  437.     names(186) = "Xirrks"
  438.     names(187) = "Yed"
  439.     names(188) = "Yildun"
  440.     names(189) = "yundun"
  441.     names(190) = "Yavyo"
  442.     names(191) = "Yotrac"
  443.     names(192) = "Yxzoqu"
  444.     names(193) = "Ynnot"
  445.     names(194) = "Zaniah"
  446.     names(195) = "Zaurak"
  447.     names(196) = "Zhang"
  448.     names(197) = "Zibal"
  449.     names(198) = "Zosma"
  450.     names(199) = "Zuben"
  451.  
  452.  
  453.  
  454.  
Title: Re: MOO
Post by: bplus on December 05, 2019, 04:26:46 PM
Hi Mike,

Quick tip, in Toolbox board there is a really nice circle fill routine you might want to pickup, first entry I think.
Title: Re: MOO
Post by: romichess on December 05, 2019, 05:34:32 PM
Hi Mike,

Quick tip, in Toolbox board there is a really nice circle fill routine you might want to pickup, first entry I think.

Cool!
Title: Re: MOO
Post by: TempodiBasic on December 06, 2019, 08:14:02 AM
Fine!
please say me
what is the conceptual difference between star showed as a voide circle and star showed as a full colored circle?

it is not necessary but I must note that
Code: QB64: [Select]
  1. DECLARE SUB NewGame
  2. DECLARE SUB PaintStars
  3. DECLARE SUB StarNames
  4. DECLARE SUB ShowPanel (i)
  5. DECLARE SUB Identify (x, y)
  6. DECLARE SUB PaintBackground
  7. DECLARE SUB GetInput
  8.  
  9.  
are declaration of subprograms need in QB4.5 QBASIC and QB PDS
for QB64 you can  change the code into this one
Code: QB64: [Select]
  1. 'DECLARE SUB NewGame
  2. 'DECLARE SUB PaintStars
  3. 'DECLARE SUB StarNames
  4. 'DECLARE SUB ShowPanel (i)
  5. 'DECLARE SUB Identify (x, y)
  6. 'DECLARE SUB PaintBackground
  7. 'DECLARE SUB GetInput
  8.  
  9.  
as you can read here http://www.qb64.org/wiki/DECLARE (http://www.qb64.org/wiki/DECLARE)

PS Welcome to QB64 forum!
Title: Re: MOO
Post by: romichess on December 06, 2019, 10:15:04 AM
Fine!
please say me
what is the conceptual difference between star showed as a voide circle and star showed as a full colored circle?

it is not necessary but I must note that
Code: QB64: [Select]
  1. DECLARE SUB NewGame
  2. DECLARE SUB PaintStars
  3. DECLARE SUB StarNames
  4. DECLARE SUB ShowPanel (i)
  5. DECLARE SUB Identify (x, y)
  6. DECLARE SUB PaintBackground
  7. DECLARE SUB GetInput
  8.  
  9.  
are declaration of subprograms need in QB4.5 QBASIC and QB PDS
for QB64 you can  change the code into this one
Code: QB64: [Select]
  1. 'DECLARE SUB NewGame
  2. 'DECLARE SUB PaintStars
  3. 'DECLARE SUB StarNames
  4. 'DECLARE SUB ShowPanel (i)
  5. 'DECLARE SUB Identify (x, y)
  6. 'DECLARE SUB PaintBackground
  7. 'DECLARE SUB GetInput
  8.  
  9.  
as you can read here http://www.qb64.org/wiki/DECLARE (http://www.qb64.org/wiki/DECLARE)

PS Welcome to QB64 forum!

Thanks, glad to be here. A painted circle is one of the six players. The human player for now always plays from Sol.
Title: Re: MOO
Post by: OldMoses on December 06, 2019, 12:02:10 PM
It looks like there are a few black holes in your star field. ;) Name boxes pop up where I don't see anything.

Welcome to the forum.

Title: Re: MOO
Post by: romichess on December 06, 2019, 02:41:49 PM
It looks like there are a few black holes in your star field. ;) Name boxes pop up where I don't see anything.

Welcome to the forum.

Thanks! That should have been fixed a couple of post ago. I'm about to make a new post and I'll make sure it does not do that anymore. Hmm, maybe a few cloaked planets is not a bad idea. The mouse did detect them by the way as they were there but painted black, lol.
Title: Re: MOO
Post by: romichess on December 06, 2019, 03:19:58 PM
I have decided to code the simplest space game possible just to have a game and not just some example code. Then I was reminded of a game that I used to play on my Atari 800 around 1984. It was a text screen space conquest game that used 40 characters, A thru z and the symbols above the numbers. Each turn every planet produced a number of ships. The players played by the hot seat style and there were no computer players. Each turn a player could send ships to another planet either friendly or hostile. It was a very simple yet fun game. So first I'll aim for something close to that.

I'm old and my eyes are not the greatest. Just a short while ago I noticed the cyberbit.ttf font that comes with QB64. So I switched to that font. It would have saved me a lot of time had I seen it sooner.

Now hitting 't' toggles between the name and the number of ships printed under the star. Trying to print both introduced noticeable lag. Printing must be very expensive. Now I'm wondering if QB64 will be fast enough. I suppose that the frame rate can be reduced to compensate.

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 INTEGER '                     (Type of planetary system; terran, frozen, radiated, toxic, etc.) Ships
  9.     p AS INTEGER '                     (Population) For now ships produced per turn
  10.  
  11. 'DECLARE SUB NewGame
  12. 'DECLARE SUB PaintStars
  13. 'DECLARE SUB StarNames
  14. 'DECLARE SUB ShowPanel (i)
  15. 'DECLARE SUB Identify (x, y)
  16. 'DECLARE SUB PaintBackground
  17. 'DECLARE SUB GetInput
  18.  
  19. ' Global variables shared because they are needed in more than one routine
  20. DIM SHARED sw AS INTEGER '             Screen Width
  21. DIM SHARED sh AS INTEGER '             Screen Height
  22. DIM SHARED sww AS INTEGER '            Screen Width Wide margin
  23. DIM SHARED swn AS INTEGER '            Screen Width Narrow adjustment
  24. DIM SHARED shw AS INTEGER '            Screen Height Wide margine
  25. DIM SHARED shn AS INTEGER '            Screen Height Narrow adjustment
  26. DIM SHARED nw AS INTEGER '             games Natural screen Width
  27. DIM SHARED nh AS INTEGER '             games Natural screen Height
  28. DIM SHARED ratio AS _FLOAT '           the Ratio of the games natural screen width to the actual
  29. DIM SHARED star(100) AS stars '        100 stars - may change
  30. DIM SHARED names(200) AS STRING * 10 ' 200 star names
  31. DIM SHARED seed AS INTEGER '           Seed to prime the Randomizer to display identical background each frame
  32. DIM SHARED home(6) AS INTEGER '        The starting star for each player. The human always has star(0), Sol
  33. DIM SHARED tt AS INTEGER '             tt = 0 star names displayed, tt = 0 star names not didplayed
  34. DIM SHARED ch AS STRING * 1 '          Game loop key input variable
  35. DIM SHARED repeat AS INTEGER '         Game loop control variable
  36.  
  37. sw = _DESKTOPWIDTH '                   native video with of syatem
  38. sww = sw / 24 '                        margin based on native video width to keep stars away from edge
  39. swn = sw / 48 '                        adjustment that works with sww to keep stars away from left and top of screen
  40. nw = 1920
  41.  
  42. ratio = sw / 1920 '                    Used to adjust distances and sizes for various screen modes
  43.  
  44. shw = sh / 20
  45. shn = sh / 40
  46. nh = 1080
  47.  
  48. tt = 0
  49. cx = sw
  50. cp = 100
  51. h = 100
  52. ar = 0
  53.  
  54. SCREEN _NEWIMAGE(sw, sh, 256) '        creates a screen the resolution of the users native system
  55.  
  56.  
  57. ps = _NEWIMAGE(400 * ratio, 540 * ratio, 256)
  58.  
  59. StarNames '                            Routine to load star names into string array stars(200)
  60.  
  61. NewGame
  62.  
  63. ttf1 = _LOADFONT("cyberbit.ttf", 14, "BOLD")
  64. ttf2 = _LOADFONT("cyberbit.ttf", 72, "BOLD")
  65.  
  66. repeat = 1
  67.  
  68. WHILE repeat
  69.  
  70.     _LIMIT 60 '                        Set to 60 frames per second
  71.  
  72.     CLS
  73.  
  74.     PaintBackground
  75.  
  76.     PaintStars
  77.  
  78.     GetInput
  79.  
  80.     Identify x, y '                    Identify star mouse is over if any
  81.  
  82.     computer
  83.  
  84.     _DISPLAY
  85.  
  86.  
  87.  
  88. SUB computer
  89.     FOR i = 0 TO 99
  90.         r = INT(RND * 120)
  91.         IF r < star(i).p THEN star(i).t = star(i).t + 1
  92.     NEXT
  93.  
  94. SUB GetInput
  95.  
  96.     ch = INKEY$
  97.     IF ch = CHR$(27) THEN repeat = 0
  98.     IF ch = "n" THEN NewGame
  99.     IF ch = "t" THEN tt = 1 - tt
  100.     ch = ""
  101.  
  102.     WHILE _MOUSEINPUT: WEND '          Eat all the mice but keep last mouse to toy with
  103.  
  104.     x = _MOUSEX
  105.     y = _MOUSEY
  106.     mb = _MOUSEBUTTON(1)
  107.     clk = 0
  108.  
  109.     IF mb = -1 AND cx = sw THEN
  110.         cx = x
  111.         cy = y
  112.     END IF
  113.  
  114.     IF mb = 0 AND cx < sw THEN
  115.         IF ABS(x - cx) < 4 AND ABS(y - cy) < 4 THEN
  116.             clk = 1
  117.         END IF
  118.         cx = sw
  119.     END IF
  120.  
  121. SUB PaintBackground
  122.     x = RND * sw
  123.     y = RND * sh
  124.     c = RND * 14 + 1
  125.     PSET (x, y), c
  126.     RANDOMIZE USING seed
  127.     FOR i = 1 TO 600 * ratio
  128.         x = RND * sw
  129.         y = RND * sh
  130.         c = RND * 14 + 1
  131.         PSET (x, y), c
  132.     NEXT
  133.  
  134. SUB ProcessPanel
  135.  
  136.  
  137. SUB Identify (x, y)
  138.     IF ar = 1 THEN
  139.         ShowPanel h
  140.         IF clk THEN
  141.             IF x >= x1 AND x <= x2 AND y >= y1 AND y <= y2 THEN
  142.                 ProcessPanel
  143.             ELSE
  144.                 ar = 0
  145.             END IF
  146.         END IF
  147.     END IF
  148.     IF ar = 0 THEN
  149.         FOR i = 0 TO 99
  150.             dx = star(i).x - x
  151.             dy = star(i).y - y
  152.             IF ABS(dx) <= star(i).s + 6 AND ABS(dy) <= star(i).s + 6 THEN
  153.                 ShowPanel i
  154.                 IF clk THEN
  155.                     clk = 0
  156.                     h = i
  157.                     ar = 1
  158.                     ax = x
  159.                 END IF
  160.             END IF
  161.         NEXT
  162.     END IF
  163.  
  164. SUB ShowPanel (i)
  165.     x1 = star(i).x - 420 * ratio
  166.     IF star(i).x