[Add] News window and the concept of fuel.
This commit is contained in:
parent
1307661363
commit
2c388ea1b0
42
src/land.c
42
src/land.c
@ -2,14 +2,20 @@
|
|||||||
#include "pause.h"
|
#include "pause.h"
|
||||||
#include "land.h"
|
#include "land.h"
|
||||||
|
|
||||||
|
// Global/main window.
|
||||||
#define LAND_WIDTH 700
|
#define LAND_WIDTH 700
|
||||||
#define LAND_HEIGHT 600
|
#define LAND_HEIGHT 600
|
||||||
#define BUTTON_WIDTH 200
|
#define BUTTON_WIDTH 200
|
||||||
#define BUTTON_HEIGHT 40
|
#define BUTTON_HEIGHT 40
|
||||||
|
|
||||||
|
// News window.
|
||||||
|
#define NEWS_WIDTH 400
|
||||||
|
#define NEWS_HEIGHT 400
|
||||||
|
|
||||||
int landed = 0;
|
int landed = 0;
|
||||||
|
|
||||||
static int land_wid = 0;
|
static int land_wid = 0; // Primary land window.
|
||||||
|
static int secondary_wid = 0; // For the second opened land window (We can only have 2 max).
|
||||||
static Planet* planet = NULL;
|
static Planet* planet = NULL;
|
||||||
|
|
||||||
static void commodity_exchange(coid);
|
static void commodity_exchange(coid);
|
||||||
@ -17,6 +23,7 @@ static void outfits(void);
|
|||||||
static void shipyard(void);
|
static void shipyard(void);
|
||||||
static void spaceport_bar(void);
|
static void spaceport_bar(void);
|
||||||
static void news(void);
|
static void news(void);
|
||||||
|
static void news_close(char* str);
|
||||||
|
|
||||||
static void commodity_exchange(void) {
|
static void commodity_exchange(void) {
|
||||||
|
|
||||||
@ -35,7 +42,24 @@ static void spaceport_bar(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void news(void) {
|
static void news(void) {
|
||||||
|
secondary_wid = window_create(-1, -1, NEWS_WIDTH, NEWS_HEIGHT);
|
||||||
|
|
||||||
|
// Window title.
|
||||||
|
window_addText(secondary_wid, 0, -20, NEWS_WIDTH, 0, 1,
|
||||||
|
"txtTitle", NULL, &cBlack, "News Reports");
|
||||||
|
|
||||||
|
window_addText(secondary_wid, 20, 20 + BUTTON_HEIGHT + 20,
|
||||||
|
NEWS_WIDTH-40, NEWS_HEIGHT - 20 - BUTTON_HEIGHT - 20 - 20 -20,
|
||||||
|
0, "txtNews", &gl_smallFont, &cBlack,
|
||||||
|
"News reporters report that they are on strike right now! D:");
|
||||||
|
|
||||||
|
window_addButton(secondary_wid, -20, 20, BUTTON_WIDTH, BUTTON_HEIGHT,
|
||||||
|
"btnCloseNews", "Close", news_close);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void news_close(char* str) {
|
||||||
|
if(strcmp(str, "btnCloseNews")==0)
|
||||||
|
window_destroy(secondary_wid);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Land the player.
|
// Land the player.
|
||||||
@ -45,34 +69,34 @@ void land(Planet* p) {
|
|||||||
land_wid = window_create(-1, -1, LAND_WIDTH, LAND_HEIGHT);
|
land_wid = window_create(-1, -1, LAND_WIDTH, LAND_HEIGHT);
|
||||||
|
|
||||||
// Pretty display.
|
// Pretty display.
|
||||||
window_addText(land_wid, 0., -20., LAND_WIDTH, 0, 1, "txtPlanet", NULL, &cBlack, p->name);
|
window_addText(land_wid, 0., -20, LAND_WIDTH, 0, 1, "txtPlanet", NULL, &cBlack, p->name);
|
||||||
window_addImage(land_wid, 20., -440, "imgPlanet", p->gfx_exterior);
|
window_addImage(land_wid, 20, -440, "imgPlanet", p->gfx_exterior);
|
||||||
window_addText(land_wid, 440., 80., 200., 460., 0,
|
window_addText(land_wid, 440, 80, 200, 460, 0,
|
||||||
"txtPlanetDesc", &gl_smallFont, &cBlack, p->description);
|
"txtPlanetDesc", &gl_smallFont, &cBlack, p->description);
|
||||||
// Buttons.
|
// Buttons.
|
||||||
window_addButton(land_wid, -20, 20, BUTTON_WIDTH, BUTTON_HEIGHT,
|
window_addButton(land_wid, -20, 20, BUTTON_WIDTH, BUTTON_HEIGHT,
|
||||||
"btnTakeoff", "Takeoff", (void(*)(char*))takeoff);
|
"btnTakeoff", "Takeoff", (void(*)(char*))takeoff);
|
||||||
|
|
||||||
if(planet_hasService(planet, PLANET_SERVICE_COMMODITY))
|
if(planet_hasService(planet, PLANET_SERVICE_COMMODITY))
|
||||||
window_addButton(land_wid, -20., 20. + BUTTON_HEIGHT + 20.,
|
window_addButton(land_wid, -20, 20 + BUTTON_HEIGHT + 20,
|
||||||
BUTTON_WIDTH, BUTTON_HEIGHT, "btnCommodity",
|
BUTTON_WIDTH, BUTTON_HEIGHT, "btnCommodity",
|
||||||
"Commodity Exchange", (void(*)(char*))commodity_exchange);
|
"Commodity Exchange", (void(*)(char*))commodity_exchange);
|
||||||
|
|
||||||
if(planet_hasService(planet, PLANET_SERVICE_SHIPYARD))
|
if(planet_hasService(planet, PLANET_SERVICE_SHIPYARD))
|
||||||
window_addButton(land_wid, -20. - BUTTON_WIDTH - 20., 20.,
|
window_addButton(land_wid, -20 - BUTTON_WIDTH - 20, 20,
|
||||||
BUTTON_WIDTH, BUTTON_HEIGHT, "btnShipyard",
|
BUTTON_WIDTH, BUTTON_HEIGHT, "btnShipyard",
|
||||||
"Shipyard", (void(*)(char*))shipyard);
|
"Shipyard", (void(*)(char*))shipyard);
|
||||||
|
|
||||||
if(planet_hasService(planet, PLANET_SERVICE_OUTFITS))
|
if(planet_hasService(planet, PLANET_SERVICE_OUTFITS))
|
||||||
window_addButton(land_wid, -20. - BUTTON_WIDTH - 20., 20. + BUTTON_HEIGHT + 20.,
|
window_addButton(land_wid, -20 - BUTTON_WIDTH - 20, 20 + BUTTON_HEIGHT + 20,
|
||||||
BUTTON_WIDTH, BUTTON_HEIGHT, "btnOutfits",
|
BUTTON_WIDTH, BUTTON_HEIGHT, "btnOutfits",
|
||||||
"Outfits", (void(*)(char*))outfits);
|
"Outfits", (void(*)(char*))outfits);
|
||||||
|
|
||||||
if(planet_hasService(planet, PLANET_SERVICE_BASIC))
|
if(planet_hasService(planet, PLANET_SERVICE_BASIC))
|
||||||
window_addButton(land_wid, 20., 20.,
|
window_addButton(land_wid, 20, 20,
|
||||||
BUTTON_WIDTH, BUTTON_HEIGHT, "btnNews",
|
BUTTON_WIDTH, BUTTON_HEIGHT, "btnNews",
|
||||||
"News", (void(*)(char*))news);
|
"News", (void(*)(char*))news);
|
||||||
window_addButton(land_wid, 20., 20. + BUTTON_HEIGHT + 20.,
|
window_addButton(land_wid, 20, 20 + BUTTON_HEIGHT + 20,
|
||||||
BUTTON_WIDTH, BUTTON_HEIGHT, "btnBar",
|
BUTTON_WIDTH, BUTTON_HEIGHT, "btnBar",
|
||||||
"SpaceBar", (void(*)(char*))spaceport_bar);
|
"SpaceBar", (void(*)(char*))spaceport_bar);
|
||||||
|
|
||||||
|
@ -47,6 +47,7 @@ typedef struct Pilot {
|
|||||||
// Current health.
|
// Current health.
|
||||||
double armour, shield, energy;
|
double armour, shield, energy;
|
||||||
double armour_max, shield_max, energy_max;
|
double armour_max, shield_max, energy_max;
|
||||||
|
double fuel; // Used only for jumps. TODO: make it do something.
|
||||||
|
|
||||||
void (*think)(struct Pilot*); // AI thinking for the pilot.
|
void (*think)(struct Pilot*); // AI thinking for the pilot.
|
||||||
void (*update)(struct Pilot*, const double); // Update the pilot.
|
void (*update)(struct Pilot*, const double); // Update the pilot.
|
||||||
|
Loading…
Reference in New Issue
Block a user