Empire Of The Far Suns - Space Conquest Strategy Game
created for the 50-line challenge, this game features
combat, invasion, and research among the stars,
against two hostile alien forces, in an ever-changing galaxy.
code as a 50-liner:
set display mode 1024,768,32 : sync on : sync rate 60 : sync : Randomize Timer() : color backdrop 0 : set text font "lucida console" : set text opaque : for t=1000 to 1300 : make object sphere t,1 : position object t,rnd(500)-250,rnd(500)-250,340+rnd(30) : next t : dim PS(36,11) : dim RP(3,6) : dim TL(3,6) : dim FL(3) : dim TH(36,3) : DIM N$(36) AS STRING : dim w$(5,6) as string : dim CN(2,6)
CREATE_NEW_GAME_HERE: : for i=1 to 36 : if image exist(i) : delete object i : delete image i : endif : next i : RESTORE : for t=1 to 3 : for u=0 to 4 : read a$ : w$(t,u)=a$ : next u : next t : for t=1 to 6 : read a$ : w$(5,t)=a$ : next t : k=rnd(105) : for t=1 to k : read a$ : next t : for t=1 to 36
if object exist(t) : delete object t : endif : next t : IMG=0 : FAIL=0 : for a=1 to 6 : for b=1 to 6 : IF RND(19)<12 : x=a*7-1+rnd(2) : y=b*7-1+rnd(2) : repeat : j=(25+rnd(100))*rnd(2) : k=(25+rnd(100))*rnd(2) : l=(25+rnd(100))*rnd(2) : until (j+k+l)>50 : create bitmap 1,16,16 : ink rgb(j,k,l),0 : box 0,0,15,15 : ink rgb(l,j,k),0 : for t=1 to 5+rnd(3) : c=rnd(9)+2 : d=rnd(9)+2
box c,d,c+1+rnd(3),d+1+rnd(3) : next t : ink rgb(k,l,j),0 : for t=1 to 3+rnd(1) : c=rnd(8)+2 : d=rnd(8)+2 : box c,d,c+1+rnd(4),d+1+rnd(4) : next t : blur bitmap 1,2 : inc IMG : get image img,0,0,15,15 : delete bitmap 1 : make object sphere img,3.3 : texture object img,img : position object img,x,y,37 : rotate object img,rnd(359),rnd(359),rnd(359) : fix object pivot img : PS(img,4)=x : PS(img,5)=y : PS(img,6)=0 : for t=1 to 3 : ps(img,t)=1 : ps(img,t+6)=0
next t : k=rnd(5)+4+(3*(rnd(4)=1)) : for t=1 to k : inc ps(img,(rnd(2)+1)) : next t : inc ps(img,1),(rnd(3)+1) : read a$ : n$(img)=a$ : ENDIF : next b : next a : for t=1 to 3 : repeat : p=rnd(img-1)+1 : until PS(p,6)=0 : PS(p,6)=t : for u=1 to 3 : ps(p,u)=rnd(2)+5 : next u : FL(t)=5 : next t : for t=2 to 3 : for u=1 to 4
inc RP(t,rnd(5)+1),u : next u : next t : for t=1 to 3 : for u=1 to 6 : TL(t,u)=1 : next u : next t : YEAR=2100+RND(2100) : Y1=YEAR : position camera 0,25,30,12 : repeat : until mouseclick()=0 : set camera aspect 1.333 : set camera view 0,0,1024,768 : ink RGB(0,128,192),RGB(128,34,34) : set text size 48 : do : center text 512,200,"Empire Of The Far Suns" : center text 512,300,"Click Mouse To Play"
for i=1 to img : yrotate object i,object angle y(i)+0.5 : next i : sync : if mouseclick() : exit : endif : loop : set text size 16 : set camera aspect 1.0 : set camera view 0,0,600,600 : position camera 0,25,30,0 : Display_State=1 : DO : INC YEAR : if YEAR mod 8 = 0 : for i=1 to img : inc PS(i,1) : inc PS(i,rnd(1)+2) : next i : endif : CurPlay=1
GOSUB INIT_STATE : GOSUB PLAN_VAL_STR : FOR I=1 TO IMG : for OFF=1 to 3 : for DEF=1 to 3 : if OFF<>DEF : if PS(i,6+OFF)>0 and PS(i,6+DEF)>0 : for t=0 to 2 : for u=0 to 6 : CN(t,u)=0 : next u : next t : cn(1,0)=OFF : cn(2,0)=DEF : show=0 : if off=1 or def=1 : show=1 : C=1 : E=2 : if def=1 : C=2 : E=1
endif : endif : round=0 : repeat : inc round : if round=1 : PICK=99 : for t=1 to 2 : cn(t,1)=ps(i,6+cn(t,0)) : cn(t,2)=cn(t,1)*(6+(2*int(sqrt(TL(cn(t,0),4))))) : cn(t,4)=rnd(2)+1 : cn(t,5)=rnd(2)+1 : cn(t,6)=1 : for u=2 to 3 : if TL(cn(t,0),u)>TL(cn(t,0),cn(t,6)) : cn(t,6)=u : endif : next u : next t
else : for t=1 to 2 : PICK=1 : if cn(t,2)>0 : cn(t,1)=(cn(t,2) / (6+(2*int(sqrt(TL(cn(t,0),4))))))+1 : else : cn(t,1)=0 : endif : next t : for t=1 to 2 : if cn(t,0)>1 : if rnd(4)<4 : cn(t,rnd(1)+4)=rnd(2)+1 : endif : endif : next t : endif : IF CN(1,1)>0 AND CN(2,1)>0 : IF SHOW=1 : repeat : until mouseclick()=0 : DO
cls rgb(20,20,70) : center text 512,60," COMBAT AT "+N$(I)+" " : center text 512,80," ROUND # "+STR$(ROUND)+" " : text 300,120," You have "+str$(CN(c,1))+" Ships " : text 300,140," Player "+str$(cn(e,0))+" has "+str$(CN(e,1))+" Ships " : text 300,160," Give Your Fleet Orders ("+str$(PICK)+") " : for t=1 to 3 : text 200,100+100*t,w$(t,0)+":" : for u=1 to 3 : a$=w$(t,u) : if cn(c,t+3)=u : a$=upper$(" *"+a$+"* ") : endif : text 300,100+100*t+(u-1)*20,a$ : next u : next t : text 400,500," ENGAGE " : if mouseclick()=1 : if mousex()>199 and mousex()<420 : L=(mousey()-100)/100 : V=1+(mousey()-(100+L*100))/20
if L>0 and L<4 : if v>0 and V<4 : cn(c,L+3)=V : Dec PICK : repeat : until mouseclick()=0 : endif : endif : endif : IF mousey()>495 and mousey()<525 : if mousex()>300 and mousex()<500 : EXIT : endif : ENDIF : endif : sync : if PICK<1 : wait 500 : EXIT : endif : loop : ENDIF : for t=1 to 2
d=(int(sqrt(TL(cn(t,0),cn(t,6))))+2)*cn(t,1) : cn(t,3)=(d+rnd(d))*0.55 : next t : for t=1 to 3 : w$(4,t)="" : next t : for t=4 to 6 : if (cn(1,t)=1 and cn(2,t)=2 ) OR (cn(1,t)=2 and cn(2,t)=3 ) OR (cn(1,t)=3 and cn(2,t)=1 ) : DEC cn(2,3),((cn(2,3)/10)+1) : w$(4,t-3)=" Player "+str$(cn(1,0))+" has the advantage in "+w$(t-3)+" " : endif : next t : for t=4 to 6 : if (cn(2,t)=1 and cn(1,t)=2 ) OR (cn(2,t)=2 and cn(1,t)=3 ) OR (cn(2,t)=3 and cn(1,t)=1 ) : DEC cn(1,3),((cn(1,3)/10)+1) : w$(4,t-3)=" Player "+str$(cn(2,0))+" has the advantage in "+w$(t-3)+" " : endif : next t
IF SHOW=0 : dec cn(1,2),cn(2,3) : dec cn(2,2),cn(1,3) : ELSE : repeat : cls rgb(20,20,70) : center text 512,60," COMBAT AT "+N$(I)+" " : center text 512,80," ROUND # "+STR$(ROUND)+" " : for t=1 to 2 : if cn(t,2)>0 : cn(t,1)=(cn(t,2) / (6+(2*int(sqrt(TL(cn(t,0),4))))))+1 : else : cn(t,1)=0 : endif : next t : for t=1 to 2 : text (t-1)*400+100,100," Player "+str$(cn(t,0)) : text (t-1)*400+100,120," Ships : "+str$(cn(t,1)) : text (t-1)*400+100,140," Hull Points : "+str$(cn(t,2))
for u=1 to 3 : text (t-1)*400+100,160+u*20,w$(u,0)+" : "+w$(u,cn(t,u+3)) : next u : next t : for t=1 to 3 : if w$(4,t)<>"" : text 300,330+t*20,w$(4,t) : endif : next t : text 400,500," CONTINUE " : sync : if cn(1,3)>0 : dec cn(2,2) : dec cn(1,3) : endif : if cn(2,3)>0 : dec cn(1,2) : dec cn(2,3) : endif : until ( cn(2,3)<1 and cn(1,3)<1 ) OR cn(2,2)<0 or cn(1,2)<0 : DO : if mouseclick()
IF mousey()>495 and mousey()<525 : if mousex()>300 and mousex()<500 : EXIT : endif : ENDIF : endif : LOOP : ENDIF : ENDIF : until CN(1,1)=0 or CN(2,1)=0 : FOR T=1 TO 2 : PS(I,6+CN(T,0))=CN(T,1) : NEXT T : endif : endif : next DEF : next OFF : NEXT I : for t=1 to img : inc FL(ps(T,6)),PS(T,2) : next t : FL(0)=0 : YES=0
for t=1 to img : if ps(t,7)>=PS(T,11) : yes=1 : endif : next t : if yes=1 : COL_PHASE=1 : GOSUB INIT_STATE : GOSUB PLAN_VAL_STR : do : GOSUB SCREEN_SUBROUTINE : center text 812,24," COLONIZATION PHASE " : center text 812,64," Right Click Circled Planet To Colonize " : CENTER TEXT 812,84," DONE " : if mouseclick()=2 : T=pick object(mousex(),mousey(),1,img) : if t>0 and t<=img : if ps(t,6)<>1 : if ps(t,7)>=PS(T,11) : dec ps(t,7),PS(T,11) : ps(t,6)=1 : GOSUB PLAN_VAL_STR
endif : endif : endif : endif : if mouseclick()=1 : if mousey()>84 and mousey()<104 : if mousex()>780 and mousex()<844 : EXIT : endif : endif : endif : sync : loop : COL_PHASE=0 : endif : e=0 : FOR I=1 TO IMG : if PS(i,6)>1 : inc e : endif : NEXT I : IF e=0 : repeat
until mouseclick()=0 : CLS RGB(20,20,70) : set text size 48 : center text 512,200," YOU WIN! " : center text 512,280," YOU BUILT THE SUPREME EMPIRE " : center text 512,328," IN "+STR$(YEAR-Y1)+" YEARS! " : center text 512,400," Click Mouse To Play Again " : center text 512,450," Or Hit Escape Key To Quit " : sync : wait mouse : GOTO CREATE_NEW_GAME_HERE : ENDIF : FOR P=2 TO 3 : CurPlay=P : GOSUB INIT_STATE : for i=1 to img : if ps(i,6)<>P : if ps(i,6+P)>=PS(I,11) : if ps(i,7)<1 AND ( ( p=2 and ps(i,9)<1 ) OR ( p=3 and ps(i,8)<1 ) ) : dec ps(i,6+P),PS(I,11) : if ps(i,6)=1
CLS RGB(20,20,70) : center text 512,240+rnd(20)," Player "+str$(P)+" Invaded Your Colony At "+n$(i)+" " : sync : wait 2500 : endif : ps(i,6)=P : GOSUB PLAN_VAL_STR : endif : endif : endif : next i : NEXT P : e=0 : FOR I=1 TO IMG : if PS(i,6)=1 : inc e : endif : NEXT I : IF e=0
YOU_LOST_THE_GAME: : repeat : until mouseclick()=0 : CLS RGB(20,20,70) : set text size 48 : center text 512,200," YOU HAVE BEEN DEFEATED! " : center text 512,400," Click Mouse To Play Again " : center text 512,450," Or Hit Escape Key To Quit " : sync : wait mouse : GOTO CREATE_NEW_GAME_HERE : ENDIF : GOSUB PLAN_VAL_STR : CurPlay=1 : for t=1 to img : if ps(t,7)>0 : inc FL(1),ps(t,7) : ps(t,7)=0 : endif : next t : GOSUB INIT_STATE : GOSUB PLAN_VAL_STR : REPEAT : GOSUB SCREEN_SUBROUTINE
center text 812,24," MOVEMENT PHASE " : center text 812,64," Left Click Planet To Add 1 Ship " : center text 812,84," Right Click To Add 5 " : center text 812,264," "+str$(FL(1))+" Ships Left " : if mouseclick() : T=pick object(mousex(),mousey(),1,img) : if t>0 and t<=img : if object visible(t) : N=1 : if mouseclick()=2 AND fl(1)>4 : N=5 : endif : dec FL(1),n : inc PS(t,7),n : wait 125 : endif : endif : endif : SYNC : UNTIL FL(1)<1 : wait 250 : GOSUB INIT_STATE : GOSUB PLAN_VAL_STR
P=0 : for t=1 to img : if ps(t,6)=1 : inc P,ps(t,3) : endif : next t : REPEAT : GOSUB SCREEN_SUBROUTINE : center text 812,24," RESEARCH PHASE " : center text 812,64," Click To Add Points " : center text 812,84," "+str$(P)+" Points Left " : if mouseclick() : if mousex()>612 and mousex()<750 : y=(mousey()/20)-5 : if y>0 and y<7 : s=(P/25)+1 : dec P,s : Inc TL(1,y),s : wait 125 : endif : endif : endif
for t=1 to 6 : text 612,100+t*20,w$(5,t)+STR$(TL(1,t))+" ("+str$(INT(SQRT(TL(1,t))))+") " : next t : sync : UNTIL P<1 : wait 250 : FOR P=2 TO 3 : alive=0 : for i=1 to img : if ps(i,6)=P : alive=1 : endif : next i : if alive=0 : fl(p)=0 : for i=1 to img : ps(i,6+P)=0 : next i : endif : IF ALIVE=1 : CurPlay=P
GOSUB INIT_STATE : GOSUB PLAN_VAL_STR : for t=1 to img : if ps(t,6+P)>0 : inc FL(P),ps(t,6+P) : ps(t,6+P)=0 : endif : next t : for i=1 to img : for j=0 to 3 : th(i,j)=0 : next j : TH(I,1) = (ps(I,10)*100) / ps(I,11) : if ps(i,6)=0 : TH(I,1)=TH(I,1)*2.2 : endif : if object visible(i) : if FL(P)>=PS(i,11) AND PS(i,6)<>P : th(i,3)=1 : endif : endif : next i : F=FL(P)
fail=0 : while f>0 : TAR=0 : QUO=0 : for i=1 to img : if rnd(2)<2 : if th(i,3)=1 : if f>=ps(i,11) : if ps(i,6+P)<7 : if TH(I,1)>QUO : QUO=TH(I,1) : TAR=I : endif : endif : endif : endif : endif : next i : if tar>0 and quo>0 : ps(TAR,6+p)=ps(TAR,11) : dec f,ps(TAR,11) : x=rnd(f/2) : inc ps(TAR,6+p),x
dec f,x : endif : if fail>25 : repeat : if f>0 : x=rnd(img-1)+1 : if PS(x,6)=P : inc ps(x,6+P) : dec F : endif : endif : until f<1 : endif : INC FAIL : endwhile : FL(p)=0 : RP=0 : for t=1 to img : if ps(t,6)=P : inc RP,ps(t,3) : endif : next t : TRP=RP
nav=1 : vis=0 : for i=1 to img : if object visible(i) : inc vis : if ps(i,6)<>P : nav=0 : endif : endif : next i : if vis>=img OR TL(P,6)>48 : nav=0 : endif : IF NAV=1 : inc TL(P,6),RP : RP=0 : TRP=0 : ELSE : for a=1 to 5 : Z=(RP(P,a)*10*TRP)/100 : inc TL(P,A),Z : dec RP,Z : next a
while RP>0 : a=rnd(4)+1 : inc TL(P,A) : dec RP : endwhile : ENDIF : ENDIF : NEXT P : LOOP : END
SCREEN_SUBROUTINE: : if Display_State=2 : set text size 12 : endif : if Display_State=3 : set text size 14 : endif : for tt=1 to img : IF OBJECT VISIBLE(tT) : yrotate object tt,object angle y(tt)+0.35 : ox=object screen x(tt)*0.586 : oy=object screen y(tt)*0.781 : if Display_State=1 : center text ox,oy-18,n$(tt) : if PS(Tt,6)>0 : center text ox,oy," "+str$(PS(Tt,6))+" " : endif : endif : if Display_State=2
center text ox,oy-21," P: "+str$((ps(tt,1)))+" " : center text ox,oy-9," F: "+str$((ps(tt,2)))+" " : center text ox,oy+3," R: "+str$((ps(tt,3)))+" " : center text ox,oy+15," S: "+str$( ps(tt,11) )+" " : endif : if Display_State=3 : center text ox,oy-18," 1: "+str$((PS(tt,7)))+" " : center text ox,oy-6," 2: "+str$((PS(tt,8)))+" " : center text ox,oy+6," 3: "+str$((PS(tt,9)))+" " : endif : if COL_PHASE=1 : if ps(tt,6)<>1 : if ps(tt,7)>=ps(tt,11) : IF ps(tt,8)<1 and ps(tt,9)<1 : circle ox,oy,26 : circle ox,oy,27 : circle ox,oy,28 : ENDIF : endif : endif
endif : ENDIF : next tt : set text size 16 : if mouseclick()=1 : mx=mousex() : my=mousey() : IF MY>740 : IF MX>712 AND MX<912 : GOTO YOU_LOST_THE_GAME : ENDIF :ENDIF : if my>604 and my<620 : Display_State=0 : if mx>165 and mx<235 : Display_State=1 : endif : if mx>265 and mx<335 : Display_State=2 : endif : if mx>365 and mx<435 : Display_State=3
endif : endif : endif : ink rgb(20,20,70),0 : box 0,600,1024,768 : box 600,0,1024,768 : ink RGB(0,128,192),RGB(128,34,34) : line 0,0,1024,0 : line 0,0,0,768 : line 600,0,600,600 : line 0,600,601,600 : line 0,767,1024,767 : line 1023,0,1023,767 : center text 200,604," OWNER " : center text 300,604," STATS " : center text 400,604," FLEET " : CENTER TEXT 812,740," * SURRENDER * " : for tt=1 to 3 : text (tt-1)*150+112,650,w$(tt,4) : text 44,650+tt*20," "+str$(tt)+" "
next tt : for tt=1 to 3 : for uu=0 to 6 : tl(0,uu)=0 : next uu : for ii=1 to img : if PS(ii,6)=tt : for uu=1 to 3 : inc tl(0,uu),ps(ii,uu) : next uu : endif : next ii : for uu=1 to 3 : text (uu-1)*150+112,650+tt*20,str$(tl(0,uu)) : next uu : next tt : center text 812,44," Year : "+str$(year)+" " : RETURN
PLAN_VAL_STR: : FOR T=1 TO IMG : PS(T,10)=(ps(t,2)+ps(t,3)) : PS(T,11)=ps(t,1)+PS(T,10)+((ps(t,6)>0)*int(SQRT(TL(ps(t,6),5)))) : NEXT T : RETURN
INIT_STATE: : range=( 6+ (SQRT(TL(CurPlay,6))*3) ) : for t=1 to img : hide object t : next t : for t=1 to img : if ps(t,6)=CurPlay : show object t : for u=1 to img : if (abs(ps(u,4)-ps(t,4))+abs(ps(u,5)-ps(t,5)))<range : show object u : endif : next u : endif : next t : RETURN
data "STRATEGY","Fighter Attack","Battleship Firepower","Destroyer Maneuver","POPULATION","FORMATION","Hexagon","Wing","Zig-Zag","SHIPYARDS","WEAPON","Beams","Missiles","Mines","RESEARCH"," BEAMS: "," MISSILES: "," MINES: "," DEFENSE: "," TROOPS: "," NAVIGATION: "
DATA "Inora","Ixat","Sicogu","Iraga","Tethia","Zelopol","Chigor","Alsapha","Ataxon","Inzaras","Ulsulus","Venuxi","Lyapht","Dmuren","Inx","Sirces","Icogol","Darisul","Vugi","Zentili","Kotolro","Ioturon","Kadic","Jogoth"
DATA "Epran","Heraph","Mesga","Orazar","Sirukur","Pryus","Duoni","Kasoria","Tunephi","Etacion","Usomi","Eadi","Darsag","Ulicon","Clyus","Oxus","Rulko","Hayx","Oszri","Azarosa","Betu","Mirnath","Kimuri","Denigal"
DATA "Ondisa","Quordas","Usbeda","Uphrama","Hados","Orunath","Iliau","Joruk","Wrackur","Psani","Corigar","Rhefac","Silsha","Rafiad","Kemiron","Maryda","Izreus","Cibra","Argen","Nirodu","Astaka","Bhezar","Inconis","Delomec"
DATA "Idaros","Chromad","Misurud","Cornath","Vhudia","Jalyria","Onpha","Chiphan","Talux","Rasoron","Forani","Animir","Sildar","Koryl","Uronze","Mindara","Imiosc","Dargi","Daceron","Irasa","Cliurna","Iskande","Heralis"
DATA "Ebudri","Enicon","Uprogol","Eprusil","Tanir","Vagen","Prinath","Entaghi","Mizraga","Gisima","Irami","Ineax","Ontau","Regiden","Yirigi","Mayisa","Alera","Targesa","Masilus","Osreba","Tazuron","Detha","Tazaros","Rosmir"
DATA "Sirnami","Turnema","Askendi","Altoven","Ormiga","Mirius","Magmada","Necersi","Onumen","Ymbecri","Forturi","Scheda","Shiri","Cigen","Agemna","Rukani","Idmar","Cequum","Gaezann","Yenchak","Nepanus","Aethia"
Readme & Instructions:
Empire Of The Far Suns
By Bob Saunders
This is a strategy game of space conquest,
programmed in Dark Basic Professional for the 50-line challenge.
The challenge rules state that you may use up to 25 commands per line.
EOTFS uses only 43 lines, with a maximum of 24 commands per line (average=21).
The program requires no external media; it creates its own.
[]
Gameplay proceeds until you are destroyed, or both enemies are defeated,
or until you surrender or quit (escape key).
No two games are ever alike. The planets have different names, appearances, and locations every time.
AI players have different research priorities every time, and they are focused, not random distribution.
AIs also choose targets intelligently, but with enough randomness to provide a challenge.
[]
DISPLAY:
The majority of the screen (upper left) shows all the planets that you can reach.
You may choose to view them by OWNER, STATS, or FLEETS.
-Owner shows the NAME of the planet and the NUMBER of the player that owns it,
if any.
-Stats shows P/F/R/S for the planet. These stand for
Population - a relative measure of the number of inhabitants.
Fleet - how many new ships the planet can produce per year.
Research - how many "Research Points" the planet produces per year.
Strength - how many ships you would need to land to colonize (or invade) the planet.
-Fleet display shows how many ships each player has in that star system. Usually 0.
The rest of the display is taken up by whatever is necessary for the current "PHASE",
and a running tally of the relative holdings of each player.
[]
The game is played in "Phases" that comprise each turn (or year).
PHASE 1: COLONIZATION
---------------------
If you have enough ships at a planet to colonize (or invade) it,
you may choose to do so. 'Enough' is greater than or equal to that planet's Strength.
(under STAT display, the last number, labeled 'S:' ).
Right click any circled planet to colonize, then hit "DONE" at upper right.
PHASE 2: MOVEMENT
-----------------
At the beginning of the movement phase, all of your ships are taken from wherever they are,
and put into a "pool". You may then send any ships anywhere within your navigation range.
They will arrive at the beginning of the next turn. This is how you colonize planets,
and ultimately defeat your enemy's fleets.
PHASE 3: RESEARCH
-----------------
During this phase, you take the combined scientific power of your empire and apply it
to 6 different areas of technology.
Beams, Missiles, and Mines are 3 weapons technologies. Higher levels increase damage.
Defense tech increases how much damage your ships can take before being destroyed.
Troop tech increases the number of ships an invading force needs to take your worlds.
Navigation tech increases how far your ships can travel.
PHASE 4: COMBAT
---------------
Combat occurs any time 2 or more players have ships orbiting the same planet.
You have 3 decisions to make during the first round of combat.
Strategy, Formation, and Weapon. No single choice is absolutely better than another.
instead, they interact in a rock-scissors-paper manner.
STRATEGY: Battleship Firepower, Destroyer Maneuver , Fighter Attack
FORMATION: Hexagon, Wing, Zig-Zag
WEAPON: Beams, Missiles, Mines
The 1st beats the 2nd, the 2nd beats the 3rd, and the 3rd beats the 1st.
Having advantage in one of these areas decreases the amount of damage your ships will take.
NOTE that since weapons have a "Tech Level", it would be better to use L7 Beams instead of
L2 missiles, even if your oponent were using Mines (which "beat" beams).
During the SECOND and all subsequent rounds of a single combat,
you may only change ONE of the 3 choices about your fleet's tactics per round.
Combat continues until one side is destroyed. There is no retreat.
[]
A final note on the code of the game:
The 50 line / 25 command rule imposes interesting challenges in programming a DBP game.
Common structures like user defined types and functions will not compile on a single line (in my version).
So a lot of what-means-what must be kept in the programmers head, and the cluttered MAIN() becomes the norm.
Do NOT take my coding methods as the best idea for all situations.
Nevertheless, this is a great game (IMHO) for the limitations.
if you are running
dbp 6.2 or above, i recommend
this code:
set display mode 1024,768,32 : sync on : sync rate 60 : sync : Randomize Timer() : color backdrop 0 : set text font "lucida console" : set text opaque : for t=1000 to 1300 : make object sphere t,1 : position object t,rnd(500)-250,rnd(500)-250,340+rnd(30) : next t : dim PS(36,11) : dim RP(3,6) : dim TL(3,6) : dim FL(3) : dim TH(36,3) : DIM N$(36) AS STRING : dim w$(5,6) as string : dim CN(2,6) : dim BC(6) as BYTE
for t=1 to 6 : bc(t)=80+rnd(9)*5 : next t : set text size 16 : do : cls rgb(BC(1),BC(2),BC(3)) : ink RGB(0,128,192),rgb(BC(4),BC(5),BC(6)) : center text 512,100," SCREEN COLOR MODIFIER " : center text 512,140," Mouse-Over the color you want to change" : center text 512,160," roll mouse wheel to change that component " : center text 512,180," PRESS ANY KEY WHEN YOU ARE FINISHED " : CENTER text 200,280," Background Screen Color " : CENTER text 800,280," Text Background Color " : for t=0 to 1 : CENTER text 200+t*600,300," RED "+STR$(BC(T*3+1))
CENTER text 200+t*600,320," GREEN "+STR$(BC(T*3+2)) : CENTER text 200+t*600,340," BLUE "+STR$(BC(T*3+3)) : next t : z=mousemovez() : z=(z/abs(z))*5 : y=(mousey()-280)/20 : x=mousex() : if y>0 and y<4 : if x>150 and x<250 : bc(y)=bc(y)+z : endif : if x>750 and x<850 : bc(y+3)=bc(y+3)+z : endif : endif : sync : IF SCANCODE() :EXIT : ENDIF : loop
CREATE_NEW_GAME_HERE: : for i=1 to 36 : if image exist(i) : delete object i : delete image i : endif : next i : RESTORE : for t=1 to 3 : for u=0 to 4 : read a$ : w$(t,u)=a$ : next u : next t : for t=1 to 6 : read a$ : w$(5,t)=a$ : next t : k=rnd(105) : for t=1 to k : read a$ : next t : for t=1 to 36
if object exist(t) : delete object t : endif : next t : IMG=0 : FAIL=0 : for a=1 to 6 : for b=1 to 6 : IF RND(19)<12 : x=a*7-1+rnd(2) : y=b*7-1+rnd(2) : repeat : j=(25+rnd(100))*rnd(2) : k=(25+rnd(100))*rnd(2) : l=(25+rnd(100))*rnd(2) : until (j+k+l)>50 : create bitmap 1,16,16 : ink rgb(j,k,l),0 : box 0,0,15,15 : ink rgb(l,j,k),0 : for t=1 to 5+rnd(3) : c=rnd(9)+2 : d=rnd(9)+2
box c,d,c+1+rnd(3),d+1+rnd(3) : next t : ink rgb(k,l,j),0 : for t=1 to 3+rnd(1) : c=rnd(8)+2 : d=rnd(8)+2 : box c,d,c+1+rnd(4),d+1+rnd(4) : next t : blur bitmap 1,2 : inc IMG : get image img,0,0,15,15 : delete bitmap 1 : make object sphere img,3.3 : texture object img,img : position object img,x,y,37 : rotate object img,rnd(359),rnd(359),rnd(359) : fix object pivot img : PS(img,4)=x : PS(img,5)=y : PS(img,6)=0 : for t=1 to 3 : ps(img,t)=1 : ps(img,t+6)=0
next t : k=rnd(5)+4+(3*(rnd(4)=1)) : for t=1 to k : inc ps(img,(rnd(2)+1)) : next t : inc ps(img,1),(rnd(3)+1) : read a$ : n$(img)=a$ : ENDIF : next b : next a : for t=1 to 3 : repeat : p=rnd(img-1)+1 : until PS(p,6)=0 : PS(p,6)=t : for u=1 to 3 : ps(p,u)=rnd(2)+5 : next u : FL(t)=5 : next t : for t=2 to 3 : for u=1 to 4
inc RP(t,rnd(5)+1),u : next u : next t : for t=1 to 3 : for u=1 to 6 : TL(t,u)=1 : next u : next t : YEAR=2100+RND(2100) : Y1=YEAR : position camera 0,25,30,12 : repeat : until mouseclick()=0 : set camera aspect 1.333 : set camera view 0,0,1024,768 : ink RGB(0,128,192),rgb(BC(4),BC(5),BC(6)) : set text size 48 : do : center text 512,200,"Empire Of The Far Suns" : center text 512,300,"Click Mouse To Play"
for i=1 to img : yrotate object i,object angle y(i)+0.5 : next i : sync : if mouseclick() : exit : endif : loop : set text size 16 : set camera aspect 1.0 : set camera view 0,0,600,600 : position camera 0,25,30,0 : Display_State=1 : DO : INC YEAR : if YEAR mod 8 = 0 : for i=1 to img : inc PS(i,1) : inc PS(i,rnd(1)+2) : next i : endif : CurPlay=1
GOSUB INIT_STATE : GOSUB PLAN_VAL_STR : FOR I=1 TO IMG : for OFF=1 to 3 : for DEF=1 to 3 : if OFF<>DEF : if PS(i,6+OFF)>0 and PS(i,6+DEF)>0 : for t=0 to 2 : for u=0 to 6 : CN(t,u)=0 : next u : next t : cn(1,0)=OFF : cn(2,0)=DEF : show=0 : if off=1 or def=1 : show=1 : C=1 : E=2 : if def=1 : C=2 : E=1
endif : endif : round=0 : repeat : inc round : if round=1 : PICK=99 : for t=1 to 2 : cn(t,1)=ps(i,6+cn(t,0)) : cn(t,2)=cn(t,1)*(6+(2*int(sqrt(TL(cn(t,0),4))))) : cn(t,4)=rnd(2)+1 : cn(t,5)=rnd(2)+1 : cn(t,6)=1 : for u=2 to 3 : if TL(cn(t,0),u)>TL(cn(t,0),cn(t,6)) : cn(t,6)=u : endif : next u : next t
else : for t=1 to 2 : PICK=1 : if cn(t,2)>0 : cn(t,1)=(cn(t,2) / (6+(2*int(sqrt(TL(cn(t,0),4))))))+1 : else : cn(t,1)=0 : endif : next t : for t=1 to 2 : if cn(t,0)>1 : if rnd(4)<4 : cn(t,rnd(1)+4)=rnd(2)+1 : endif : endif : next t : endif : IF CN(1,1)>0 AND CN(2,1)>0 : IF SHOW=1 : repeat : until mouseclick()=0 : DO
cls RGB(bc(1),bc(2),bc(3)) : center text 512,60," COMBAT AT "+N$(I)+" " : center text 512,80," ROUND # "+STR$(ROUND)+" " : text 300,120," You have "+str$(CN(c,1))+" Ships " : text 300,140," Player "+str$(cn(e,0))+" has "+str$(CN(e,1))+" Ships " : text 300,160," Give Your Fleet Orders ("+str$(PICK)+") " : for t=1 to 3 : text 200,100+100*t,w$(t,0)+":" : for u=1 to 3 : a$=w$(t,u) : if cn(c,t+3)=u : a$=upper$(" *"+a$+"* ") : endif : text 300,100+100*t+(u-1)*20,a$ : next u : next t : text 400,500," ENGAGE " : if mouseclick()=1 : if mousex()>199 and mousex()<420 : L=(mousey()-100)/100 : V=1+(mousey()-(100+L*100))/20
if L>0 and L<4 : if v>0 and V<4 : cn(c,L+3)=V : Dec PICK : repeat : until mouseclick()=0 : endif : endif : endif : IF mousey()>495 and mousey()<525 : if mousex()>300 and mousex()<500 : EXIT : endif : ENDIF : endif : sync : if PICK<1 : wait 500 : EXIT : endif : loop : ENDIF : for t=1 to 2
d=(int(sqrt(TL(cn(t,0),cn(t,6))))+2)*cn(t,1) : cn(t,3)=(d+rnd(d))*0.55 : next t : for t=1 to 3 : w$(4,t)="" : next t : for t=4 to 6 : if (cn(1,t)=1 and cn(2,t)=2 ) OR (cn(1,t)=2 and cn(2,t)=3 ) OR (cn(1,t)=3 and cn(2,t)=1 ) : DEC cn(2,3),((cn(2,3)/10)+1) : w$(4,t-3)=" Player "+str$(cn(1,0))+" has the advantage in "+w$(t-3)+" " : endif : next t : for t=4 to 6 : if (cn(2,t)=1 and cn(1,t)=2 ) OR (cn(2,t)=2 and cn(1,t)=3 ) OR (cn(2,t)=3 and cn(1,t)=1 ) : DEC cn(1,3),((cn(1,3)/10)+1) : w$(4,t-3)=" Player "+str$(cn(2,0))+" has the advantage in "+w$(t-3)+" " : endif : next t
IF SHOW=0 : dec cn(1,2),cn(2,3) : dec cn(2,2),cn(1,3) : ELSE : repeat : cls RGB(bc(1),bc(2),bc(3)) : center text 512,60," COMBAT AT "+N$(I)+" " : center text 512,80," ROUND # "+STR$(ROUND)+" " : for t=1 to 2 : if cn(t,2)>0 : cn(t,1)=(cn(t,2) / (6+(2*int(sqrt(TL(cn(t,0),4))))))+1 : else : cn(t,1)=0 : endif : next t : for t=1 to 2 : text (t-1)*400+100,100," Player "+str$(cn(t,0)) : text (t-1)*400+100,120," Ships : "+str$(cn(t,1)) : text (t-1)*400+100,140," Hull Points : "+str$(cn(t,2))
for u=1 to 3 : text (t-1)*400+100,160+u*20,w$(u,0)+" : "+w$(u,cn(t,u+3)) : next u : next t : for t=1 to 3 : if w$(4,t)<>"" : text 300,330+t*20,w$(4,t) : endif : next t : text 400,500," CONTINUE " : sync : if cn(1,3)>0 : dec cn(2,2) : dec cn(1,3) : endif : if cn(2,3)>0 : dec cn(1,2) : dec cn(2,3) : endif : until ( cn(2,3)<1 and cn(1,3)<1 ) OR cn(2,2)<0 or cn(1,2)<0 : DO : if mouseclick()
IF mousey()>495 and mousey()<525 : if mousex()>300 and mousex()<500 : EXIT : endif : ENDIF : endif : LOOP : ENDIF : ENDIF : until CN(1,1)=0 or CN(2,1)=0 : FOR T=1 TO 2 : PS(I,6+CN(T,0))=CN(T,1) : NEXT T : endif : endif : next DEF : next OFF : NEXT I : for t=1 to img : inc FL(ps(T,6)),PS(T,2) : next t : FL(0)=0 : YES=0
for t=1 to img : if ps(t,7)>=PS(T,11) : yes=1 : endif : next t : if yes=1 : COL_PHASE=1 : GOSUB INIT_STATE : GOSUB PLAN_VAL_STR : do : GOSUB SCREEN_SUBROUTINE : center text 812,24," COLONIZATION PHASE " : center text 812,64," Right Click Circled Planet To Colonize " : CENTER TEXT 812,84," DONE " : if mouseclick()=2 : T=pick object(mousex(),mousey(),1,img) : if t>0 and t<=img : if ps(t,6)<>1 : if ps(t,7)>=PS(T,11) : dec ps(t,7),PS(T,11) : ps(t,6)=1 : GOSUB PLAN_VAL_STR
endif : endif : endif : endif : if mouseclick()=1 : if mousey()>84 and mousey()<104 : if mousex()>780 and mousex()<844 : EXIT : endif : endif : endif : sync : loop : COL_PHASE=0 : endif : e=0 : FOR I=1 TO IMG : if PS(i,6)>1 : inc e : endif : NEXT I : IF e=0 : repeat
until mouseclick()=0 : CLS RGB(bc(1),bc(2),bc(3)) : set text size 48 : center text 512,200," YOU WIN! " : center text 512,280," YOU BUILT THE SUPREME EMPIRE " : center text 512,328," IN "+STR$(YEAR-Y1)+" YEARS! " : center text 512,400," Click Mouse To Play Again " : center text 512,450," Or Hit Escape Key To Quit " : sync : wait mouse : GOTO CREATE_NEW_GAME_HERE : ENDIF : FOR P=2 TO 3 : CurPlay=P : GOSUB INIT_STATE : for i=1 to img : if ps(i,6)<>P : if ps(i,6+P)>=PS(I,11) : if ps(i,7)<1 AND ( ( p=2 and ps(i,9)<1 ) OR ( p=3 and ps(i,8)<1 ) ) : dec ps(i,6+P),PS(I,11) : if ps(i,6)=1
CLS RGB(bc(1),bc(2),bc(3)) : center text 512,240+rnd(20)," Player "+str$(P)+" Invaded Your Colony At "+n$(i)+" " : sync : wait 2500 : endif : ps(i,6)=P : GOSUB PLAN_VAL_STR : endif : endif : endif : next i : NEXT P : e=0 : FOR I=1 TO IMG : if PS(i,6)=1 : inc e : endif : NEXT I : IF e=0
YOU_LOST_THE_GAME: : repeat : until mouseclick()=0 : CLS RGB(bc(1),bc(2),bc(3)) : set text size 48 : center text 512,200," YOU HAVE BEEN DEFEATED! " : center text 512,400," Click Mouse To Play Again " : center text 512,450," Or Hit Escape Key To Quit " : sync : wait mouse : GOTO CREATE_NEW_GAME_HERE : ENDIF : GOSUB PLAN_VAL_STR : CurPlay=1 : for t=1 to img : if ps(t,7)>0 : inc FL(1),ps(t,7) : ps(t,7)=0 : endif : next t : GOSUB INIT_STATE : GOSUB PLAN_VAL_STR : REPEAT : GOSUB SCREEN_SUBROUTINE
center text 812,24," MOVEMENT PHASE " : center text 812,64," Left Click Planet To Add 1 Ship " : center text 812,84," Right Click To Add 5 " : center text 812,264," "+str$(FL(1))+" Ships Left " : if mouseclick() : T=pick object(mousex(),mousey(),1,img) : if t>0 and t<=img : if object visible(t) : N=1 : if mouseclick()=2 AND fl(1)>4 : N=5 : endif : dec FL(1),n : inc PS(t,7),n : wait 125 : endif : endif : endif : SYNC : UNTIL FL(1)<1 : wait 250 : GOSUB INIT_STATE : GOSUB PLAN_VAL_STR
P=0 : for t=1 to img : if ps(t,6)=1 : inc P,ps(t,3) : endif : next t : REPEAT : GOSUB SCREEN_SUBROUTINE : center text 812,24," RESEARCH PHASE " : center text 812,64," Click To Add Points " : center text 812,84," "+str$(P)+" Points Left " : if mouseclick() : if mousex()>612 and mousex()<750 : y=(mousey()/20)-5 : if y>0 and y<7 : s=(P/25)+1 : dec P,s : Inc TL(1,y),s : wait 125 : endif : endif : endif
for t=1 to 6 : text 612,100+t*20,w$(5,t)+STR$(TL(1,t))+" ("+str$(INT(SQRT(TL(1,t))))+") " : next t : sync : UNTIL P<1 : wait 250 : FOR P=2 TO 3 : alive=0 : for i=1 to img : if ps(i,6)=P : alive=1 : endif : next i : if alive=0 : fl(p)=0 : for i=1 to img : ps(i,6+P)=0 : next i : endif : IF ALIVE=1 : CurPlay=P
GOSUB INIT_STATE : GOSUB PLAN_VAL_STR : for t=1 to img : if ps(t,6+P)>0 : inc FL(P),ps(t,6+P) : ps(t,6+P)=0 : endif : next t : for i=1 to img : for j=0 to 3 : th(i,j)=0 : next j : TH(I,1) = (ps(I,10)*100) / ps(I,11) : if ps(i,6)=0 : TH(I,1)=TH(I,1)*2.2 : endif : if object visible(i) : if FL(P)>=PS(i,11) AND PS(i,6)<>P : th(i,3)=1 : endif : endif : next i : F=FL(P)
fail=0 : while f>0 : TAR=0 : QUO=0 : for i=1 to img : if rnd(2)<2 : if th(i,3)=1 : if f>=ps(i,11) : if ps(i,6+P)<7 : if TH(I,1)>QUO : QUO=TH(I,1) : TAR=I : endif : endif : endif : endif : endif : next i : if tar>0 and quo>0 : ps(TAR,6+p)=ps(TAR,11) : dec f,ps(TAR,11) : x=rnd(f/2) : inc ps(TAR,6+p),x
dec f,x : endif : if fail>25 : repeat : if f>0 : x=rnd(img-1)+1 : if PS(x,6)=P : inc ps(x,6+P) : dec F : endif : endif : until f<1 : endif : INC FAIL : endwhile : FL(p)=0 : RP=0 : for t=1 to img : if ps(t,6)=P : inc RP,ps(t,3) : endif : next t : TRP=RP
nav=1 : vis=0 : for i=1 to img : if object visible(i) : inc vis : if ps(i,6)<>P : nav=0 : endif : endif : next i : if vis>=img OR TL(P,6)>48 : nav=0 : endif : IF NAV=1 : inc TL(P,6),RP : RP=0 : TRP=0 : ELSE : for a=1 to 5 : Z=(RP(P,a)*10*TRP)/100 : inc TL(P,A),Z : dec RP,Z : next a
while RP>0 : a=rnd(4)+1 : inc TL(P,A) : dec RP : endwhile : ENDIF : ENDIF : NEXT P : LOOP : END
SCREEN_SUBROUTINE: : if Display_State=2 : set text size 12 : endif : if Display_State=3 : set text size 14 : endif : for tt=1 to img : IF OBJECT VISIBLE(tT) : yrotate object tt,object angle y(tt)+0.35 : ox=object screen x(tt) : oy=object screen y(tt) : if Display_State=1 : center text ox,oy-18,n$(tt) : if PS(Tt,6)>0 : center text ox,oy," "+str$(PS(Tt,6))+" " : endif : endif : if Display_State=2
center text ox,oy-21," P: "+str$((ps(tt,1)))+" " : center text ox,oy-9," F: "+str$((ps(tt,2)))+" " : center text ox,oy+3," R: "+str$((ps(tt,3)))+" " : center text ox,oy+15," S: "+str$( ps(tt,11) )+" " : endif : if Display_State=3 : center text ox,oy-18," 1: "+str$((PS(tt,7)))+" " : center text ox,oy-6," 2: "+str$((PS(tt,8)))+" " : center text ox,oy+6," 3: "+str$((PS(tt,9)))+" " : endif : if COL_PHASE=1 : if ps(tt,6)<>1 : if ps(tt,7)>=ps(tt,11) : IF ps(tt,8)<1 and ps(tt,9)<1 : circle ox,oy,26 : circle ox,oy,27 : circle ox,oy,28 : ENDIF : endif : endif
endif : ENDIF : next tt : set text size 16 : if mouseclick()=1 : mx=mousex() : my=mousey() : IF MY>740 : IF MX>712 AND MX<912 : GOTO YOU_LOST_THE_GAME : ENDIF :ENDIF : if my>604 and my<620 : Display_State=0 : if mx>165 and mx<235 : Display_State=1 : endif : if mx>265 and mx<335 : Display_State=2 : endif : if mx>365 and mx<435 : Display_State=3
endif : endif : endif : ink RGB(bc(1),bc(2),bc(3)),0 : box 0,600,1024,768 : box 600,0,1024,768 : ink RGB(0,128,192),rgb(BC(4),BC(5),BC(6)) : line 0,0,1024,0 : line 0,0,0,768 : line 600,0,600,600 : line 0,600,601,600 : line 0,767,1024,767 : line 1023,0,1023,767 : center text 200,604," OWNER " : center text 300,604," STATS " : center text 400,604," FLEET " : CENTER TEXT 812,740," * SURRENDER * " : for tt=1 to 3 : text (tt-1)*150+112,650,w$(tt,4) : text 44,650+tt*20," "+str$(tt)+" "
next tt : for tt=1 to 3 : for uu=0 to 6 : tl(0,uu)=0 : next uu : for ii=1 to img : if PS(ii,6)=tt : for uu=1 to 3 : inc tl(0,uu),ps(ii,uu) : next uu : endif : next ii : for uu=1 to 3 : text (uu-1)*150+112,650+tt*20,str$(tl(0,uu)) : next uu : next tt : center text 812,44," Year : "+str$(year)+" " : RETURN
PLAN_VAL_STR: : FOR T=1 TO IMG : PS(T,10)=(ps(t,2)+ps(t,3)) : PS(T,11)=ps(t,1)+PS(T,10)+((ps(t,6)>0)*int(SQRT(TL(ps(t,6),5)))) : NEXT T : RETURN
INIT_STATE: : range=( 6+ (SQRT(TL(CurPlay,6))*3) ) : for t=1 to img : hide object t : next t : for t=1 to img : if ps(t,6)=CurPlay : show object t : for u=1 to img : if (abs(ps(u,4)-ps(t,4))+abs(ps(u,5)-ps(t,5)))<range : show object u : endif : next u : endif : next t : RETURN
data "STRATEGY","Fighter Attack","Battleship Firepower","Destroyer Maneuver","POPULATION","FORMATION","Hexagon","Wing","Zig-Zag","SHIPYARDS","WEAPON","Beams","Missiles","Mines","RESEARCH"," BEAMS: "," MISSILES: "," MINES: "," DEFENSE: "," TROOPS: "," NAVIGATION: "
DATA "Inora","Ixat","Sicogu","Iraga","Tethia","Zelopol","Chigor","Alsapha","Ataxon","Inzaras","Ulsulus","Venuxi","Lyapht","Dmuren","Inx","Sirces","Icogol","Darisul","Vugi","Zentili","Kotolro","Ioturon","Kadic","Jogoth"
DATA "Epran","Heraph","Mesga","Orazar","Sirukur","Pryus","Duoni","Kasoria","Tunephi","Etacion","Usomi","Eadi","Darsag","Ulicon","Clyus","Oxus","Rulko","Hayx","Oszri","Azarosa","Betu","Mirnath","Kimuri","Denigal"
DATA "Ondisa","Quordas","Usbeda","Uphrama","Hados","Orunath","Iliau","Joruk","Wrackur","Psani","Corigar","Rhefac","Silsha","Rafiad","Kemiron","Maryda","Izreus","Cibra","Argen","Nirodu","Astaka","Bhezar","Inconis","Delomec"
DATA "Idaros","Chromad","Misurud","Cornath","Vhudia","Jalyria","Onpha","Chiphan","Talux","Rasoron","Forani","Animir","Sildar","Koryl","Uronze","Mindara","Imiosc","Dargi","Daceron","Irasa","Cliurna","Iskande","Heralis"
DATA "Ebudri","Enicon","Uprogol","Eprusil","Tanir","Vagen","Prinath","Entaghi","Mizraga","Gisima","Irami","Ineax","Ontau","Regiden","Yirigi","Mayisa","Alera","Targesa","Masilus","Osreba","Tazuron","Detha","Tazaros","Rosmir"
DATA "Sirnami","Turnema","Askendi","Altoven","Ormiga","Mirius","Magmada","Necersi","Onumen","Ymbecri","Forturi","Scheda","Shiri","Cigen","Agemna","Rukani","Idmar","Cequum","Gaezann","Yenchak","Nepanus","Aethia"
Main Screen: