Fix visibility

This commit is contained in:
Miloslav Číž 2020-11-14 12:01:49 +01:00
parent 8ed09615c7
commit a634519a16
4 changed files with 55 additions and 5 deletions

15
game.h
View File

@ -353,7 +353,8 @@ struct
uint8_t soundsPlayedThisFrame; /**< Each bit says whether given sound was
played this frame, prevents playing too many
sounds at once. */
RCL_RayConstraints rayConstraints;
RCL_RayConstraints rayConstraints; ///< Ray constraints for rendering.
RCL_RayConstraints visibilityRayConstraints; ///< Constraints for visibility.
uint8_t keyStates[SFG_KEY_COUNT]; /**< Pressed states of keys, each value
stores the number of frames for which the
key has been held. */
@ -1662,6 +1663,12 @@ void SFG_init()
SFG_game.rayConstraints.maxHits = SFG_RAYCASTING_MAX_HITS;
SFG_game.rayConstraints.maxSteps = SFG_RAYCASTING_MAX_STEPS;
RCL_initRayConstraints(&SFG_game.visibilityRayConstraints);
SFG_game.visibilityRayConstraints.maxHits =
SFG_RAYCASTING_VISIBILITY_MAX_HITS;
SFG_game.visibilityRayConstraints.maxSteps =
SFG_RAYCASTING_VISIBILITY_MAX_STEPS;
SFG_game.antiSpam = 0;
SFG_LOG("computing average texture colors")
@ -1734,6 +1741,10 @@ void SFG_init()
SFG_game.save[0] = SFG_NUMBER_OF_LEVELS - 1; // revealed all levels
}
#if SFG_ALL_LEVELS
SFG_game.save[0] = SFG_NUMBER_OF_LEVELS - 1;
#endif
SFG_setMusic((SFG_game.settings & 0x02) ?
SFG_MUSIC_TURN_ON : SFG_MUSIC_TURN_OFF);
@ -2868,7 +2879,7 @@ static inline uint8_t SFG_spriteIsVisible(RCL_Vector2D pos, RCL_Unit height,
height,
SFG_floorHeightAt,
SFG_ceilingHeightAt,
SFG_game.rayConstraints
SFG_game.visibilityRayConstraints
) == RCL_UNITS_PER_SQUARE;
}

View File

@ -257,12 +257,13 @@
<ul>
<li><a href="">GNU/Linux SDL</a></li>
<li><a href="">GNU/Linux SDL LQ</a></li>
<li><a href="">GNU/Linux CSFML</a></li>
<li><a href="">play in browser</a></li>
<li><a href="">Pokitto</a></li>
<li><a href="">GB Meta</a></li>
<li><a href="">M$ Win$hit XP SDL</a></li>
<li><a href="">source code</a></li>
<li><a href="https://gitlab.com/drummyfish/anarch/-/archive/master/anarch-master.zip">source code</a></li>
</ul>
<h2>Explore</h2>

View File

@ -26,11 +26,13 @@
// #define SFG_START_LEVEL 1
#define SFG_IMMORTAL 1
#define SFG_UNLOCK_DOOR 1
#define SFG_ALL_LEVELS 1
// #define SFG_UNLOCK_DOOR 1
// #define SFG_REVEAL_MAP 1
// #define SFG_INFINITE_AMMO 1
// #define SFG_TIME_MULTIPLIER 512
// #define SFG_CPU_LOAD(percent) printf("CPU load: %d%\n",percent);
#define GAME_LQ
#ifndef __EMSCRIPTEN__
#ifndef GAME_LQ
@ -53,6 +55,8 @@
#define SFG_DIMINISH_SPRITES 0
#define SFG_DITHERED_SHADOW 0
#define SFG_BACKGROUND_BLUR 0
#define SFG_RAYCASTING_MAX_STEPS 20
#define SFG_RAYCASTING_MAX_HITS 8
#endif
#else
// emscripten
@ -63,6 +67,8 @@
#define SFG_RESOLUTION_SCALEDOWN 2
#define SFG_DITHERED_SHADOW 1
#define SFG_BACKGROUND_BLUR 0
#define SFG_RAYCASTING_MAX_STEPS 20
#define SFG_RAYCASTING_MAX_HITS 8
#include <emscripten.h>
#endif

View File

@ -164,6 +164,30 @@
#define SFG_RAYCASTING_MAX_HITS 10
#endif
/**
Same as SFG_RAYCASTING_MAX_STEPS but for visibility rays that are used to
check whether sprites are visible etc.
*/
#ifndef SFG_RAYCASTING_VISIBILITY_MAX_STEPS
#if SFG_RAYCASTING_MAX_STEPS < 15
#define SFG_RAYCASTING_VISIBILITY_MAX_STEPS 15
#else
#define SFG_RAYCASTING_VISIBILITY_MAX_STEPS SFG_RAYCASTING_MAX_STEPS
#endif
#endif
/**
Same as SFG_RAYCASTING_MAX_HITS but for visibility rays that are used to check
whether sprites are visible etc.
*/
#ifndef SFG_RAYCASTING_VISIBILITY_MAX_HITS
#if SFG_RAYCASTING_MAX_HITS < 6
#define SFG_RAYCASTING_VISIBILITY_MAX_HITS 6
#else
#define SFG_RAYCASTING_VISIBILITY_MAX_HITS SFG_RAYCASTING_MAX_HITS
#endif
#endif
/**
How many times rendering should be subsampled horizontally. Bigger number
can significantly improve performance (by casting fewer rays), but can look
@ -396,7 +420,8 @@
look weirdly scaled, so this option can be used to fix that.
*/
#ifndef SFG_SPRITE_MAX_SIZE
#define SFG_SPRITE_MAX_SIZE SFG_SCREEN_RESOLUTION_Y
#define SFG_SPRITE_MAX_SIZE \
(SFG_SCREEN_RESOLUTION_Y / SFG_RESOLUTION_SCALEDOWN)
#endif
/**
@ -422,6 +447,13 @@
#define SFG_IMMORTAL 0
#endif
/**
Reveals all levels to be played.
*/
#ifndef SFG_ALL_LEVELS
#define SFG_ALL_LEVELS 0
#endif
/**
Turn on for previes mode for map editing (flying, noclip, fast movement etc.).
*/