diff --git a/dev/screenshots/v0.2-02.png b/dev/screenshots/v0.2-02.png new file mode 100644 index 0000000..2cd2501 Binary files /dev/null and b/dev/screenshots/v0.2-02.png differ diff --git a/src/defs.h b/src/defs.h index d9450cd..e9e03f8 100644 --- a/src/defs.h +++ b/src/defs.h @@ -191,7 +191,7 @@ enum CONTROL_FIRE, CONTROL_JUMP, CONTROL_JETPACK, - CONTROL_SCREENSHOT, + CONTROL_STATUS, CONTROL_MAX }; diff --git a/src/system/controls.c b/src/system/controls.c index 4e58e6f..ad22103 100644 --- a/src/system/controls.c +++ b/src/system/controls.c @@ -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++) diff --git a/src/world/hud.c b/src/world/hud.c index 9162223..5d7a43d 100644 --- a/src/world/hud.c +++ b/src/world/hud.c @@ -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]; diff --git a/src/world/hud.h b/src/world/hud.h index b377135..d2d5621 100644 --- a/src/world/hud.h +++ b/src/world/hud.h @@ -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; diff --git a/src/world/player.h b/src/world/player.h index 8c62918..d85d283 100644 --- a/src/world/player.h +++ b/src/world/player.h @@ -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; diff --git a/src/world/world.c b/src/world/world.c index df54409..35f94ea 100644 --- a/src/world/world.c +++ b/src/world/world.c @@ -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) diff --git a/src/world/world.h b/src/world/world.h index c24cde2..8eabe77 100644 --- a/src/world/world.h +++ b/src/world/world.h @@ -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;