I just started this version (a rewrite), and my old code was much longer:
remstart
| . . . . . . .. . |
| . . . .. . . . . . |
| . . . .. . . Star Fleet . . . |
| . . . . Dark Game Studios .. |
|___________________________________________________________________|
remend
`Project by Dark Games
`Started: August 14, 2005 9:15pm
`Setup
`Our standard font will be right here:D
SET TEXT FONT "Arial Bold"
sync on : sync rate 45
` when I new object is created, we dont want to go to that object:)
autocam off
` Menu, Menu on the wall, stop this escape key from going a-wal.
DISABLE ESCAPEKEY
Global MouseOverEndTurn as boolean = 0
`types are below
`below is sitrep report:) By IBOL. Thanks.
TYPE REPORTS
A AS STRING
B AS STRING
Q
Pic
ENDTYPE
type txt_t
x as integer
y as integer
endtype
type starsystem
name as string
empire as string
warplimit as integer
warps as integer
endtype
type event_handler
event as string
picture as integer
endtype
type event
empire as string
eventid as integer
location as string
endtype
type starnamelist
name as string
taken as string
endtype
type line1
x as integer
y as integer
endtype
type line2
x as integer
y as integer
t as integer
endtype
dim line1(50) as line1
dim line2(50) as line2
dim events(200) as event_handler
events(1).event="End of Game"
events(1).picture=9101
dim starsystem(50) as starsystem
dim starnames(500) as starnamelist
open to read 3,"Data/Steller/stars.txt"
while file end(3) = 0
inc r, 1
read string 3, starnames(r).name
endwhile
close file 3
dim txt(50) as txt_t
`set globals
`Start Turn is 0. Boo
turn = 0
`YEAR.
year = 2840
`year that ends the game
end_year = 7050
`races
race$ = "0"
`DIMS
dim r(NUMPLAY,200) as REPORTS
` Q will store the STAR NUMBER for any "goto star of report" function, and Pic will associate a picture.
` NumPlay is the number of players in the game. 200 is an arbitrary limit on the number of reports you can get in 1 turn
`Tie ins
` load the loading image
load image "Images/Misc/Loading.jpg",600,1
`load my 1337 toon
load music "Music/Main_Intro.wav",1
` loops the music. I might make a random track thing later
loop music 1
` plays a retro version of main tune
load music "Music/Main_Amp.wav",2
`RACE FLAGS
`Nyss Flag
load image "Images/Races/Nys/Portrait/Flag.jpg",90000,1
`Human Flag
load image "Images/Races/Humans/Portrait/Flag.jpg",90003,1
`Other
`menu Item 1
load image "Images/Misc/a_End.jpg",2095,1
`Mwnu Item 2
load image "Images/Misc/p_End.jpg",2096,1
`load the gui left bar
load image "Images/Misc/gui.png",2837,1
`Star Backdrop
load image "Images/Steller/stars.jpg",2,1
load image "Images/Misc/menu.jpg", 2191, 1
load image "Images/Steller/Planets/Water/1.jpg", 9101, 1
load image "Images/Misc/mainm.png",7895,1
version$ = "Beta 0.1"
played$ = "Yes"
if file exist("config.cfg") then delete file "config.cfg"
open to write 1,"config.cfg"
write string 1,version$
write string 1,played$
close file 1
` goto the magical menu
goto menu
menu:
cls
a=1
na=1
open to read 2, "config.cfg"
read string 2,version$
read string 2,played$
read string 2,created$
close file 2
do
paste image 7895,0,0
ink rgb(500,500,500),0
if mousex()>=380 and mousex()<=450 and mousey()>=275 and mousey()<=275+text height("New Game")
ink rgb(55,9,462),1
endif
text 380,275,"New Game"
if mousex()>=380 and mousex()<=450 and mousey()>=275 and mousey()<=275+text height("New Game")
ink rgb(55,9,462),1
if mouseclick()=1
goto game
endif
else
ink rgb(55,9,462),1
endif
ink rgb(500,500,500),0
if mousex()>=525 and mousex()<=575 and mousey()>=275 and mousey()<=275+text height("Options")
ink rgb(55,9,462),1
endif
text 525,275,"Options"
if mousex()>=525 and mousex()<=575 and mousey()>=275 and mousey()<=275+text height("Options")
ink rgb(55,9,462),1
if mouseclick()=1
gosub options
endif
else
endif
ink rgb(500,500,500),0
if mousex()>=650 and mousex()<=675 and mousey()>=275 and mousey()<=275+text height("Quit")
ink rgb(55,9,462),1
endif
text 650,275,"Quit"
if mousex()>=650 and mousex()<=675 and mousey()>=275 and mousey()<=275+text height("Quit")
ink rgb(55,9,462),1
if mouseclick()=1
end
endif
else
ink rgb(55,9,462),1
endif
ink rgb(255,255,255),0
text 0,590,"Version: "+version$
sync
loop
options:
cls
paste image 7895,0,0
do
ink rgb(500,500,500),0
if mousex()>=380 and mousex()<=450 and mousey()>=275 and mousey()<=275+text height("New Game")
ink rgb(55,9,462),1
endif
text 380,275,"Graphics"
if mousex()>=380 and mousex()<=450 and mousey()>=275 and mousey()<=275+text height("New Game")
ink rgb(55,9,462),1
if mouseclick()=1
goto game
endif
else
ink rgb(55,9,462),1
endif
ink rgb(500,500,500),0
if mousex()>=525 and mousex()<=575 and mousey()>=275 and mousey()<=275+text height("Options")
ink rgb(55,9,462),1
endif
text 525,275,"Sound"
if mousex()>=525 and mousex()<=575 and mousey()>=275 and mousey()<=275+text height("Options")
ink rgb(55,9,462),1
if mouseclick()=1
gosub options
endif
else
endif
ink rgb(500,500,500),0
if mousex()>=650 and mousex()<=675 and mousey()>=275 and mousey()<=275+text height("Quit")
ink rgb(55,9,462),1
endif
text 650,275,"Return"
if mousex()>=650 and mousex()<=675 and mousey()>=275 and mousey()<=275+text height("Quit")
ink rgb(55,9,462),1
if mouseclick()=1
gosub menu
endif
else
ink rgb(55,9,462),1
endif
sync
loop
game:
ink rgb(500,500,500),0
` clear the screen of crummyness
cls
` paste the loading image
paste image 600,0,0
sync
` stops the music during load
stop music 1
` play the retro music
play music 2
` wait for the image to say "loading"
wait 4000
` delete the loading image
`delete image 600
` stops the loading music
stop music 2
` loops the music. I might make a random track thing later
loop music 1
` load the mighty terran battleship
if object exist(1) = 0
load object "Models/Ships/Terran/Battleship/Battleship.x",1
endif
` make the battleship longer a bit
scale object 1, 10,7.5,7.5
` load the standard Terran Ship Hull Image
if image exist(999) = 0
load image "Models/Ships/Terran/Battleship/Hull007.jpg",999,1
endif
` texture the object using the Hull Image(Will create a better image later)
texture object 1,999
` make the backdrop appear
backdrop on
` color it black
color backdrop 0
`Make the Stars
if matrix exist(2) = 0
make matrix 2,1000,1000,50,50
endif
`Make the grid in the right position
position matrix 2,-300,-30,-400
`Make the camera 3d Positioned
position camera 200,527,250
`Rotate the camera so the map is viewable
rotate camera 90,180,0
`Stars STARSSSS
PREPARE MATRIX TEXTURE 2, 2, 1, 1
Local X as Integer
Local Y as Integer
Local Distance as Float
do
X = MouseX()
Y = MouseY()
Distance = sqrt((abs(X - 65)*abs(65 - X))+(abs(Y - 533)*abs(533 - Y)))
If Distance < 49
`what is the click motion
if mouseclick()=1 AND year <= end_year AND Turn_end = 0
`turn equals the turn + one
turn = turn + 1
`Year is another year
year = year + 1
`the turn is ended!!!
Turn_end = 1
`go sub to the sitrep place
gosub sitrep
endif
else
endif
` End turn Thingy.
`Make the Timer go up
IF Turn_end=1 THEN INC Time,1
`Make it reload..doesnt work some reasonL:(
IF Time=1 THEN Time=0:Reload=0:Turn_end=0
for tempvalue=2 TO 50 Step 1
if object exist(50) = 0
make object sphere tempvalue,5
endif
starposition1# = rnd(400)
starposition2# = rnd(400)
if object exist(50) = 0
position object tempvalue,starposition1#,rnd(0),starposition2#
SET OBJECT COLLISION TO SPHERES tempvalue
color object tempvalue,rgb(rnd(500),rnd(500),rnd(500))
starnumber = rnd(r)
if starnames(starnumber).taken = ""
starsystem(tempvalue).name = starnames(starnumber).name
starnames(starnumber).taken = "yes"
starsystem(tempvalue).empire = "NONE"
starsystem(tempvalue).warplimit = 1
endif
endif
if object exist(50) = 1
for j=2 to 50
if tempvalue <> j
`checks squared distance (24*24)
if between(tempvalue,j) <= 576
starposition1# = rnd(200)
starposition2# = rnd(200)
position object tempvalue,starposition1#,rnd(0),starposition2#
endif
endif
next j
endif
if starsystem(tempvalue).name = ""
starnumber = rnd(r)
starsystem(tempvalue).name = starnames(starnumber).name
endif
txt(tempvalue).x=OBJECT SCREEN X(tempvalue)
txt(tempvalue).y=OBJECT SCREEN Y(tempvalue)+1
Next tempvalue
for p=2 to 50
lineset = 0
if lineset = 0
number = rnd(50)
if number = 0
number = number + 2
endif
if number = 1
number = 2
endif
if number = p
number = p-1
endif
if line2(p).t=0
line2(p).t=number
endif
lineset = 1
endif
if starsystem(p).warplimit >= starsystem(p).warps OR starsystem(line2(p).t).warplimit >= starsystem(line2(p).t).warps
if lineset = 0
number = rnd(50)
if number = 0
number = number + 2
endif
if number = 1
number = 2
endif
if number = p
number = p-1
endif
if line2(p).t=0
line2(p).t=number
endif
lineset = 1
endif
endif
line1(p).x=OBJECT SCREEN X(p)
line1(p).y=OBJECT SCREEN Y(p)
starsystem(p).warps = starsystem(p).warps + 1
line2(p).x=OBJECT SCREEN X(line2(p).t)
line2(p).y=OBJECT SCREEN Y(line2(p).t)
starsystem(line2(p).t).warps = starsystem(line2(p).t).warps + 1
next p
for i= 2 to 50
ink rgb(500,0,0),0
line line1(i).x,line1(i).y,line2(i).x,line2(i).y
next i
for q = 2 to 50
ink rgb(500,500,500),0
set text size 14
text txt(q).x,txt(q).y, starsystem(q).name
next q
set text size 12
paste image 2837,0,0,1
ink rgb(500,500,500),0
if turn# = 0
`Make you NYSS
if inkey$()="1"
race=2
imagerace=90000
endif
`Make you HUMAN
if inkey$()="2"
race=1
imagerace=90003
endif
endif
`Print and paste the race info
Set Cursor 550,0
if race = 1 Or race = 2
paste image imagerace,17,20
endif
` Race 2 is The Nys. I will make a race image thing, but this is the main race:).
if race=2
racename$ = "Nyss"
text 47,25,"Nyss"
endif
` Humans. Love em. Hate em. Cool.
if race=1
racename$ = "Humans"
text 47,25,"Humans"
endif
`Camera movement
`Down
if inkey$()="=" and camera position y()>=21
move camera 1
endif
`Up
if inkey$()="-"
move camera -1
endif
`print the year
set cursor 215,515
print year
set cursor 250,515
print Camera Position Y()
`print the turn
set cursor 175,515
print turn
`print the fps
set cursor 195,515
print screen fps()
menu_ingame()
sync
`end teh loop
loop
sitrep:
A$=" Our Forces enounctered the Alzuran Rebels, and We won with 25% damage to our ships."
B$ = "Very Shocking to our "+racename$
do
SET CURSOR 50,0
print year#
SET CURSOR 150,0
print turn#
print_Report(2,A$,B$,9101,0,34)
ink rgb(128,182,225),0
if mousex()>=180 and mousex()<=250 and mousey()>=275 and mousey()<=275+text height("Go Back")
ink rgb(500,500,500),1
endif
text 180,275,"Go Back"
if mousex()>=180 and mousex()<=250 and mousey()>=275 and mousey()<=275+text height("Go Back")
ink rgb(500,500,500),1
if mouseclick()=1
return
endif
else
ink rgb(500,500,500),1
endif
menu_ingame()
sync
loop
Function menu_ingame()
`Pause? Duuuh.
if escapekey() = 1
`DO TEH LOOPY
do
paste image 2191,0,0
ink rgb(128,182,225),0
if mousex()>=180 and mousex()<=250 and mousey()>=275 and mousey()<=275+text height("Quit")
ink rgb(500,500,500),1
endif
text 180,275,"Quit"
if mousex()>=180 and mousex()<=250 and mousey()>=275 and mousey()<=275+text height("Quit")
ink rgb(500,500,500),1
if mouseclick()=1
end
endif
else
ink rgb(500,500,500),1
endif
ink rgb(128,182,225),0
if mousex()>=325 and mousex()<=375 and mousey()>=275 and mousey()<=275+text height("Continue")
ink rgb(500,500,500),1
endif
text 325,275,"Continue"
if mousex()>=325 and mousex()<=375 and mousey()>=275 and mousey()<=275+text height("Continue")
ink rgb(500,500,500),1
if mouseclick()=1
exit
endif
else
ink rgb(500,500,500),1
endif
ink rgb(128,182,225),0
if mousex()>=450 and mousex()<=475 and mousey()>=275 and mousey()<=275+text height("Menu")
ink rgb(500,500,500),1
endif
text 450,275,"Menu"
if mousex()>=450 and mousex()<=475 and mousey()>=275 and mousey()<=275+text height("Menu")
ink rgb(500,500,500),1
if mouseclick()=1
goto menu
endif
else
ink rgb(500,500,500),1
endif
sync
`end
loop
endif
endfunction
Function print_Report(p,a$,b$,Pic,X,Y)
print "In the star of "+starsystem(p).name+ a$
print "The result was "+b$
paste image Pic,X,Y
EndFunction
` end sitrep
function between(a as integer, b as integer)
x = object position x(a) - object position x(b)
y = object position y(a) - object position y(b)
z = object position z(a) - object position z(b)
d = x*x + y*y + z*z
endfunction d
I have just been away from darkbasic pro for a long time..
edit: Thanks for the help TDK, after 10 minutes the code is looking nicer, and I have gotten rid of the goto command...completely.
Evil Mods keep erasing my below 600x120 sig...