d
AS INTEGER ' (Population) For now ships production
' Global variables shared because they are needed in more than one routine
DIM SHARED ratio
AS _FLOAT ' the Ratio of the games natural screen width to the actual DIM SHARED seed
AS INTEGER ' Seed to prime the Randomizer to display identical background each frame DIM SHARED home
(7) AS INTEGER ' The starting star for each player. The human always has star(0), Sol
sww = sw / 24 ' margin based on native video width to keep stars away from edge
swn = sw / 48 ' adjustment that works with sww to keep stars away from left and top of screen
nw = 1920
ratio = sw / 1920 ' Used to adjust distances and sizes for various screen modes
shw = sh / 20
shn = sh / 40
nh = 1080
tt = 0
lcx = sw
rcx = sw
cp = 100
h = 100
ar = 0
rng = 200
slct = 0
strng = ""
strng0 = ""
strng1 = ""
src = 100
dst = 100
ord.src = 100
SCREEN _NEWIMAGE(sw
, sh
, 256) ' creates a screen the resolution of the users native system
sp
= _NEWIMAGE(400 * ratio
, 540 * ratio
, 256)op
= _NEWIMAGE(400 * ratio
, 225 * ratio
, 256)
StarNames ' Routine to load star names into string array stars(200)
NewGame
ttf16
= _LOADFONT("cyberbit.ttf", 16 * ratio
, "BOLD")ttf24
= _LOADFONT("cyberbit.ttf", 24 * ratio
, "BOLD")ttf36
= _LOADFONT("cyberbit.ttf", 36 * ratio
, "BOLD")ttf72
= _LOADFONT("cyberbit.ttf", 72 * ratio
, "BOLD")
repeat = 1
PaintBackground
PaintStars
PaintFleet
GetInput
Player
Computer
star(i).t = star(i).t + 1
star(i).t = star(i).t + 1
i = home(id)
dis = 0
hid = 0
dis = hate(id, j)
hid = j
away = 10000
jay = 100
star(j).d = star(j).d - 1
IF star
(j
).o
<> id
AND star
(i
).t
> star
(j
).t
* th
THEN ok = 0
dist
= SQR(ABS(star
(j
).x
- star
(k
).x
) ^ 2 + ABS(star
(j
).y
- star
(k
).y
) ^ 2) ok = 1
dist
= SQR(ABS(star
(j
).x
- star
(i
).x
) ^ 2 + ABS(star
(j
).y
- star
(i
).y
) ^ 2) away = dist
jay = j
SendFleet i, jay, star(i).t / 1.6
star(jay).d = 1000
sf2 = 100
IF star
(i
).o
= id
AND i
<> home
(id
) AND star
(i
).t
> LL
* 1.6 THEN sf3 = star(i).t / 2.5
star(j).d = star(j).d - 1
IF star
(j
).o
<> id
AND star
(i
).t
> star
(j
).t
* 4 THEN dist
= SQR(ABS(star
(k
).x
- star
(j
).x
) ^ 2 + ABS(star
(k
).y
- star
(j
).y
) ^ 2) sf1 = i
sf2 = j
SendFleet sf1, sf2, sf3
star(sf2).d = 1000
ok = 1
dist
= SQR(ABS(star
(i
).x
- star
(j
).x
) ^ 2 + ABS(star
(i
).y
- star
(j
).y
) ^ 2) ok = 0
SendFleet i, home(id), star(i).t / 2
ok = 0
IF star
(i
).t
> LL
* 1.5 + star
(i
).p
* 50 THEN ok = 1
SendFleet i, home(id), star(i).t / 4
count = fltcnt
i = 0
count = count - 1
IF fleet
(i
).x2
> fleet
(i
).x1
THEN fleet(i).x1 = fleet(i).x1 + 1
IF fleet
(i
).x2
< fleet
(i
).x1
THEN fleet(i).x1 = fleet(i).x1 - 1
IF fleet
(i
).y2
> fleet
(i
).y1
THEN fleet(i).y1 = fleet(i).y1 + 1
IF fleet
(i
).y2
< fleet
(i
).y1
THEN fleet(i).y1 = fleet(i).y1 - 1
IF fleet
(i
).x1
= fleet
(i
).x2
AND fleet
(i
).y1
= fleet
(i
).y2
THEN dest = fleet(i).d
IF star
(dest
).o
= fleet
(i
).o
THEN star(dest).t = star(dest).t + fleet(i).t
fleet(i).o = 0
fltcnt = fltcnt - 1
o = star(dest).o
IF o
> 0 AND star
(dest
).t
< fleet
(i
).t
* 0.6 THEN SendFleet dest, home(o), star(dest).t * 0.9
star(dest).t = 0
star(dest).o = fleet(i).o
star(dest).t = fleet(i).t
star(dest).o = fleet(i).o
fleet(i).o = 0
fltcnt = fltcnt - 1
IF fleet
(i
).t
* 1.1 > star
(dest
).t
THEN alive = 1
alive = 0
damorg = fleet(i).t / 10 + 1
damdst = star(dest).t / 8 + 1
fleet(i).t = fleet(i).t - damdst
star(dest).t = star(dest).t - damorg
alive = 1
star(dest).t = fleet(i).t
star(dest).o = fleet(i).o
fleet(i).o = 0
fltcnt = fltcnt - 1
k = 100
shortest = 10000
IF star
(j
).o
= fleet
(i
).o
THEN dist
= SQR(ABS(star
(j
).x
- fleet
(i
).x1
) ^ 2 + ABS(star
(j
).y
- fleet
(i
).y1
) ^ 2) shortest = dist
k = j
fleet(i).x2 = star(k).x
fleet(i).y2 = star(k).y
fleet(i).d = k
fleet(i).o = 0
fltcnt = fltcnt - 1
i = i + 1
IF ch
= "p" THEN paused
= 1 - paused
IF speed
< 10 THEN speed
= speed
+ 1 IF speed
> 0 THEN speed
= speed
- 1
lclk = 0
rclk = 0
lcx = sw
rcx = sw
i = Identify
paused = 1 - paused
ch = ""
src = 100
oact = 0
pact = 0
rclk = 0
rclk = 0
ii = 100
dx = star(i).x - x
dy = star(i).y - y
ii = i
Identify = ii
x1 = star(i).x - 420 * ratio
IF star
(i
).x
< sw
/ 2 THEN x1
= star
(i
).x
+ 20 * ratio
x2 = x1 + 400 * ratio
y1 = star(i).y
IF y1
> sh
- 225 * ratio
THEN y1
= sh
- 225 * ratio
y2 = y1 + 225 * ratio
LINE (20 * ratio
, 76 * ratio
)-(380 * ratio
, 76 * ratio
), 0 xo = 142 * ratio: xd = 250 * ratio: yo = 166 * ratio: yd = 200 * ratio
LINE (xo
, yo
)-(xd
, yd
), 7, BF
xo = 268 * ratio: xd = 314 * ratio: yo = 166 * ratio: yd = 200 * ratio
LINE (xo
, yo
)-(xd
, yd
), 7, BF
xo = 332 * ratio: xd = 366 * ratio: yo = 166 * ratio: yd = 200 * ratio
LINE (xo
, yo
)-(xd
, yd
), 7, BF
xo = 198 * ratio: xd = 278 * ratio: yo = 166 * ratio: yd = 200 * ratio
LINE (xo
, yo
)-(xd
, yd
), 7, BF
xo = 294 * ratio: xd = 340 * ratio: yo = 166 * ratio: yd = 200 * ratio
LINE (xo
, yo
)-(xd
, yd
), 7, BF
xo = 356 * ratio: xd = 390 * ratio: yo = 166 * ratio: yd = 200 * ratio
LINE (xo
, yo
)-(xd
, yd
), 7, BF
_PUTIMAGE (x1
, y1
), op
, 0, (0, 0)-(400 * ratio
, 225 * ratio
) oanx = x1: oany = y1
count = fltcnt
i = 0
CIRCLE (fleet
(i
).x1
, fleet
(i
).y1
), 3, fleet
(i
).o
+ 8 count = count - 1
i = i + 1
c = star(i).c
x = star(i).x
y = star(i).y
o = star(i).o
CIRCLE (x
, y
), (star
(i
).s
+ 8) * ratio
, c
n$ = star(i).n
'Add new order to standing orders
i = ord.src
order(i).src = 100
order(i) = ord
src = 100
ord.src = 100
'execute standing orders
IF star
(i
).o
<> 1 OR star
(order
(i
).dst
).o
<> 1 THEN order(i).src = 100
LINE (star
(i
).x
, star
(i
).y
)-(star
(order
(i
).dst
).x
, star
(order
(i
).dst
).y
), 17 IF star
(i
).t
>= order
(i
).ovr
THEN SendFleet order(i).src, order(i).dst, order(i).shp
'If there is no source star see if we can get one
lclk = 0
rclk = 0
src = Identify
' If there is a source star then draw a range line that snaps to center of destination, if one
c = 12
dist
= SQR(ABS(star
(i
).x
- x
) ^ 2 + ABS(star
(i
).y
- y
) ^ 2) c = 10
i = Identify
x = star(i).x
y = star(i).y
rang
= SQR(ABS(star
(src
).x
- x
) ^ 2 + ABS(star
(src
).y
- y
) ^ 2) LINE (star
(src
).x
, star
(src
).y
)-(x
, y
), c
'If we have a source star see if we clicked on a destination star
i = Identify
lclk = 0
src = 100
rclk = 0
order(i).src = 100
lclk = 0
dist
= SQR(ABS(star
(i
).x
- star
(j
).x
) ^ 2 + ABS(star
(i
).y
- star
(j
).y
) ^ 2) dst = i
pact = 1
rclk = 0
dst = i
oact = 1
'If the star standing orders panel is active
OrderPanel dst
x1 = oanx: x2 = oanx + 400 * ratio
y1 = oany: y2 = oany + 540 * ratio
IF y
> y1
+ 80 * ratio
AND y
< y1
+ 152 * ratio
THEN IF x
> x1
+ 20 * ratio
AND x
< x1
+ 380 * ratio
THEN dig = (x - x1 - 32 * ratio) / (37 * ratio)
IF y
> y1
+ 166 * ratio
AND y
< y1
+ 200 * ratio
THEN
IF x
> x1
+ 268 * ratio
AND x
< x1
+ 314 * ratio
THEN box = 1
IF x
> x1
+ 332 * ratio
AND x
< x1
+ 366 * ratio
THEN strng0 = ""
IF x
> x1
+ 294 * ratio
AND x
< x1
+ 340 * ratio
THEN strng1 = ""
box = 0
oact = 0
ord.src = src
ord.dst = dst
strng0 = ""
strng1 = ""
IF x
> x1
+ 356 * ratio
AND x
< x1
+ 390 * ratio
THEN strng0 = ""
strng1 = ""
box = 0
x1 = 10000: y1 = 10000
'If the fleet send panel is active
ShowPanel dst
x1 = panx: x2 = panx + 400 * ratio
y1 = pany: y2 = pany + 540 * ratio
IF y
> y1
+ 256 * ratio
AND y
< y1
+ 328 * ratio
THEN IF x
> x1
+ 20 * ratio
AND x
< x1
+ 380 * ratio
THEN dig = (x - x1 - 32 * ratio) / (37 * ratio)
IF y
> y1
+ 334 * ratio
AND y
< y1
+ 374 * ratio
THEN IF x
> x1
+ 20 * ratio
AND x
< x1
+ 84 * ratio
THEN pact = 0
value = star(src).t
SendFleet src, dst, value
src = 100
IF x
> x1
+ 102 * ratio
AND x
< x1
+ 184 * ratio
THEN pact = 0
value = star(src).t / 2
SendFleet src, dst, value
src = 100
IF x
> x1
+ 202 * ratio
AND x
< x1
+ 282 * ratio
THEN pact = 0
value = star(src).t / 3
SendFleet src, dst, value
src = 100
IF x
> x1
+ 300 * ratio
AND x
< x1
+ 380 * ratio
THEN strng = ""
IF y
> y1
+ 460 * ratio
AND y
< y1
+ 530 * ratio
THEN IF x
> x1
+ 32 * ratio
AND x
< x1
+ 182 * ratio
THEN strng = ""
pact = 0
IF value
<= star
(src
).t
AND star
(src
).t
<> o
THEN SendFleet src, dst, value
src = 100
IF x
> x1
+ 212 * ratio
AND x
< x1
+ 362 * ratio
THEN pact = 0
src = 100
strng = ""
FOR i
= 0 TO 99: qstar
(i
) = star
(i
): qorder
(i
) = order
(i
):
NEXT FOR i
= 0 TO 1999: qfleet
(i
) = fleet
(i
):
NEXT qhome(i) = home(i)
qhate(i, j) = hate(i, j)
qfltcnt = fltcnt
qLL = LL
FOR i
= 0 TO 99: star
(i
) = qstar
(i
): order
(i
) = qorder
(i
):
NEXT FOR i
= 0 TO 1999: fleet
(i
) = qfleet
(i
):
NEXT home(i) = qhome(i)
hate(i, j) = qhate(i, j)
fltcnt = qfltcnt
LL = qLL
paused = 1
SUB SendFleet
(src
, dst
, ships
) hate(star(src).o, star(dst).o) = hate(star(src).o, star(dst).o) + 1
fleet(i).o = star(src).o
fleet(i).d = dst
fleet(i).x1 = star(src).x
fleet(i).y1 = star(src).y
fleet(i).x2 = star(dst).x
fleet(i).y2 = star(dst).y
fleet(i).t = ships
star(src).t = star(src).t - ships
fltcnt = fltcnt + 1
IF fleet
(i
).o
> 1 AND LL
< 10000 THEN LL
= LL
+ 1
x1 = star(i).x - 420 * ratio
IF star
(i
).x
< sw
/ 2 THEN x1
= star
(i
).x
+ 20 * ratio
x2 = x1 + 400 * ratio
y1 = star(i).y
IF y1
> sh
- 560 * ratio
THEN y1
= sh
- 560 * ratio
y2 = y1 + 540 * ratio
n$ = "to"
LINE (20 * ratio
, 239 * ratio
)-(380 * ratio
, 239 * ratio
), 0 xo = 20 * ratio: xd = 84 * ratio: yo = 334 * ratio: yd = 374 * ratio
LINE (xo
, yo
)-(xd
, yd
), 7, BF
xo = 102 * ratio: xd = 184 * ratio: yo = 334 * ratio: yd = 374 * ratio
LINE (xo
, yo
)-(xd
, yd
), 7, BF
xo = 202 * ratio: xd = 282 * ratio: yo = 334 * ratio: yd = 374 * ratio
LINE (xo
, yo
)-(xd
, yd
), 7, BF
xo = 300 * ratio: xd = 380 * ratio: yo = 334 * ratio: yd = 374 * ratio
LINE (xo
, yo
)-(xd
, yd
), 7, BF
xo = 32 * ratio: xd = 182 * ratio: yo = 458 * ratio: yd = 530 * ratio
LINE (xo
, yo
)-(xd
, yd
), 7, BF
xo = 212 * ratio: xd = 362 * ratio: yo = 458 * ratio: yd = 530 * ratio
LINE (xo
, yo
)-(xd
, yd
), 7, BF
_PUTIMAGE (x1
, y1
), sp
, 0, (0, 0)-(400 * ratio
, 540 * ratio
) panx = x1: pany = y1
paused = 1
fleet(i).o = 0
slct = 0
fltcnt = 0
LL = 25
k = 1
k = 0
x
= RND * (sw
- sww
) + swn
y
= RND * (sh
- shw
) + shn
n = names(r)
dx = x - star(j).x
dy = y - star(j).y
k = 1
k = 1
star(i).n = n
star(i).x = x
star(i).y = y
star(i).o = 0
star
(i
).p
= star
(i
).s
+ (RND * 5) + 3 star(i).t = 0
order(i).src = 100
ok = 0
ok = 1
dist
= SQR(ABS(star
(j
).x
- star
(home
(k
)).x
) ^ 2 + ABS(star
(j
).y
- star
(home
(k
)).y
) ^ 2) ok = 0
ok = -1
dist
= SQR(ABS(star
(j
).x
- star
(k
).x
) ^ 2 + ABS(star
(j
).y
- star
(k
).y
) ^ 2) IF dist
<= 200 THEN ok
= ok
+ 1 home(i) = j
star(j).o = i
star(j).p = 10
star(j).t = 100
star(j).s = 4
star(home(1)).n = "Sol"
star(home(1)).c = 14
QuickSave
' A lot of star names I made up
names(0) = "Acamar"
names(1) = "Arcab"
names(2) = "Acrux"
names(3) = "Adhara"
names(4) = "Arneb"
names(5) = "Antares"
names(6) = "Arcturus"
names(7) = "Atria"
names(8) = "Beid"
names(9) = "Betelgeuse"
names(10) = "Botein"
names(11) = "Beemim"
names(12) = "Bellatrix"
names(13) = "Bharani"
names(14) = "Biham"
names(15) = "Brachium"
names(16) = "Canopus"
names(17) = "Capella"
names(18) = "Castor"
names(19) = "Chara"
names(20) = "Cursa"
names(21) = "Copernicus"
names(22) = "Chalawan"
names(23) = "Chertan"
names(24) = "Dabih"
names(25) = "Dalim"
names(26) = "Deneb"
names(27) = "Denebola"
names(28) = "Diadem"
names(29) = "Diphda"
names(30) = "Dschubba"
names(31) = "Dziban"
names(32) = "Edasich"
names(33) = "Electra"
names(34) = "Elgafar"
names(35) = "Elkurud"
names(36) = "Elnath"
names(37) = "Eltanin"
names(38) = "Enif"
names(39) = "Errai"
names(40) = "Fafnir"
names(41) = "Fang"
names(42) = "Fawaris"
names(43) = "Felis"
names(44) = "Fomalhaut"
names(45) = "Fulu"
names(46) = "Fumal"
names(47) = "Furud"
names(48) = "Garnet"
names(49) = "Giausar"
names(50) = "Gienah"
names(51) = "Ginan"
names(52) = "Gomeisa"
names(53) = "Graffias"
names(54) = "Grumium"
names(55) = "Gudja"
names(56) = "Hadar"
names(57) = "Haedus"
names(58) = "Hamal"
names(59) = "Hassaleh"
names(60) = "Hatysa"
names(61) = "Helvetios"
names(62) = "Heze"
names(63) = "Homan"
names(64) = "Iklil"
names(65) = "Imai"
names(66) = "Intercrus"
names(67) = "Izar"
names(68) = "Iccar"
names(69) = "Inar"
names(70) = "Iaeth"
names(71) = "Imaous"
names(72) = "Jabbah"
names(73) = "Jishui"
names(74) = "Jax"
names(75) = "Jalae"
names(76) = "Jewel"
names(77) = "Jumbo"
names(78) = "Jerue"
names(79) = "Jabear"
names(80) = "Kakkab"
names(81) = "Kang"
names(82) = "Kekouan"
names(83) = "Keid"
names(84) = "Kitalpha"
names(85) = "Kochab"
names(86) = "Kolob"
names(87) = "Kobol"
names(88) = "Larawag"
names(89) = "Lesath"
names(90) = "Libertas"
names(91) = "Lich"
names(92) = "Lilly"
names(93) = "Laddel"
names(94) = "Luminous"
names(95) = "Lasacious"
names(96) = "Mizar"
names(97) = "Markab"
names(98) = "Matar"
names(99) = "Mintaka"
names(100) = "Meleph"
names(101) = "Menkar"
names(102) = "Merga"
names(103) = "Merope"
names(104) = "Nahn"
names(105) = "Naos"
names(106) = "Nashira"
names(107) = "Navi"
names(108) = "Nekkar"
names(109) = "Nembus"
names(110) = "Nihal"
names(111) = "Nunki"
names(112) = "Ogma"
names(113) = "Okab"
names(114) = "Ohmy"
names(115) = "Oragami"
names(116) = "Origen"
names(117) = "Omanii"
names(118) = "Obytewa"
names(119) = "Oglok"
names(120) = "Phact"
names(121) = "Pherkad"
names(122) = "Pleione"
names(122) = "Polaris"
names(123) = "Pollux"
names(124) = "Procyon"
names(125) = "Proxima"
names(126) = "Polis"
names(127) = "Quaint"
names(128) = "Quazzat"
names(129) = "Quetzal"
names(130) = "Qussol"
names(131) = "Quella"
names(132) = "Quyaeo"
names(133) = "Ququdas"
names(134) = "Quekak"
names(135) = "Rasalas"
names(136) = "Regor"
names(137) = "Regulus"
names(138) = "Rigel"
names(139) = "Revati"
names(140) = "Rotenev"
names(141) = "Rukbat"
names(142) = "Rastaban"
names(143) = "Sabik"
names(144) = "Sadr"
names(145) = "Saiph"
names(146) = "Sargas"
names(147) = "Sarin"
names(148) = "Syrma"
names(149) = "Spica"
names(150) = "Sirius"
names(151) = "Tarazed"
names(152) = "Taygeta"
names(153) = "Tejat"
names(154) = "Thabit"
names(155) = "Thuban"
names(156) = "Tiaki"
names(157) = "Toliman"
names(158) = "Torcular"
names(157) = "Umala"
names(158) = "Ulatte"
names(159) = "Ubbessa"
names(160) = "Unoless"
names(161) = "Umaddem"
names(162) = "Ummbra"
names(162) = "Uniqu"
names(163) = "Uzzaal"
names(164) = "Vega"
names(165) = "Veritate"
names(166) = "Vindetrix"
names(167) = "Vedas"
names(168) = "Vergg"
names(169) = "Vacant"
names(170) = "Vucae"
names(171) = "Vicar"
names(172) = "Wasat"
names(173) = "Wazn"
names(174) = "Wezen"
names(175) = "Waiten"
names(176) = "Wachar"
names(177) = "Wheelz"
names(178) = "Whatsp"
names(179) = "Wassand"
names(180) = "Xenno"
names(181) = "Xyphod"
names(182) = "Xu"
names(183) = "Xaal"
names(184) = "Xyross"
names(185) = "Xiggot"
names(186) = "Xirrks"
names(187) = "Yed"
names(188) = "Yildun"
names(189) = "Yundun"
names(190) = "Yavyo"
names(191) = "Yotrac"
names(192) = "Yxzoqu"
names(193) = "Ynnot"
names(194) = "Zaniah"
names(195) = "Zaurak"
names(196) = "Zhang"
names(197) = "Zibal"
names(198) = "Zosma"
names(199) = "Zuben"