Redo win overlay

This commit is contained in:
Miloslav Číž 2020-09-26 20:24:40 +02:00
parent 9d5e582d70
commit 544c7a955e
4 changed files with 109 additions and 4 deletions

102
game.h
View File

@ -4279,8 +4279,9 @@ void SFG_drawMenu()
i++; i++;
} }
SFG_drawText("0.7 CC0",SFG_HUD_MARGIN,SFG_GAME_RESOLUTION_Y - SFG_HUD_MARGIN SFG_drawText(SFG_VERSION_STRING " CC0",SFG_HUD_MARGIN,SFG_GAME_RESOLUTION_Y -
- SFG_FONT_SIZE_SMALL * SFG_FONT_CHARACTER_SIZE,SFG_FONT_SIZE_SMALL,4,0,0); SFG_HUD_MARGIN - SFG_FONT_SIZE_SMALL * SFG_FONT_CHARACTER_SIZE,
SFG_FONT_SIZE_SMALL,4,0,0);
#if SFG_OS_IS_MALWARE #if SFG_OS_IS_MALWARE
if (SFG_game.blink) if (SFG_game.blink)
@ -4293,6 +4294,102 @@ void SFG_drawMenu()
#undef SCROLL_PIXELS_PER_FRAME #undef SCROLL_PIXELS_PER_FRAME
} }
void SFG_drawWinOverlay()
{
uint32_t t = RCL_min(SFG_WIN_ANIMATION_DURATION,
SFG_game.frameTime - SFG_game.stateChangeTime);
uint32_t t2 = RCL_min(t,SFG_WIN_ANIMATION_DURATION / 4);
#define STRIP_HEIGHT (SFG_GAME_RESOLUTION_Y / 2)
#define INNER_STRIP_HEIGHT ((STRIP_HEIGHT * 3) / 4)
#define STRIP_START ((SFG_GAME_RESOLUTION_Y - STRIP_HEIGHT) / 2)
RCL_Unit l = (t2 * STRIP_HEIGHT * 4) / SFG_WIN_ANIMATION_DURATION;
uint8_t n = (t * 5) / SFG_WIN_ANIMATION_DURATION;
for (uint16_t y = STRIP_START; y < STRIP_START + l; ++y)
for (uint16_t x = 0; x < SFG_GAME_RESOLUTION_X; ++x)
SFG_setGamePixel(x,y,
RCL_abs(y - (SFG_GAME_RESOLUTION_Y / 2)) <= (INNER_STRIP_HEIGHT / 2) ?
0 : 172);
char textLine[] = "level done";
uint16_t y = SFG_GAME_RESOLUTION_Y / 2 -
((STRIP_HEIGHT + INNER_STRIP_HEIGHT) / 2) / 2;
uint16_t x = (SFG_GAME_RESOLUTION_X -
SFG_textHorizontalSize(textLine,SFG_FONT_SIZE_BIG)) / 2;
SFG_drawText(textLine,x,y,SFG_FONT_SIZE_BIG,7 + SFG_game.blink * 95,255,0);
uint32_t timeTotal = SFG_SAVE_TOTAL_TIME;
// don't show totals in level 1:
uint8_t blink = (SFG_game.blink) && (SFG_currentLevel.levelNumber != 0)
&& (timeTotal != 0);
if (t >= (SFG_WIN_ANIMATION_DURATION / 2))
{
y += (SFG_FONT_SIZE_BIG + SFG_FONT_SIZE_MEDIUM) * SFG_FONT_CHARACTER_SIZE;
x = SFG_HUD_MARGIN;
#define CHAR_SIZE (SFG_FONT_SIZE_SMALL * SFG_FONT_CHARACTER_SIZE)
uint32_t time = blink ? timeTotal : SFG_currentLevel.completionTime10sOfS;
x += SFG_drawNumber(time / 10,x,y,SFG_FONT_SIZE_SMALL,7) *
CHAR_SIZE;
char timeRest[5] = ".X s";
timeRest[1] = '0' + (time % 10);
SFG_drawText(timeRest,x,y,SFG_FONT_SIZE_SMALL,7,4,0);
x = SFG_HUD_MARGIN;
y += (SFG_FONT_SIZE_BIG + SFG_FONT_SIZE_MEDIUM) * SFG_FONT_CHARACTER_SIZE;
if (blink)
{
x += (SFG_drawNumber(SFG_game.save[10] + SFG_game.save[11] * 256,x,y,
SFG_FONT_SIZE_SMALL,7) + 1) * CHAR_SIZE;
}
else
{
x += SFG_drawNumber(SFG_currentLevel.monstersDead,x,y,
SFG_FONT_SIZE_SMALL,7) * CHAR_SIZE;
SFG_drawText("/",x,y,SFG_FONT_SIZE_SMALL,7,1,0);
x += CHAR_SIZE;
x += (SFG_drawNumber(SFG_currentLevel.monsterRecordCount,x,y,
SFG_FONT_SIZE_SMALL,7) + 1) * CHAR_SIZE;
}
SFG_drawText(SFG_TEXT_KILLS,x,y,SFG_FONT_SIZE_SMALL,7,255,0);
if ((t >= (SFG_WIN_ANIMATION_DURATION - 1)) &&
(SFG_currentLevel.levelNumber != (SFG_NUMBER_OF_LEVELS - 1)))
{
y += (SFG_FONT_SIZE_BIG + SFG_FONT_SIZE_MEDIUM) * SFG_FONT_CHARACTER_SIZE;
SFG_drawText(SFG_TEXT_SAVE_PROMPT,
(SFG_GAME_RESOLUTION_X - SFG_textHorizontalSize(SFG_TEXT_SAVE_PROMPT,
SFG_FONT_SIZE_MEDIUM)) / 2,y,SFG_FONT_SIZE_MEDIUM,7,255,0);
}
#undef CHAR_SIZE
}
#undef STRIP_HEIGHT
#undef STRIP_START
#undef INNER_STRIP_HEIGHT
}
/*
void SFG_drawWinOverlay() void SFG_drawWinOverlay()
{ {
uint32_t t = RCL_min(SFG_WIN_ANIMATION_DURATION, uint32_t t = RCL_min(SFG_WIN_ANIMATION_DURATION,
@ -4400,6 +4497,7 @@ void SFG_drawWinOverlay()
#undef STRIP_START #undef STRIP_START
#undef INNER_STRIP_HEIGHT #undef INNER_STRIP_HEIGHT
} }
*/
void SFG_draw() void SFG_draw()
{ {

View File

@ -23,6 +23,7 @@
#define SFG_RAYCASTING_MAX_STEPS 20 #define SFG_RAYCASTING_MAX_STEPS 20
#define SFG_RAYCASTING_MAX_HITS 5 #define SFG_RAYCASTING_MAX_HITS 5
#define SFG_RAYCASTING_SUBSAMPLE 2 #define SFG_RAYCASTING_SUBSAMPLE 2
#define SFG_DIMINISH_SPRITES 0
#define SFG_DITHERED_SHADOW 0 #define SFG_DITHERED_SHADOW 0

View File

@ -29,7 +29,7 @@
// #define SFG_START_LEVEL 6 // #define SFG_START_LEVEL 6
// #define SFG_IMMORTAL 1 // #define SFG_IMMORTAL 1
// #define SFG_UNLOCK_DOOR 1 #define SFG_UNLOCK_DOOR 1
// #define SFG_REVEAL_MAP 1 // #define SFG_REVEAL_MAP 1
// #define SFG_INFINITE_AMMO 1 // #define SFG_INFINITE_AMMO 1

View File

@ -32,6 +32,12 @@ static const char *SFG_menuItemTexts[] =
#define SFG_TEXT_KILLS "kills" #define SFG_TEXT_KILLS "kills"
#define SFG_TEXT_SAVE_PROMPT "save? L no yes R" #define SFG_TEXT_SAVE_PROMPT "save? L no yes R"
#define SFG_TEXT_SAVED "saved" #define SFG_TEXT_SAVED "saved"
#define SFG_VERSION_STRING "0.9d"
/**<
Version numbering is following: major.minor for stable releases,
in-development unstable versions have the version of the latest stable +
"d" postfix, e.g. 1.0d. This means the "d" versions can actually differ even
if they're marked the same. */
static const char *SFG_introText = static const char *SFG_introText =
"Near future, capitalist hell, Macrochip corp has enslaved man via " "Near future, capitalist hell, Macrochip corp has enslaved man via "