Update level

This commit is contained in:
Miloslav Číž 2020-09-27 21:19:08 +02:00
parent b9b5b94976
commit 892d2443ba
5 changed files with 18 additions and 13 deletions

View File

@ -1,5 +1,6 @@
general: general:
- Refactor.
- Rewrite python scripts to C (faster, less bloat). - Rewrite python scripts to C (faster, less bloat).
- Try to recolor textures and give them a bit more of variety. - Try to recolor textures and give them a bit more of variety.
- automatic tests: a frontend that will play the game, check the state, rendered - automatic tests: a frontend that will play the game, check the state, rendered

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

20
game.h
View File

@ -969,7 +969,7 @@ void SFG_pixelFunc(RCL_PixelInfo *pixel)
RCL_Unit screenX = pixel->position.x * SFG_RAYCASTING_SUBSAMPLE; RCL_Unit screenX = pixel->position.x * SFG_RAYCASTING_SUBSAMPLE;
for (uint8_t i = 0; i < SFG_RAYCASTING_SUBSAMPLE; ++i) for (int_fast8_t i = 0; i < SFG_RAYCASTING_SUBSAMPLE; ++i)
{ {
SFG_setGamePixel(screenX,pixel->position.y,color); SFG_setGamePixel(screenX,pixel->position.y,color);
screenX++; screenX++;
@ -3968,8 +3968,8 @@ void SFG_drawMap()
} }
} }
for (uint16_t k = 0; k < SFG_MAP_PIXEL_SIZE; ++k) for (int_fast16_t k = 0; k < SFG_MAP_PIXEL_SIZE; ++k)
for (uint16_t l = 0; l < SFG_MAP_PIXEL_SIZE; ++l) for (int_fast16_t l = 0; l < SFG_MAP_PIXEL_SIZE; ++l)
SFG_setGamePixel(x + l, y + k,color); SFG_setGamePixel(x + l, y + k,color);
x += SFG_MAP_PIXEL_SIZE; x += SFG_MAP_PIXEL_SIZE;
@ -4084,11 +4084,11 @@ uint8_t SFG_drawNumber(
*/ */
void SFG_drawIndicationBorder(uint16_t width, uint8_t color) void SFG_drawIndicationBorder(uint16_t width, uint8_t color)
{ {
for (uint16_t j = 0; j < width; ++j) for (int_fast16_t j = 0; j < width; ++j)
{ {
uint16_t j2 = SFG_GAME_RESOLUTION_Y - 1 - j; uint16_t j2 = SFG_GAME_RESOLUTION_Y - 1 - j;
for (uint16_t i = 0; i < SFG_GAME_RESOLUTION_X; ++i) for (int_fast16_t i = 0; i < SFG_GAME_RESOLUTION_X; ++i)
{ {
if ((i & 0x01) == (j & 0x01)) if ((i & 0x01) == (j & 0x01))
{ {
@ -4098,11 +4098,11 @@ void SFG_drawIndicationBorder(uint16_t width, uint8_t color)
} }
} }
for (uint16_t i = 0; i < width; ++i) for (int_fast16_t i = 0; i < width; ++i)
{ {
uint16_t i2 = SFG_GAME_RESOLUTION_X - 1 - i; uint16_t i2 = SFG_GAME_RESOLUTION_X - 1 - i;
for (uint16_t j = width; j < SFG_GAME_RESOLUTION_Y - width; ++j) for (int_fast16_t j = width; j < SFG_GAME_RESOLUTION_Y - width; ++j)
{ {
if ((i & 0x01) == (j & 0x01)) if ((i & 0x01) == (j & 0x01))
{ {
@ -4421,7 +4421,7 @@ void SFG_draw()
} }
else else
{ {
for (uint16_t i = 0; i < SFG_Z_BUFFER_SIZE; ++i) for (int_fast16_t i = 0; i < SFG_Z_BUFFER_SIZE; ++i)
SFG_game.zBuffer[i] = 255; SFG_game.zBuffer[i] = 255;
int16_t weaponBobOffset = 0; int16_t weaponBobOffset = 0;
@ -4464,7 +4464,7 @@ void SFG_draw()
// draw sprites: // draw sprites:
// monster sprites: // monster sprites:
for (uint16_t i = 0; i < SFG_currentLevel.monsterRecordCount; ++i) for (int_fast16_t i = 0; i < SFG_currentLevel.monsterRecordCount; ++i)
{ {
SFG_MonsterRecord m = SFG_currentLevel.monsterRecords[i]; SFG_MonsterRecord m = SFG_currentLevel.monsterRecords[i];
@ -4510,7 +4510,7 @@ void SFG_draw()
} }
// item sprites: // item sprites:
for (uint16_t i = 0; i < SFG_currentLevel.itemRecordCount; ++i) for (int_fast16_t i = 0; i < SFG_currentLevel.itemRecordCount; ++i)
if (SFG_currentLevel.itemRecords[i] & SFG_ITEM_RECORD_ACTIVE_MASK) if (SFG_currentLevel.itemRecords[i] & SFG_ITEM_RECORD_ACTIVE_MASK)
{ {
RCL_Vector2D worldPosition; RCL_Vector2D worldPosition;

View File

@ -28,10 +28,10 @@
#define SFG_LOG(str) puts(str); #define SFG_LOG(str) puts(str);
// #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
// #define SFG_SCREEN_RESOLUTION_X 80 // #define SFG_SCREEN_RESOLUTION_X 80
// #define SFG_SCREEN_RESOLUTION_Y 64 // #define SFG_SCREEN_RESOLUTION_Y 64
@ -417,7 +417,11 @@ int main(int argc, char *argv[])
audioSpec.freq = 8000; audioSpec.freq = 8000;
audioSpec.format = AUDIO_U16; audioSpec.format = AUDIO_U16;
audioSpec.channels = 1; audioSpec.channels = 1;
#ifdef __EMSCRIPTEN__
audioSpec.samples = 1024; audioSpec.samples = 1024;
#else
audioSpec.samples = 256;
#endif
if (SDL_OpenAudio(&audioSpec,NULL) < 0) if (SDL_OpenAudio(&audioSpec,NULL) < 0)
puts("SDL: could not initialize audio"); puts("SDL: could not initialize audio");