[Add] Earth Starports [London, Los Angeles, Moscow and more. ]

[Add] Intro screen.
This commit is contained in:
Rtch90 2018-01-23 21:31:52 +00:00
parent 0b648b4a9a
commit a0d7eb207a
14 changed files with 168 additions and 60 deletions

BIN
screenshot/aabb.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 304 KiB

BIN
screenshot/barnardc.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 426 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 302 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 308 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 348 KiB

BIN
screenshot/lmenu2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 320 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 346 KiB

View File

@ -23,6 +23,36 @@ const CustomSBody sol_system[] = {
0, fixed(1,1), fixed(1,1), 288,
fixed(1,1), fixed(167,10000), 0, fixed(1,1)
},
{
"Mexico City", StarSystem::TYPE_STARPORT_SURFACE,
3, 0, 0, 0, 0, 0, DEG2RAD(19)
},
{
"Shanghai", StarSystem::TYPE_STARPORT_SURFACE,
3, 0, 0, 0, 0, 0, DEG2RAD(31)
},
{
"London", StarSystem::TYPE_STARPORT_SURFACE,
3, 0, 0, 0, 0, 0, DEG2RAD(51)
},
{
"Moscow", StarSystem::TYPE_STARPORT_SURFACE,
3, 0, 0, 0, 0, 0, DEG2RAD(55)
},
{
"Brasilia", StarSystem::TYPE_STARPORT_SURFACE,
3, 0, 0, 0, 0, 0, DEG2RAD(-15.5)
},
{
"Los Angeles", StarSystem::TYPE_STARPORT_SURFACE,
3, 0, 0, 0, 0, 0, DEG2RAD(34)
},
{
"Moon", StarSystem::TYPE_PLANET_DWARF,
@ -62,13 +92,13 @@ const CustomSBody sol_system[] = {
/* Moons of jupiter. */
{
"Io", StarSystem::TYPE_PLANET_HIGHLY_VOLCANIC,
6, fixed(286,1000), fixed(15,1000), 130,
12, fixed(286,1000), fixed(15,1000), 130,
fixed(282,100000), fixed(41,10000), DEG2RAD(2.21), fixed(177, 100)
},
{
"Europa", StarSystem::TYPE_PLANET_WATER,
6, fixed(245,1000), fixed(8,1000), 102,
12, fixed(245,1000), fixed(8,1000), 102,
fixed(441,100000), fixed(9,1000), 0.0, fixed(355, 100)
},
{ 0 }

View File

@ -40,6 +40,7 @@ class Frame;
class L3D {
public:
static void Init(IniConfig& config);
static void Start(void);
static void MainLoop(void);
static void Quit(void);
static float GetFrameTime(void) { return frameTime; }

View File

@ -106,6 +106,8 @@ void L3D::Init(IniConfig& config) {
dInitODE();
GLFTInit();
Space::Init();
Gui::Init(scrWidth, scrHeight, 800, 600);
}
void L3D::InitOpenGL() {
@ -212,60 +214,46 @@ void L3D::HandleEvents(void) {
}
}
void L3D::MainLoop(void) {
static void draw_intro(float _time) {
static float lightCol[4] = { 1, 1, 1, 0 };
static float lightDir[4] = { 0, 1, 0, 0 };
static ObjParams params = {
{ 0.5, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0.0f, 0.0f, 0.1f}, { 0.0f, 0.0f, 0.0f },
/* pColor[3] */
{
{ { 1.0f, 1.0f, 1.0f }, { 0, 0, 0 }, { 0, 0, 0 }, 0 },
{ { 0.8f, 0.6f, 0.5f }, { 0, 0, 0 }, { 0, 0, 0 }, 0 },
{ { 0.5f, 0.5f, 0.5f }, { 0, 0, 0 }, { 0, 0, 0 }, 0 },
},
{ "LEPHISTO" },
};
glRotatef(_time*10, 1, 0, 0);
L3D::worldView->DrawBgStars();
glPushAttrib(GL_ALL_ATTRIB_BITS);
sbreSetViewport(L3D::GetScrWidth(), L3D::GetScrHeight(), L3D::GetScrWidth()*0.5, 1.0f, 1000.0f, 0.0f, 1.0f);
sbreSetDirLight(lightCol, lightDir);
matrix4x4d rot = matrix4x4d::RotateYMatrix(_time) * matrix4x4d::RotateZMatrix(0.6*_time) *
matrix4x4d::RotateXMatrix(_time*.7);
Matrix m;
Vector p;
m.x1 = rot[0]; m.x2 = rot[4]; m.x3 = rot[ 8];
m.y1 = rot[1]; m.y2 = rot[5]; m.y3 = rot[ 9];
m.z1 = rot[2]; m.z2 = rot[6]; m.z3 = rot[10];
p.x = 0; p.y = 0; p.z = 80;
sbreRenderModel(&p, &m, 61, &params);
glPopAttrib();
}
void L3D::Start(void) {
player = new Player(ShipType::SLEEK);
player->SetLabel("Me");
Space::AddBody(player);
StarSystem s(0, 0, 1);
HyperspaceTo(&s);
const float zpos = EARTH_RADIUS * 3;
//Frame* pframe = *(++(++(Space::rootFrame->m_children.begin())));
Frame* pframe = *(Space::rootFrame->m_children.begin());
#if 0
Frame* stationFrame = new Frame(pframe, "Station frame..");
stationFrame->SetRadius(5000);
stationFrame->m_sbody = 0;
stationFrame->SetPosition(vector3d(0, 0, zpos));
stationFrame->SetAngVelocity(vector3d(0,0,0.5));
for(int i = 0; i < 4; i++) {
Ship* body = new Ship(ShipType::SLEEK/*LADYBIRD*/);
char buf[64];
snprintf(buf, sizeof(buf), "X%c-0%02d", "A"+i, i);
body->SetLabel(buf);
body->SetFrame(stationFrame);
body->SetPosition(vector3d(200*(i+1), 0, 2000));
Space::AddBody(body);
}
SpaceStation* station = new SpaceStation(SpaceStation::JJHOOP);
station->SetLabel("Poemi-chan's Folly");
station->SetFrame(stationFrame);
station->SetPosition(vector3d(0,0,0));
Space::AddBody(station);
SpaceStation* station2 = new SpaceStation(SpaceStation::GROUND_FLAVOURED);
station2->SetLabel("Dfighter's point");
station2->SetFrame(*pframe->m_children.begin()); /* Rotating frame of planet. */
station2->OrientOnSurface(EARTH_RADIUS, M_PI/4, M_PI/4);
Space::AddBody(station2);
#endif
player->SetFrame(pframe);
//player->SetPosition(vector3d(0,0,0));
//player->OrientOnSurface(EARTH_RADIUS*1.001, M_PI/4, M_PI/4);
//player->OrientOnSurface(EARTH_RADIUS*1.001, M_PI/4, M_PI/4);
player->SetPosition(vector3d(0, 0, EARTH_RADIUS));
//player->SetPosition(vector3d(0,0,2000));
//player->SetFrame(pframe);
Gui::Init(scrWidth, scrHeight, 800, 600);
cpan = new ShipCpanel();
cpan->ShowAll();
sectorView = new SectorView();
systemView = new SystemView();
@ -275,8 +263,83 @@ void L3D::MainLoop(void) {
spaceStationView = new SpaceStationView();
infoView = new InfoView();
Gui::Fixed* splash = new Gui::Fixed(Gui::Screen::GetWidth(), Gui::Screen::GetHeight());
Gui::Screen::AddBaseWidget(splash, 0, 0);
splash->SetTransparency(true);
const float w = Gui::Screen::GetWidth() / 2;
const float h = Gui::Screen::GetHeight() / 2;
const int OPTS = 3;
Gui::ToggleButton* opts[OPTS];
opts[0] = new Gui::ToggleButton(); opts[0]->SetShortcut(SDLK_1, KMOD_NONE);
opts[1] = new Gui::ToggleButton(); opts[1]->SetShortcut(SDLK_2, KMOD_NONE);
opts[2] = new Gui::ToggleButton(); opts[2]->SetShortcut(SDLK_3, KMOD_NONE);
splash->Add(opts[0], w, h+64);
splash->Add(new Gui::Label("New game starting on Earth"), w+32, h+64);
splash->Add(opts[1], w, h+32);
splash->Add(new Gui::Label("New game starting on debug point"), w+32, h+32);
splash->Add(opts[2], w, h);
splash->Add(new Gui::Label("Quit"), w+32, h);
splash->ShowAll();
int choice = 0;
Uint32 last_time = SDL_GetTicks();
float _time = 0;
do {
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glClearColor(0,0,0,0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
L3D::HandleEvents();
SDL_ShowCursor(1);
SDL_WM_GrabInput(SDL_GRAB_OFF);
draw_intro(_time);
Gui::Draw();
glFlush();
SDL_GL_SwapBuffers();
L3D::frameTime = 0.001*(SDL_GetTicks() - last_time);
_time += L3D::frameTime;
last_time = SDL_GetTicks();
/* Poll ui instead of using callbacks. :D */
for(int i = 0; i < OPTS; i++) if(opts[i]->GetPressed()) choice = i+1;
} while(!choice);
splash->HideAll();
if(choice == 1) {
/* Earth start point. */
StarSystem s(0,0,0);
HyperspaceTo(&s);
//Frame* pframe = *(++(++(Space::rootFrame->m_children.begin())));
//player->SetFrame(pframe);
/* TODO: There isn't a sensible way to find stations for a planet. */
SpaceStation* station = 0;
for(Space::bodiesIter_t i = Space::bodies.begin(); i!=Space::bodies.end(); i++) {
if((*i)->GetType() == Object::SPACESTATION) { station = (SpaceStation*)*i; break; }
}
assert(station);
player->SetFrame(station->GetFrame());
player->SetDockedWith(station, 0);
MainLoop();
} else if(choice == 2) {
/* Debug start point. */
StarSystem s(0,0,1);
HyperspaceTo(&s);
Frame* pframe = *(Space::rootFrame->m_children.begin());
player->SetFrame(pframe);
player->SetPosition(vector3d(0,0,EARTH_RADIUS));
MainLoop();
}
}
void L3D::MainLoop(void) {
cpan->ShowAll();
SetView(worldView);
//player->SetDockedWith(station2, 0);
Uint32 last_stats = SDL_GetTicks();
int frame_stat = 0;
@ -409,7 +472,8 @@ int main(int argc, char** argv) {
IniConfig cfg("config.ini");
L3D::Init(cfg);
L3D::MainLoop();
L3D::Start();
L3D::Quit();
return 0;
}

View File

@ -630,6 +630,7 @@ void StarSystem::MakePlanetsAround(SBody* primary) {
SBody* planet = new SBody;
planet->type = TYPE_PLANET_DWARF;
planet->seed = rand.Int32();
planet->humanActivity = m_humanInfested * rand.Fixed();
planet->tmp = 0;
planet->parent = primary;
//planet->radius = EARTH_RADIUS*bodyTypeInfo[type].radius;
@ -769,6 +770,7 @@ void StarSystem::SBody::PickPlanetType(StarSystem* system, SBody* star, const fi
moon->parent = this;
//moon->radius = EARTH_RADIUS*bodyTypeInfo[type].radius;
moon->rotationPeriod = fixed(rand.Int32(1,200), 24);
moon->humanActivity = system->m_humanInfested * rand.Fixed();
moon->mass = mass;
fixed ecc = rand.NFixed(3);
@ -800,7 +802,7 @@ void StarSystem::SBody::PickPlanetType(StarSystem* system, SBody* star, const fi
}
/* Starports - orbital. */
if((genMoons) && (averageTemp < CELSIUS+100) && (averageTemp > 100) &&
(rand.Fixed() < system->m_humanInfested)) {
(rand.Fixed() < humanActivity)) {
SBody* sp = new SBody;
sp->type = TYPE_STARPORT_ORBITAL;
sp->seed = rand.Int32();
@ -810,6 +812,7 @@ void StarSystem::SBody::PickPlanetType(StarSystem* system, SBody* star, const fi
sp->averageTemp = this->averageTemp;
sp->mass = 0;
sp->name = "Starport";
sp->humanActivity = humanActivity;
fixed semiMajorAxis;
if(children.size()) {
semiMajorAxis = fixed(1,2) * children[0]->orbMin;
@ -824,7 +827,7 @@ void StarSystem::SBody::PickPlanetType(StarSystem* system, SBody* star, const fi
sp->orbMin = semiMajorAxis;
sp->orbMax = semiMajorAxis;
if(rand.Fixed() < system->m_humanInfested) {
if(rand.Fixed() < humanActivity) {
SBody* sp2 = new SBody;
*sp2 = *sp;
sp2->orbit.rotMatrix = matrix4x4d::RotateZMatrix(M_PI);
@ -840,14 +843,18 @@ void StarSystem::SBody::PickPlanetType(StarSystem* system, SBody* star, const fi
(type == TYPE_PLANET_METHANE) ||
(type == TYPE_PLANET_INDIGENOUS_LIFE)) {
fixed activ = humanActivity;
if(type == TYPE_PLANET_INDIGENOUS_LIFE) humanActivity *= 2;
int max = 6;
while((max-- > 0) && (rand.Fixed() < system->m_humanInfested)) {
while((max-- > 0) && (rand.Fixed() < activ)) {
SBody* sp = new SBody;
sp->type = TYPE_STARPORT_SURFACE;
sp->seed = rand.Int32();
sp->tmp = 0;
sp->parent = this;
sp->averageTemp = this->averageTemp;
sp->humanActivity = activ;
sp->mass = 0;
sp->name = "Starport";
/* Used for orientation on planet surface. */

View File

@ -121,6 +121,7 @@ public:
fixed mass; /* Earth masses if planet, solar masses if star. */
fixed orbMin, orbMax; /* Periapsism, Apoapsis in AUs. */
fixed rotationPeriod; /* In days. */
fixed humanActivity; /* 0 - 1 */
int averageTemp;
BodySuperType supertype;

View File

@ -53,20 +53,20 @@ WorldView::WorldView(void): View() {
glNewList(m_bgstarsDlist, GL_COMPILE);
glPushAttrib(GL_ENABLE_BIT);
glDisable(GL_LIGHTING);
glDisable(GL_DEPTH_TEST);
glPointSize(1.0);
glBegin(GL_POINTS);
for(int i = 0; i < BG_STAR_MAX; i++) {
float col = 0.05+L3D::rng.NDouble(4);
float col = 0.05+L3D::rng.NDouble(3);
col = CLAMP(col, 0, 1);
glColor3f(col, col, col);
glVertex3f(1000-L3D::rng.Double(2000.0), 1000-L3D::rng.Double(2000.0), 1000-L3D::rng.Double(2000.0));
}
glEnd();
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glPopAttrib();
glEndList();
}
@ -93,6 +93,10 @@ void WorldView::OnClickHyperspace(void) {
}
}
void WorldView::DrawBgStars(void) {
glCallList(m_bgstarsDlist);
}
void WorldView::Draw3D(void) {
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
@ -133,7 +137,7 @@ void WorldView::Draw3D(void) {
trans2bg.ClearToRotOnly();
glPushMatrix();
glMultMatrixd(&trans2bg[0]);
glCallList(m_bgstarsDlist);
DrawBgStars();
glPopMatrix();
/* Position light at sol. */
matrix4x4d m;

View File

@ -13,6 +13,7 @@ public:
static const float PICK_OBJECT_RECT_SIZE;
void UpdateCommsOptions(void);
bool GetShowLabels(void) { return labelsOn; }
void DrawBgStars(void);
private:
Gui::Button* AddCommsOption(const std::string msg, int ypos);
void OnClickHyperspace(void);