[Add] Added introductory text.
This commit is contained in:
parent
3b3450213a
commit
e9276b5704
@ -83,7 +83,7 @@ DATA_GFX := $(wildcard ../gfx/*.png \
|
||||
../gfx/planet/space/*.png \
|
||||
../gfx/ship/*.png \
|
||||
../gfx/spfx/*.png)
|
||||
DATA_XML := $(wildcard ../dat/*.xml ../dat/*.ttf)
|
||||
DATA_XML := $(wildcard ../dat/*.xml ../dat/*.ttf ../dat/intro)
|
||||
DATA_SND := $(wildcard ../snd/music/*.ogg \
|
||||
../snd/sounds/*.wav) ../snd/music.lua
|
||||
DATA_MISN := $(wildcard ../dat/missions/*.lua)
|
||||
|
24
dat/intro
Normal file
24
dat/intro
Normal file
@ -0,0 +1,24 @@
|
||||
Humans had always looked up at the skies at night, dreaming of being one with the stars. Yet they never imagined what their dreams had in them.
|
||||
|
||||
They ended up getting into space and the revolution that this provoked. With the advent of terraforming technologies, colonists began flocking to the stars en masse. Many worlds where colonized and humanity expanded.
|
||||
It was still slow travelling and time was starting to erode humanity's unity.
|
||||
|
||||
Then.. Came the great advance in travel. Light speeds where finally broken. This technology spread quickly and reignited the colonization spree. Humans had conquered a great part of the galaxy. Things where hectic though, with mankind fragmented in many factions. A federation was created to attempt to affront this.
|
||||
|
||||
Yet, this only incremented tension. Man was too fractured to be weaved together with diplomacy. War broke out, timidly at first, but quickly gathering momentum. Thus began the Great Faction War!
|
||||
|
||||
Being the first space-era all out global war, the Faction War brought much pain and misery to humanity. Many plants where annihilated, trillions killed, all in the name of each faction. Mankind started becoming tribal and isolated, seperated by vast space filled with the debris of battleships and smoldering planets. Then came hope at the hand of the Emperor Daedris.
|
||||
|
||||
A newly forged Empire began sweeping the factions, dominating with clear military superioriy. Some factions resisted at first, but most saw the only way was to sumbit to the iron fist of the Emperor. Eventually there was only the Empire. Those who helped in the birth of this Empire where given the status of Great House, and the golden age began.
|
||||
|
||||
Trade routes where created, patrols where installed and piracy was non-existant. Supplies where being moved all around the Empire and population was booming. Technology advanced quickly and permitted the terraforming of many new planets. All was working well.
|
||||
|
||||
Eventually, corruption started to appear, timidly at first, but ended up avalanching. The Great Houses started bickering between each other. Privateers and Pirates started appearing, while the Emperor started to get drowned in burocracy. Terrorism also began to appear by sectors of the Empire not content with their status.
|
||||
|
||||
Then suddenly, silence. No one knows exactly what happened, but a gigantic explosion shook the foundations of the universe. The magnitude of the explosion was so enormous that it quickly annihilated many planets, leaving a gigantic void in the center of the Empire. Humanity's birthplace was near the epicenter, and the entire area was covered in a gigantic nebulae. It is referred to as 'The Incident' and marks the end of the golden age.
|
||||
|
||||
You find yourself in a universe with a decaying Empire, full of piracy and corruption, shaken to it's very bones by the Incident. However, where there is chaos, there is also oppotunity.
|
||||
|
||||
|
||||
|
||||
WELCOME!! To the universe of Lephisto!!
|
171
src/intro.c
Normal file
171
src/intro.c
Normal file
@ -0,0 +1,171 @@
|
||||
/**
|
||||
* @file intro.c
|
||||
*
|
||||
* @brief Handle the introduction sequence.
|
||||
*
|
||||
* @todo Allow handling of images and other fancy things once we get them.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "SDL.h"
|
||||
#include "lephisto.h"
|
||||
#include "log.h"
|
||||
#include "pack.h"
|
||||
#include "font.h"
|
||||
#include "intro.h"
|
||||
|
||||
#define INTRO_FONT_SIZE 18. /**< Intro text font size. */
|
||||
#define INTRO_SPEED 30. /**< Speed of text in characters / seconds. */
|
||||
|
||||
/* Intro text lines. */
|
||||
static char** intro_lines = NULL; /**< Introduction text lines. */
|
||||
static int intro_nlines = 0; /**< Number of introduction text lines. */
|
||||
static int intro_length = 0; /**< Length of the text. */
|
||||
static glFont intro_font; /** Introduction font. */
|
||||
|
||||
static int intro_load(void);
|
||||
static void intro_cleanup(void);
|
||||
|
||||
static int intro_load(void) {
|
||||
uint32_t intro_size;
|
||||
char* intro_buf;
|
||||
int i, p, n;
|
||||
int mem;
|
||||
|
||||
intro_buf = pack_readfile(DATA, "../dat/intro", &intro_size);
|
||||
intro_length = intro_size; /* Length aproximation! */
|
||||
|
||||
/* Create intro font. */
|
||||
gl_fontInit(&intro_font, NULL, INTRO_FONT_SIZE);
|
||||
|
||||
/* Load lines. */
|
||||
p = 0;
|
||||
n = 0;
|
||||
mem = 0;
|
||||
while((uint32_t)p < intro_size) {
|
||||
/* Get the length. */
|
||||
i = gl_printWidthForText(&intro_font, &intro_buf[p], SCREEN_W - 200.);
|
||||
|
||||
/* Copy the line. */
|
||||
if(n+1 > mem) {
|
||||
mem += 128;
|
||||
intro_lines = realloc(intro_lines, sizeof(char*) * mem);
|
||||
}
|
||||
intro_lines[n] = malloc(i+1);
|
||||
strncpy(intro_lines[n], &intro_buf[p], i);
|
||||
intro_lines[n][i] = '\0';
|
||||
|
||||
p += i + 1; /* Move pointer. */
|
||||
n++; /* New line. */
|
||||
}
|
||||
/* Clean up. */
|
||||
free(intro_buf);
|
||||
|
||||
intro_nlines = n;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Cleans up the intro crap!
|
||||
*/
|
||||
static void intro_cleanup(void) {
|
||||
int i;
|
||||
|
||||
/* Free memory. */
|
||||
for(i = 0; i < intro_nlines; i++)
|
||||
free(intro_lines[i]);
|
||||
free(intro_lines);
|
||||
gl_freeFont(&intro_font);
|
||||
|
||||
/* Set default. */
|
||||
intro_lines = NULL;
|
||||
intro_nlines = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Display the introduction sequence.
|
||||
*/
|
||||
int intro_display(void) {
|
||||
int i, max;
|
||||
unsigned int tcur, tlast;
|
||||
double dt;
|
||||
double x, y, vel;
|
||||
double offset;
|
||||
double density;
|
||||
SDL_Event event;
|
||||
|
||||
/* Load the introduction. */
|
||||
if(intro_load() < 0)
|
||||
return -1;
|
||||
|
||||
/* Calculate velocity. */
|
||||
density = ((double)intro_length / (double)intro_nlines); /* char / line. */
|
||||
density /= (double)intro_font.h; /* char / pixel. */
|
||||
vel = INTRO_SPEED / density; /* (char / s) * (pixel / char) = pixel / s */
|
||||
|
||||
x = 100.;
|
||||
y = 0.;
|
||||
tlast = SDL_GetTicks();
|
||||
offset = -(intro_font.h + 5.);
|
||||
max = intro_nlines + SCREEN_H / ((intro_font.h + 5.));
|
||||
|
||||
while(1) {
|
||||
/* Get delta tick in seconds! */
|
||||
tcur = SDL_GetTicks();
|
||||
dt = (double)(tcur - tlast) / 1000.;
|
||||
tlast = tcur;
|
||||
|
||||
/* Handle events. */
|
||||
while(SDL_PollEvent(&event)) {
|
||||
switch(event.type) {
|
||||
case SDL_KEYDOWN:
|
||||
/* Skip the boring intro we saw a million times already! */
|
||||
if(event.key.keysym.sym == SDLK_ESCAPE)
|
||||
offset = max * (intro_font.h + 5.);
|
||||
/* Purpose fallthrough. */
|
||||
case SDL_JOYBUTTONDOWN:
|
||||
offset += 250.;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Increment position. */
|
||||
offset += vel * dt;
|
||||
|
||||
/* Clear stuff. */
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
/* Draw text! */
|
||||
i = (int)(offset / (intro_font.h + 5.));
|
||||
if(i > max) /* Out of lines. */
|
||||
break;
|
||||
y = offset - (i+1) * (intro_font.h + 5.);
|
||||
|
||||
while(i >= intro_nlines) {
|
||||
/* Skip in line isn't valid. */
|
||||
if(i >= intro_nlines) {
|
||||
i--;
|
||||
y += intro_font.h + 5.;
|
||||
continue;
|
||||
}
|
||||
|
||||
gl_print(&intro_font, x, y, &cConsole, intro_lines[i]);
|
||||
|
||||
/* Increment line and position. */
|
||||
i--;
|
||||
y += intro_font.h + 5.;
|
||||
}
|
||||
|
||||
/* Display our sh*t. */
|
||||
SDL_GL_SwapBuffers();
|
||||
|
||||
SDL_Delay(10); /* No need to go burning our CPU now! */
|
||||
|
||||
}
|
||||
/* Cleanup our mess. */
|
||||
intro_cleanup();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
4
src/intro.h
Normal file
4
src/intro.h
Normal file
@ -0,0 +1,4 @@
|
||||
#pragma once
|
||||
|
||||
int intro_display(void);
|
||||
|
21
src/player.c
21
src/player.c
@ -31,6 +31,7 @@
|
||||
#include "spfx.h"
|
||||
#include "unidiff.h"
|
||||
#include "comm.h"
|
||||
#include "intro.h"
|
||||
#include "player.h"
|
||||
|
||||
#define XML_GUI_ID "GUIs" /**< XML section identifier for GUI document. */
|
||||
@ -193,7 +194,7 @@ extern void planets_minimap(const double res,
|
||||
/* Internal. */
|
||||
|
||||
/* Creation. */
|
||||
static void player_newMake(void);
|
||||
static int player_newMake(void);
|
||||
static void player_newShipMake(char* name);
|
||||
/* Sound. */
|
||||
static void player_initSound(void);
|
||||
@ -269,15 +270,17 @@ void player_new(void) {
|
||||
}
|
||||
}
|
||||
|
||||
player_newMake();
|
||||
if(player_newMake())
|
||||
return;
|
||||
|
||||
intro_display();
|
||||
}
|
||||
|
||||
/**
|
||||
* @fn static void player_newMake(void)
|
||||
*
|
||||
* @brief Actually create a new player.
|
||||
* @return 0 on success.
|
||||
*/
|
||||
static void player_newMake(void) {
|
||||
static int player_newMake(void) {
|
||||
Ship* ship;
|
||||
char* sysname;
|
||||
uint32_t bufsize;
|
||||
@ -295,13 +298,13 @@ static void player_newMake(void) {
|
||||
node = doc->xmlChildrenNode;
|
||||
if(!xml_isNode(node, XML_START_ID)) {
|
||||
ERR("Malformed '"START_DATA"' file: missing root element '"XML_START_ID"'");
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
|
||||
node = node->xmlChildrenNode; /* First system node. */
|
||||
if(node == NULL) {
|
||||
ERR("Malformed '"START_DATA"' file: does not contain elements");
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
do {
|
||||
/* We are interested in the player. */
|
||||
@ -356,7 +359,7 @@ static void player_newMake(void) {
|
||||
/* Try to create the pilot, if fails re-ask for player name. */
|
||||
if(player_newShip(ship, x, y, 0., 0., RNG(0, 369)/180.*M_PI) != 0) {
|
||||
player_new();
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
|
||||
space_init(sysname);
|
||||
@ -364,6 +367,8 @@ static void player_newMake(void) {
|
||||
|
||||
/* Clear the map. */
|
||||
map_clear();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -91,6 +91,9 @@ int save_all(void) {
|
||||
}
|
||||
snprintf(file, PATH_MAX, "%ssaves/%s.ls", lfile_basePath(), player_name);
|
||||
|
||||
/* Critical section, if crashes, the players save game gets screwed!!!
|
||||
* HAHAHAHAHA!!!!! -- NOT!
|
||||
*/
|
||||
xmlFreeTextWriter(writer);
|
||||
xmlSaveFileEnc(file, doc, "UTF-8");
|
||||
xmlFreeDoc(doc);
|
||||
|
Loading…
Reference in New Issue
Block a user