Show objective and inventory screen.
This commit is contained in:
parent
b862123c95
commit
e9c1560bde
Binary file not shown.
After Width: | Height: | Size: 568 KiB |
|
@ -191,7 +191,7 @@ enum
|
||||||
CONTROL_FIRE,
|
CONTROL_FIRE,
|
||||||
CONTROL_JUMP,
|
CONTROL_JUMP,
|
||||||
CONTROL_JETPACK,
|
CONTROL_JETPACK,
|
||||||
CONTROL_SCREENSHOT,
|
CONTROL_STATUS,
|
||||||
CONTROL_MAX
|
CONTROL_MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@ void initControls(void)
|
||||||
game.config.keyControls[CONTROL_JUMP] = SDL_SCANCODE_I;
|
game.config.keyControls[CONTROL_JUMP] = SDL_SCANCODE_I;
|
||||||
game.config.keyControls[CONTROL_FIRE] = SDL_SCANCODE_J;
|
game.config.keyControls[CONTROL_FIRE] = SDL_SCANCODE_J;
|
||||||
game.config.keyControls[CONTROL_JETPACK] = SDL_SCANCODE_L;
|
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 */
|
/* can't use memset here, as it doesn't work */
|
||||||
for (i = 0 ; i < CONTROL_MAX ; i++)
|
for (i = 0 ; i < CONTROL_MAX ; i++)
|
||||||
|
|
|
@ -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, ...)
|
void setGameplayMessage(int newMessageType, const char *format, ...)
|
||||||
{
|
{
|
||||||
char newMessage[MAX_DESCRIPTION_LENGTH];
|
char newMessage[MAX_DESCRIPTION_LENGTH];
|
||||||
|
|
|
@ -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 void limitTextWidth(int width);
|
||||||
extern int getWrappedTextHeight(const char *text, int size);
|
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 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 Texture *getTexture(const char *filename);
|
||||||
extern SDL_Rect getCurrentFrame(Sprite *s);
|
extern SDL_Rect getCurrentFrame(Sprite *s);
|
||||||
|
|
||||||
extern Dev dev;
|
extern Dev dev;
|
||||||
extern Camera camera;
|
extern Camera camera;
|
||||||
extern Colors colors;
|
extern Colors colors;
|
||||||
extern Game game;
|
|
||||||
extern World world;
|
extern World world;
|
||||||
|
|
|
@ -22,5 +22,4 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
extern App app;
|
extern App app;
|
||||||
extern Dev dev;
|
extern Dev dev;
|
||||||
extern Game game;
|
|
||||||
extern World world;
|
extern World world;
|
||||||
|
|
|
@ -30,6 +30,7 @@ static void doWorldComplete(void);
|
||||||
static void doGameComplete(void);
|
static void doGameComplete(void);
|
||||||
static void doGameOver(void);
|
static void doGameOver(void);
|
||||||
static void doCommon(void);
|
static void doCommon(void);
|
||||||
|
static void drawNormal(void);
|
||||||
static void addHelperItems(void);
|
static void addHelperItems(void);
|
||||||
static void spawnEnemies(void);
|
static void spawnEnemies(void);
|
||||||
static int canAdd(Unit *u, int mx, int my);
|
static int canAdd(Unit *u, int mx, int my);
|
||||||
|
@ -83,7 +84,8 @@ void initWorld(void)
|
||||||
|
|
||||||
startMission();
|
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)
|
static void logic(void)
|
||||||
|
@ -130,7 +132,24 @@ static void draw(void)
|
||||||
{
|
{
|
||||||
clearScreen();
|
clearScreen();
|
||||||
|
|
||||||
|
switch (world.state)
|
||||||
|
{
|
||||||
|
case WS_PAUSED:
|
||||||
|
drawNormal();
|
||||||
|
drawMissionStatus();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
if (world.betweenTimer == 0)
|
if (world.betweenTimer == 0)
|
||||||
|
{
|
||||||
|
drawNormal();
|
||||||
|
drawHud();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void drawNormal(void)
|
||||||
{
|
{
|
||||||
blitScaled(background->texture, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0);
|
blitScaled(background->texture, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0);
|
||||||
|
|
||||||
|
@ -143,9 +162,6 @@ static void draw(void)
|
||||||
drawEntities(PLANE_FOREGROUND);
|
drawEntities(PLANE_FOREGROUND);
|
||||||
|
|
||||||
drawParticles(PLANE_FOREGROUND);
|
drawParticles(PLANE_FOREGROUND);
|
||||||
|
|
||||||
drawHud();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void startMission(void)
|
void startMission(void)
|
||||||
|
@ -209,6 +225,12 @@ static void doWorldInProgress(void)
|
||||||
|
|
||||||
doLocationTriggers();
|
doLocationTriggers();
|
||||||
|
|
||||||
|
if (isControl(CONTROL_STATUS))
|
||||||
|
{
|
||||||
|
world.state = WS_PAUSED;
|
||||||
|
clearControl(CONTROL_STATUS);
|
||||||
|
}
|
||||||
|
|
||||||
if (world.allObjectivesComplete && world.state != WS_COMPLETE)
|
if (world.allObjectivesComplete && world.state != WS_COMPLETE)
|
||||||
{
|
{
|
||||||
world.bob->flags |= EF_IMMUNE;
|
world.bob->flags |= EF_IMMUNE;
|
||||||
|
@ -275,6 +297,12 @@ static void doWorldObserving(void)
|
||||||
static void doWorldPaused(void)
|
static void doWorldPaused(void)
|
||||||
{
|
{
|
||||||
animateSprites();
|
animateSprites();
|
||||||
|
|
||||||
|
if (isControl(CONTROL_STATUS))
|
||||||
|
{
|
||||||
|
world.state = WS_IN_PROGRESS;
|
||||||
|
clearControl(CONTROL_STATUS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doWorldComplete(void)
|
static void doWorldComplete(void)
|
||||||
|
|
|
@ -61,6 +61,9 @@ extern void drawParticles(int plane);
|
||||||
extern void initItems(void);
|
extern void initItems(void);
|
||||||
extern void doPlayer(void);
|
extern void doPlayer(void);
|
||||||
extern int isOnScreen(Entity *e);
|
extern int isOnScreen(Entity *e);
|
||||||
|
extern int isControl(int type);
|
||||||
|
extern void clearControl(int type);
|
||||||
|
extern void drawMissionStatus(void);
|
||||||
|
|
||||||
extern App app;
|
extern App app;
|
||||||
extern Dev dev;
|
extern Dev dev;
|
||||||
|
|
Loading…
Reference in New Issue