Show objective and inventory screen.

This commit is contained in:
Steve 2018-02-07 22:49:42 +00:00
parent b862123c95
commit e9c1560bde
8 changed files with 127 additions and 19 deletions

BIN
dev/screenshots/v0.2-02.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 568 KiB

View File

@ -191,7 +191,7 @@ enum
CONTROL_FIRE,
CONTROL_JUMP,
CONTROL_JETPACK,
CONTROL_SCREENSHOT,
CONTROL_STATUS,
CONTROL_MAX
};

View File

@ -31,6 +31,7 @@ void initControls(void)
game.config.keyControls[CONTROL_JUMP] = SDL_SCANCODE_I;
game.config.keyControls[CONTROL_FIRE] = SDL_SCANCODE_J;
game.config.keyControls[CONTROL_JETPACK] = SDL_SCANCODE_L;
game.config.keyControls[CONTROL_STATUS] = SDL_SCANCODE_TAB;
/* can't use memset here, as it doesn't work */
for (i = 0 ; i < CONTROL_MAX ; i++)

View File

@ -199,6 +199,85 @@ static void drawInventory(void)
}
}
void drawMissionStatus(void)
{
Objective *o;
int y, x, w, h, size, mid, i;
float rw, rh, d;
SDL_Color c;
SDL_Rect r;
char *status;
drawRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0, 64);
w = 800;
h = 500;
x = (SCREEN_WIDTH - w) / 2;
drawRect(x, (SCREEN_HEIGHT - h) / 2, w, h, 0, 0, 0, 128);
drawOutlineRect(x, (SCREEN_HEIGHT - h) / 2, w, h, 255, 255, 255, 200);
drawText(SCREEN_WIDTH / 2, 125, 40, TA_CENTER, colors.white, "OBJECTIVES");
y = 210;
for (o = world.objectiveHead.next ; o != NULL ; o = o->next)
{
c = colors.white;
status = _("Incomplete");
if (o->currentValue == o->targetValue)
{
c = colors.green;
status = _("Complete");
}
drawText(x + 20, y, 24, TA_LEFT, c, o->description);
drawText(SCREEN_WIDTH / 2 + 100, y, 24, TA_LEFT, c, "%d / %d", o->currentValue, o->targetValue);
drawText(x + w - 20, y, 24, TA_RIGHT, c, status);
y += 55;
}
size = 60;
mid = size / 2;
x = ((SCREEN_WIDTH - w) / 2) + 90;
y = 450;
for (i = 0 ; i < MAX_ITEMS ; i++)
{
if (i > 0 && i % (MAX_ITEMS / 2) == 0)
{
y += (size + 20);
x = ((SCREEN_WIDTH - w) / 2) + 90;
}
drawRect(x, y, size, size, 0, 0, 0, 128);
drawOutlineRect(x, y, size, size, 255, 255, 255, 255);
if (world.bob->items[i] != NULL)
{
r = getCurrentFrame(world.bob->items[i]->sprite[0]);
rw = r.w;
rh = r.h;
d = 40;
d /= (rw > rh) ? rw : rh;
rw *= d;
rh *= d;
blitRectScaled(atlasTexture->texture, x + mid, y + mid, rw, rh, &r, 1);
drawText(x + size - 5, y, 14, TA_RIGHT, colors.white, "%d", world.bob->items[i]->value);
}
x += (size + 30);
}
}
void setGameplayMessage(int newMessageType, const char *format, ...)
{
char newMessage[MAX_DESCRIPTION_LENGTH];

View File

@ -27,12 +27,10 @@ extern void drawOutlineRect(int x, int y, int w, int h, int r, int g, int b, int
extern void limitTextWidth(int width);
extern int getWrappedTextHeight(const char *text, int size);
extern void blitRectScaled(SDL_Texture *texture, int x, int y, int w, int h, SDL_Rect *srcRect, int center);
extern Sprite *getSprite(char *name);
extern Texture *getTexture(const char *filename);
extern SDL_Rect getCurrentFrame(Sprite *s);
extern Dev dev;
extern Camera camera;
extern Colors colors;
extern Game game;
extern World world;

View File

@ -22,5 +22,4 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
extern App app;
extern Dev dev;
extern Game game;
extern World world;

View File

@ -30,6 +30,7 @@ static void doWorldComplete(void);
static void doGameComplete(void);
static void doGameOver(void);
static void doCommon(void);
static void drawNormal(void);
static void addHelperItems(void);
static void spawnEnemies(void);
static int canAdd(Unit *u, int mx, int my);
@ -83,7 +84,8 @@ void initWorld(void)
startMission();
world.bob->y += MAP_TILE_SIZE * 4;
world.bob->x = 166 * MAP_TILE_SIZE;
world.bob->y = 103 * MAP_TILE_SIZE;
}
static void logic(void)
@ -130,24 +132,38 @@ static void draw(void)
{
clearScreen();
if (world.betweenTimer == 0)
switch (world.state)
{
blitScaled(background->texture, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0);
drawEntities(PLANE_BACKGROUND);
drawParticles(PLANE_BACKGROUND);
drawMap();
drawEntities(PLANE_FOREGROUND);
drawParticles(PLANE_FOREGROUND);
drawHud();
case WS_PAUSED:
drawNormal();
drawMissionStatus();
break;
default:
if (world.betweenTimer == 0)
{
drawNormal();
drawHud();
}
break;
}
}
static void drawNormal(void)
{
blitScaled(background->texture, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0);
drawEntities(PLANE_BACKGROUND);
drawParticles(PLANE_BACKGROUND);
drawMap();
drawEntities(PLANE_FOREGROUND);
drawParticles(PLANE_FOREGROUND);
}
void startMission(void)
{
Entity *self;
@ -208,6 +224,12 @@ static void doWorldInProgress(void)
doCommon();
doLocationTriggers();
if (isControl(CONTROL_STATUS))
{
world.state = WS_PAUSED;
clearControl(CONTROL_STATUS);
}
if (world.allObjectivesComplete && world.state != WS_COMPLETE)
{
@ -275,6 +297,12 @@ static void doWorldObserving(void)
static void doWorldPaused(void)
{
animateSprites();
if (isControl(CONTROL_STATUS))
{
world.state = WS_IN_PROGRESS;
clearControl(CONTROL_STATUS);
}
}
static void doWorldComplete(void)

View File

@ -61,6 +61,9 @@ extern void drawParticles(int plane);
extern void initItems(void);
extern void doPlayer(void);
extern int isOnScreen(Entity *e);
extern int isControl(int type);
extern void clearControl(int type);
extern void drawMissionStatus(void);
extern App app;
extern Dev dev;