Start assets

This commit is contained in:
Miloslav Ciz 2023-09-12 16:42:58 +02:00
parent 7bb028fad4
commit 13a4c0d807
4 changed files with 50 additions and 4 deletions

View file

@ -1,3 +1,9 @@
- background sky rendering efficiently:
- first draw the solid color top and bottom
- then render the 3D scene
- then iterate over the strip that should have the sky texture and only draw
to pixels where depth buffer was not overwritten (this step can be left out
in case we have depth buffer or sky turned off)
TOTAL SIZE OF TEXTURES:
- 64 x 64 x 2 = 8192, 6 x floor + 2 x wall + 1 x car = 8 * 8192 = 73728
- (128 x 128 x 1) x 3 background = 49152

View file

@ -3,8 +3,7 @@
#include <stdint.h>
#define LCR_SKY_IMAGE_SIZE 128
static const uint16_t LCR_skyImages[] =
{

40
game.h
View file

@ -116,8 +116,43 @@ void LCR_gameEnd(void)
{
}
void LCR_drawSky()
void LCR_drawSkyStrip(int verticalOffset, uint8_t horizontalOffset)
{
#if LCR_SETTING_SKY_SIZE != 0
verticalOffset -= (LCR_SETTING_SKY_SIZE * LCR_SKY_IMAGE_SIZE) / 2;
int finalY = verticalOffset + LCR_SETTING_SKY_SIZE * LCR_SKY_IMAGE_SIZE;
if (finalY >= LCR_EFFECTIVE_RESOLUTION_Y)
finalY = LCR_EFFECTIVE_RESOLUTION_Y - 1;
unsigned int skyY = 0;
if (verticalOffset < 0)
{
skyY = -1 * verticalOffset;
verticalOffset = 0;
}
while (verticalOffset < finalY)
{
for (int i = 0; i < LCR_EFFECTIVE_RESOLUTION_X; ++i)
{
LCR_drawPixelUnsafe(x,y,10000);
}
skyY++;
verticalOffset++;
}
#endif
/*
const uint16_t *pixel = LCR_skyImages + 256;
uint8_t odd = 1;
@ -138,6 +173,7 @@ void LCR_drawSky()
pixel++;
}
}
*/
}
@ -146,7 +182,7 @@ uint8_t LCR_gameStep(uint32_t time)
for (int i = 0; i < LCR_KEYS_TOTAL; ++i)
_LCR_keyStates[i] = LCR_keyPressed(i);
LCR_drawSky();
LCR_drawSkyStrip();
return 1;
}

View file

@ -13,6 +13,11 @@
#define LCR_SETTING_RESOLUTION_SUBDIVIDE 1
#endif
#ifndef LCR_SETTING_SKY_SIZE
/** Size of sky texture pixel, 0 turns off sky rendering. */
#define LCR_SETTING_SKY_SIZE 1
#define
#ifndef LCR_SETTING_MAP_MAX_SIZE
/** Maximum number of blocks a map can consist of, decreasing will save RAM
but also rule out loading bigger maps. */