This commit is contained in:
Miloslav Ciz 2023-09-12 17:39:55 +02:00
parent 13a4c0d807
commit d7194d9183
2 changed files with 31 additions and 36 deletions

62
game.h
View file

@ -118,21 +118,21 @@ void LCR_gameEnd(void)
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;
finalY = (finalY / LCR_SETTING_SKY_SIZE) * LCR_SETTING_SKY_SIZE;
if (finalY >= LCR_EFFECTIVE_RESOLUTION_Y)
finalY = LCR_EFFECTIVE_RESOLUTION_Y - 1;
unsigned int skyY = 0;
const uint16_t *skyLine = LCR_skyImages + 256;
if (verticalOffset < 0)
{
skyY = -1 * verticalOffset;
skyLine += (-1 * verticalOffset / LCR_SETTING_SKY_SIZE) * (LCR_SKY_IMAGE_SIZE / 2);
verticalOffset = 0;
}
@ -140,49 +140,43 @@ void LCR_drawSkyStrip(int verticalOffset, uint8_t horizontalOffset)
{
for (int i = 0; i < LCR_EFFECTIVE_RESOLUTION_X; ++i)
{
LCR_drawPixelUnsafe(x,y,10000);
// TODO: check z-buffer
int offsetX = (i / LCR_SETTING_SKY_SIZE + horizontalOffset)
% LCR_SKY_IMAGE_SIZE;
uint16_t pixel = *(skyLine + offsetX / 2);
pixel = offsetX % 2 ? (pixel >> 8) : (pixel & 0x00ff);
LCR_drawPixelUnsafe(i,verticalOffset,LCR_skyImages[pixel]);
}
skyY++;
verticalOffset++;
if (verticalOffset % LCR_SETTING_SKY_SIZE == 0)
skyLine += LCR_SKY_IMAGE_SIZE / 2;
}
#endif
/*
const uint16_t *pixel = LCR_skyImages + 256;
uint8_t odd = 1;
for (int y = 0; y < 128; ++y)
for (int x = 0; x < 128; ++x)
{
LCR_drawPixelUnsafe(x,y,
LCR_skyImages[
odd ? (*pixel & 0x00ff) : (*pixel >> 8) ]
);
if (odd)
odd = 0;
else
{
odd = 1;
pixel++;
}
}
*/
}
int aaa = 0;
uint8_t LCR_gameStep(uint32_t time)
{
for (int i = 0; i < LCR_EFFECTIVE_RESOLUTION_X; ++i)
for (int j = 0; j < LCR_EFFECTIVE_RESOLUTION_Y; ++j)
LCR_drawPixelUnsafe(i,j,0);
for (int i = 0; i < LCR_KEYS_TOTAL; ++i)
_LCR_keyStates[i] = LCR_keyPressed(i);
LCR_drawSkyStrip();
LCR_drawSkyStrip(200 + aaa / 10,aaa / 30);
aaa = (aaa + 1) % 10000;
return 1;
}

View file

@ -15,8 +15,9 @@
#ifndef LCR_SETTING_SKY_SIZE
/** Size of sky texture pixel, 0 turns off sky rendering. */
#define LCR_SETTING_SKY_SIZE 1
#define
#define LCR_SETTING_SKY_SIZE \
(LCR_SETTING_RESOLUTION_X / 256 * LCR_SETTING_RESOLUTION_SUBDIVIDE)
#endif
#ifndef LCR_SETTING_MAP_MAX_SIZE
/** Maximum number of blocks a map can consist of, decreasing will save RAM