Start assets
This commit is contained in:
parent
7bb028fad4
commit
13a4c0d807
4 changed files with 50 additions and 4 deletions
6
TODO.txt
6
TODO.txt
|
@ -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:
|
TOTAL SIZE OF TEXTURES:
|
||||||
- 64 x 64 x 2 = 8192, 6 x floor + 2 x wall + 1 x car = 8 * 8192 = 73728
|
- 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
|
- (128 x 128 x 1) x 3 background = 49152
|
||||||
|
|
3
assets.h
3
assets.h
|
@ -3,8 +3,7 @@
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#define LCR_SKY_IMAGE_SIZE 128
|
||||||
|
|
||||||
|
|
||||||
static const uint16_t LCR_skyImages[] =
|
static const uint16_t LCR_skyImages[] =
|
||||||
{
|
{
|
||||||
|
|
40
game.h
40
game.h
|
@ -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;
|
const uint16_t *pixel = LCR_skyImages + 256;
|
||||||
uint8_t odd = 1;
|
uint8_t odd = 1;
|
||||||
|
|
||||||
|
@ -138,6 +173,7 @@ void LCR_drawSky()
|
||||||
pixel++;
|
pixel++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +182,7 @@ uint8_t LCR_gameStep(uint32_t time)
|
||||||
for (int i = 0; i < LCR_KEYS_TOTAL; ++i)
|
for (int i = 0; i < LCR_KEYS_TOTAL; ++i)
|
||||||
_LCR_keyStates[i] = LCR_keyPressed(i);
|
_LCR_keyStates[i] = LCR_keyPressed(i);
|
||||||
|
|
||||||
LCR_drawSky();
|
LCR_drawSkyStrip();
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,11 @@
|
||||||
#define LCR_SETTING_RESOLUTION_SUBDIVIDE 1
|
#define LCR_SETTING_RESOLUTION_SUBDIVIDE 1
|
||||||
#endif
|
#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
|
#ifndef LCR_SETTING_MAP_MAX_SIZE
|
||||||
/** Maximum number of blocks a map can consist of, decreasing will save RAM
|
/** Maximum number of blocks a map can consist of, decreasing will save RAM
|
||||||
but also rule out loading bigger maps. */
|
but also rule out loading bigger maps. */
|
||||||
|
|
Loading…
Reference in a new issue