Show hud messages.
This commit is contained in:
parent
d3db893190
commit
5588abc063
|
@ -23,6 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
static int messageTime;
|
||||
static char message[MAX_DESCRIPTION_LENGTH];
|
||||
static int messageType;
|
||||
static SDL_Color messageColor;
|
||||
|
||||
static char infoMessage[MAX_DESCRIPTION_LENGTH];
|
||||
|
||||
|
@ -30,6 +31,8 @@ void initHud(void)
|
|||
{
|
||||
messageTime = FPS * 2;
|
||||
messageType = MSG_STANDARD;
|
||||
strcpy(message, "");
|
||||
messageColor = colors.white;
|
||||
}
|
||||
|
||||
void doHud(void)
|
||||
|
@ -46,11 +49,27 @@ void doHud(void)
|
|||
|
||||
void drawHud(void)
|
||||
{
|
||||
drawText(SCREEN_WIDTH / 2, SCREEN_HEIGHT - 25, 14, TA_CENTER, colors.white, "Bob [%.0f, %.0f]", world.bob->x / MAP_TILE_SIZE, world.bob->y / MAP_TILE_SIZE);
|
||||
int x, y;
|
||||
|
||||
if (messageTime > 0)
|
||||
{
|
||||
drawRect(0, SCREEN_HEIGHT - 32, SCREEN_WIDTH, 32, 0, 0, 0, 200);
|
||||
|
||||
drawText(SCREEN_WIDTH / 2, SCREEN_HEIGHT - 26, 16, TA_CENTER, messageColor, message);
|
||||
}
|
||||
|
||||
if (dev.debug)
|
||||
{
|
||||
x = -camera.x + world.bob->x + (world.bob->w / 2);
|
||||
y = -camera.y + world.bob->y - world.bob->h;
|
||||
|
||||
drawText(x, y, 14, TA_CENTER, colors.white, "[%.0f, %.0f]", world.bob->x / MAP_TILE_SIZE, world.bob->y / MAP_TILE_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
void setGameplayMessage(int newMessageType, const char *format, ...)
|
||||
{
|
||||
int i;
|
||||
char newMessage[MAX_DESCRIPTION_LENGTH];
|
||||
va_list args;
|
||||
|
||||
|
@ -66,7 +85,28 @@ void setGameplayMessage(int newMessageType, const char *format, ...)
|
|||
messageType = newMessageType;
|
||||
messageTime = FPS * 3;
|
||||
|
||||
for (i = 0 ; i < strlen(message) ; i++)
|
||||
{
|
||||
message[i] = toupper(message[i]);
|
||||
}
|
||||
|
||||
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "%s", message);
|
||||
|
||||
switch (messageType)
|
||||
{
|
||||
case MSG_STANDARD:
|
||||
case MSG_GAMEPLAY:
|
||||
messageColor = colors.white;
|
||||
break;
|
||||
|
||||
case MSG_PROGRESS:
|
||||
messageColor = colors.cyan;
|
||||
break;
|
||||
|
||||
case MSG_OBJECTIVE:
|
||||
messageColor = colors.green;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
extern void showWidgetGroup(char *groupName);
|
||||
extern void drawText(int x, int y, int size, int align, SDL_Color c, const char *format, ...);
|
||||
extern void drawRect(int x, int y, int w, int h, int r, int g, int b, int a);
|
||||
|
||||
extern Dev dev;
|
||||
extern Camera camera;
|
||||
extern Colors colors;
|
||||
extern World world;
|
||||
|
|
|
@ -43,6 +43,8 @@ void initWorld(void)
|
|||
|
||||
initObjectives();
|
||||
|
||||
initHud();
|
||||
|
||||
world.enemySpawnTimer = (FPS * rrnd(world.minEnemySpawnTime, world.maxEnemySpawnTime));
|
||||
|
||||
world.state = WS_START;
|
||||
|
@ -65,9 +67,6 @@ void initWorld(void)
|
|||
app.delegate.draw = draw;
|
||||
|
||||
startMission();
|
||||
|
||||
world.bob->x = 110 * MAP_TILE_SIZE;
|
||||
world.bob->y = 105 * MAP_TILE_SIZE;
|
||||
}
|
||||
|
||||
static void logic(void)
|
||||
|
|
|
@ -52,6 +52,7 @@ extern void drawMap(void);
|
|||
extern void blitScaled(SDL_Texture *texture, int x, int y, int w, int h, int center);
|
||||
extern void clearScreen(void);
|
||||
extern void drawHud(void);
|
||||
extern void initHud(void);
|
||||
|
||||
extern App app;
|
||||
extern Dev dev;
|
||||
|
|
Loading…
Reference in New Issue