Start menu

This commit is contained in:
Miloslav Číž 2020-02-11 21:24:50 +01:00
parent 689ad344c6
commit 7555ac4851
4 changed files with 127 additions and 25 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 979 B

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -583,27 +583,27 @@ SFG_PROGRAM_MEMORY uint8_t SFG_itemSprites[][SFG_TEXTURE_STORE_SIZE] =
SFG_PROGRAM_MEMORY uint8_t SFG_backgroundImages[][SFG_TEXTURE_STORE_SIZE] =
{
{ // 0, city
64,73,10,168,19,12,14,13,80,101,0,100,136,57,59,63,34,34,34,68,87,119,119,119,
118,8,0,16,0,28,17,17,34,34,36,85,84,85,119,118,102,96,0,129,129,1,17,17,34,34,
36,66,68,69,119,102,99,48,48,0,1,16,17,17,34,34,34,34,68,68,87,118,102,102,104,
0,1,12,17,17,34,34,34,36,69,69,51,51,0,8,0,192,1,16,17,17,34,34,34,36,85,87,58,
170,163,51,0,0,0,1,17,17,34,34,34,68,85,119,218,170,51,192,48,0,0,16,17,193,34,
34,34,68,85,119,51,51,48,3,0,0,129,17,17,17,34,34,68,68,85,119,119,102,102,104,
48,24,16,16,17,17,34,34,36,69,87,119,119,102,102,102,128,128,0,1,17,17,34,34,34,
69,87,51,51,51,0,8,48,24,16,16,17,17,34,34,34,36,87,58,250,250,227,51,0,0,128,1,
17,17,226,34,34,36,85,58,170,170,51,48,48,0,16,16,17,17,34,34,34,68,85,51,61,51,
48,51,8,129,129,1,17,17,34,34,36,69,103,149,85,95,102,0,56,0,0,28,17,17,34,34,
34,69,85,153,85,89,111,3,13,0,0,1,17,17,34,34,34,68,85,153,51,51,0,8,8,0,0,16,
17,17,34,34,34,68,75,153,51,51,48,0,140,0,0,1,17,17,34,34,34,68,75,185,51,51,0,
8,48,0,0,16,17,17,34,34,66,69,51,51,58,170,163,51,192,0,0,1,17,17,34,34,68,69,
63,207,170,170,51,48,192,0,0,16,17,17,34,34,78,69,51,51,51,51,48,208,136,128,12,
1,17,17,238,34,78,68,85,187,153,185,144,8,48,24,16,28,17,17,34,34,36,68,69,91,
185,179,48,0,0,0,0,1,28,17,34,34,68,68,75,185,187,179,0,8,48,0,192,16,17,17,226,
36,69,85,84,185,187,147,48,0,136,128,0,1,17,17,34,68,69,85,119,121,187,185,150,
104,8,16,0,16,17,17,34,34,68,69,87,105,187,153,246,102,102,128,0,1,17,17,34,34,
36,85,87,105,185,156,0,8,8,0,0,16,17,17,34,34,36,84,86,105,150,102,102,3,192,0,
1,1,17,17,34,34,36,68,71,103,118,108,0,8,0,24,17,16,17,17,34,34,34,68,71,102,
103,102,246,102,248,128,0,1,17,17
64,10,73,168,19,12,14,13,80,1,72,101,0,100,136,57,17,17,17,68,87,119,119,119,
118,8,0,32,0,46,34,154,17,17,20,85,84,85,119,118,102,96,0,130,130,2,34,154,17,
17,20,65,68,69,119,102,99,48,48,0,2,32,34,154,17,17,17,17,68,68,87,118,102,102,
104,0,2,14,34,154,17,17,17,20,69,69,51,51,0,8,0,224,2,32,34,154,17,17,17,20,85,
87,60,204,195,51,0,0,0,2,34,154,17,17,17,68,85,119,252,204,51,224,48,0,0,32,34,
154,17,17,17,68,85,119,51,51,48,3,0,0,130,34,34,154,17,17,68,68,85,119,119,102,
102,104,48,40,32,32,34,154,17,17,20,69,87,119,119,102,102,102,128,128,0,2,34,
154,17,17,17,69,87,51,51,51,0,8,48,40,32,32,34,154,17,17,17,20,87,60,252,252,
243,51,0,0,128,2,34,154,65,17,17,20,85,60,204,204,51,48,48,0,32,32,34,154,17,17,
17,68,85,51,63,51,48,51,8,130,130,2,34,154,17,17,20,69,103,181,85,86,102,0,56,0,
0,46,34,154,17,17,17,69,85,187,85,91,102,3,15,0,0,2,34,154,17,17,17,68,85,187,
51,51,0,8,8,0,0,32,34,154,17,17,17,68,77,187,51,51,48,0,142,0,0,2,34,154,17,17,
17,68,77,219,51,51,0,8,48,0,0,32,34,154,17,17,65,69,51,51,60,204,195,51,224,0,0,
2,34,154,17,17,68,69,63,239,204,204,51,48,224,0,0,32,34,154,17,17,71,69,51,51,
51,51,48,240,136,128,14,2,34,154,68,17,71,68,85,221,187,219,176,8,48,40,32,46,
34,154,17,17,20,68,69,93,219,211,48,0,0,0,0,2,34,154,17,17,68,68,77,219,221,211,
0,8,48,0,224,32,34,154,65,20,69,85,84,219,221,179,48,0,136,128,0,2,34,154,17,68,
69,85,119,123,221,219,182,104,8,32,0,32,34,154,17,17,68,69,87,107,221,187,102,
102,102,128,0,2,34,154,17,17,20,85,87,107,219,190,0,8,8,0,0,32,34,154,17,17,20,
84,86,107,182,102,102,3,224,0,2,2,34,154,17,17,20,68,71,103,118,110,0,8,0,40,34,
32,34,154,17,17,17,68,71,102,103,102,102,102,104,128,0,2,34,154
},
{ // 1, reddish scifi interior
168,18,17,19,65,153,1,9,152,232,0,45,61,80,96,160,18,114,34,34,34,34,34,80,0,0,
@ -1225,6 +1225,28 @@ SFG_PROGRAM_MEMORY uint8_t SFG_monsterSprites[][SFG_TEXTURE_STORE_SIZE] =
}
};
uint8_t SFG_logoImage[SFG_TEXTURE_STORE_SIZE] =
{
175,224,0,7,4,5,162,77,2,74,70,69,6,11,68,75,0,0,0,0,0,0,17,17,17,17,17,0,0,0,0,
0,0,0,0,0,0,1,132,69,51,84,65,0,0,0,0,0,0,0,0,0,0,24,65,17,19,17,17,0,0,0,0,0,0,
0,0,0,0,24,65,0,19,16,0,0,0,0,0,0,0,0,0,0,0,24,65,17,19,17,17,0,0,0,0,0,0,0,0,0,
0,1,132,69,51,84,65,32,0,0,0,0,0,0,0,0,0,1,17,17,17,17,17,242,0,0,0,0,0,0,0,6,
97,243,94,40,51,84,66,159,32,0,0,0,0,0,17,17,24,60,190,40,50,34,34,155,146,0,0,
0,0,0,33,17,20,203,238,109,51,84,66,251,178,0,0,0,0,0,17,17,131,171,123,145,18,
34,38,122,187,32,0,0,0,0,6,97,92,170,167,113,115,35,81,122,171,32,0,0,0,0,2,22,
202,170,170,212,51,37,210,26,121,130,0,0,0,0,34,17,22,234,164,28,60,34,92,23,
218,56,32,0,0,2,33,17,102,110,113,69,210,35,51,93,51,66,50,0,0,34,34,40,126,246,
210,34,195,35,51,49,210,34,34,0,0,0,2,40,119,238,105,197,210,35,51,93,51,65,50,
0,0,0,2,38,87,119,166,156,60,34,92,223,218,161,32,0,0,2,34,38,87,119,170,20,51,
37,223,23,114,18,0,0,0,2,34,34,69,122,119,241,211,35,86,102,187,32,0,0,0,0,0,97,
213,119,187,97,134,45,17,246,105,32,0,0,0,0,34,33,22,247,238,29,51,53,65,155,98,
0,0,0,0,0,2,34,33,110,233,29,54,17,17,155,146,0,0,0,0,0,0,0,97,111,153,34,34,34,
29,159,32,0,0,0,0,0,0,0,0,41,150,40,51,84,65,146,0,0,0,0,0,0,0,0,0,2,38,40,56,
24,65,32,0,0,0,0,0,0,0,0,0,0,2,40,49,145,65,0,0,0,0,0,0,0,0,0,0,1,17,34,17,17,
17,0,0,0,0,0,0,0,0,0,0,1,132,69,51,84,65,0,0,0,0,0,0,0,0,0,0,1,17,24,56,17,17,0,
0,0,0,0,0,0,0,0,0,0,0,24,51,84,65,0,0,0,0,0,0,0,0,0,0,0,0,1,17,17,17,0,0,0,0,0
};
uint8_t SFG_charToFontIndex(char c)
{
if (c >= 'a' && c <= 'z')

88
main.c
View File

@ -660,7 +660,7 @@ void SFG_pixelFunc(RCL_PixelInfo *pixel)
#if SFG_BACKGROUND_BLUR != 0
+ SFG_backgroundBlurOffsets[SFG_backgroundBlurIndex]
#endif
) * SFG_RAYCASTING_SUBSAMPLE + SFG_game.backgroundScroll) % SFG_GAME_RESOLUTION_Y],
) * SFG_RAYCASTING_SUBSAMPLE + SFG_game.backgroundScroll) % SFG_GAME_RESOLUTION_Y],
(SFG_game.backgroundScaleMap[(pixel->position.y // ^ TODO: get rid of mod?
#if SFG_BACKGROUND_BLUR != 0
+ SFG_backgroundBlurOffsets[SFG_backgroundBlurIndex + 1]
@ -1873,7 +1873,7 @@ uint8_t SFG_projectileCollides(SFG_ProjectileRecord *projectile,
return RCL_vectorsAngleCos(projDir,toElement) >= 0;
}
SFG_getLevelElementSprite(
void SFG_getLevelElementSprite(
uint8_t elementType, uint8_t *spriteIndex, uint8_t *spriteSize)
{
*spriteSize = 0;
@ -3012,12 +3012,92 @@ void SFG_drawWeapon(int16_t bobOffset)
SFG_WEAPON_IMAGE_SCALE);
}
void SFG_drawMenu()
{
#define BACKGROUND_SCALE (SFG_GAME_RESOLUTION_X / (4 * SFG_TEXTURE_SIZE ) )
#if BACKGROUND_SCALE == 0
#define BACKGROUND_SCALE 1
#endif
#define SCROLL_PIXELS_PER_FRAME ((64 * SFG_GAME_RESOLUTION_X) / (8 * SFG_FPS))
#if SCROLL_PIXELS_PER_FRAME == 0
#define SCROLL_PIXELS_PER_FRAME 1
#endif
#define MAX_ITEMS 8
#define CHAR_SIZE (SFG_FONT_SIZE_MEDIUM * (SFG_FONT_CHARACTER_SIZE + 1))
uint16_t scroll = (SFG_game.frame * SCROLL_PIXELS_PER_FRAME) / 64;
for (uint16_t y = 0; y < SFG_GAME_RESOLUTION_Y; ++y)
for (uint16_t x = 0; x < SFG_GAME_RESOLUTION_X; ++x)
SFG_setGamePixel(x,y,
(y >= (SFG_TEXTURE_SIZE * BACKGROUND_SCALE)) ? 0 :
SFG_getTexel(SFG_backgroundImages[0],((x + scroll) / BACKGROUND_SCALE)
% SFG_TEXTURE_SIZE,y / BACKGROUND_SCALE));
char *itemTexts[MAX_ITEMS];
for (uint8_t i = 0; i < MAX_ITEMS; ++i)
itemTexts[i] = 0;
itemTexts[0] = "continue";
itemTexts[1] = "map";
itemTexts[2] = "play level 1";
itemTexts[3] = "load";
itemTexts[4] = "sound on";
itemTexts[5] = "exit";
uint16_t y = CHAR_SIZE;
SFG_blitImage(SFG_logoImage, SFG_GAME_RESOLUTION_X / 2 - 16 * SFG_FONT_SIZE_MEDIUM,
y,SFG_FONT_SIZE_MEDIUM );
y += 32 * SFG_FONT_SIZE_MEDIUM + CHAR_SIZE * 2;
for (uint8_t i = 0; i < MAX_ITEMS; ++i)
{
if (itemTexts[i] == 0)
break;
uint8_t textLen = 0;
while (itemTexts[i][textLen] != 0)
textLen++;
uint16_t drawX = (SFG_GAME_RESOLUTION_X - textLen * CHAR_SIZE) / 2;
//SFG_drawText(itemTexts[i],drawX - 1,y - 1,SFG_FONT_SIZE_MEDIUM,63);
SFG_drawText(itemTexts[i],drawX,y,SFG_FONT_SIZE_MEDIUM,23);
y += CHAR_SIZE + SFG_FONT_SIZE_MEDIUM;
}
#undef CHAR_SIZE
#undef MAX_ITEMS
#undef BACKGROUND_SCALE
#undef SCROLL_PIXELS_PER_FRAME
}
void SFG_draw()
{
#if SFG_BACKGROUND_BLUR != 0
SFG_backgroundBlurIndex = 0;
#endif
SFG_drawMenu();
return;
if (SFG_keyPressed(SFG_KEY_MAP))
{
SFG_drawMap();
@ -3217,14 +3297,14 @@ void SFG_draw()
SFG_drawNumber( // ammo
SFG_player.ammo[SFG_weaponAmmo(SFG_player.weapon)],
SFG_GAME_RESOLUTION_X - SFG_HUD_MARGIN -
SFG_FONT_CHARACTER_SIZE * SFG_FONT_SIZE_MEDIUM * 3,
(SFG_FONT_CHARACTER_SIZE + 1) * SFG_FONT_SIZE_MEDIUM * 3,
TEXT_Y,
SFG_FONT_SIZE_MEDIUM,
4);
for (uint8_t i = 0; i < 3; ++i) // access cards
if (SFG_player.cards & (1 << i))
SFG_drawText(",",SFG_HUD_MARGIN + SFG_FONT_CHARACTER_SIZE *
SFG_drawText(",",SFG_HUD_MARGIN + (SFG_FONT_CHARACTER_SIZE + 1) *
SFG_FONT_SIZE_MEDIUM * (6 + i),
TEXT_Y,SFG_FONT_SIZE_MEDIUM,i == 0 ? 93 : (i == 1 ? 124 : 60));