Add bob shear

This commit is contained in:
Miloslav Číž 2020-10-03 23:38:33 +02:00
parent a19b9fd07b
commit 1bef03bf72
3 changed files with 29 additions and 3 deletions

18
game.h
View File

@ -4301,7 +4301,7 @@ void SFG_drawMenu()
if (item == SFG_MENU_ITEM_NONE)
break;
# if SFG_GAME_RESOLUTION_Y < 70
#if SFG_GAME_RESOLUTION_Y < 70
// with low resolution only display the selected item
if (i != SFG_game.selectedMenuItem)
@ -4504,12 +4504,21 @@ void SFG_draw()
#if SFG_HEADBOB_ENABLED
RCL_Unit headBobOffset = 0;
#if SFG_HEADBOB_SHEAR != 0
int16_t headBobShearOffset;
#endif
if (SFG_game.state != SFG_GAME_STATE_LOSE)
{
RCL_Unit bobSin = RCL_sin(SFG_player.headBobFrame);
headBobOffset = (bobSin * SFG_HEADBOB_OFFSET) / RCL_UNITS_PER_SQUARE;
#if SFG_HEADBOB_SHEAR != 0
headBobShearOffset = (bobSin * SFG_HEADBOB_SHEAR) / RCL_UNITS_PER_SQUARE;
SFG_player.camera.shear += headBobShearOffset;
#endif
weaponBobOffset =
(bobSin * SFG_WEAPONBOB_OFFSET_PIXELS) / (RCL_UNITS_PER_SQUARE) +
SFG_WEAPONBOB_OFFSET_PIXELS;
@ -4527,7 +4536,7 @@ void SFG_draw()
// add head bob just for the rendering (we'll will substract it back later)
SFG_player.camera.height += headBobOffset;
#endif
#endif // headbob enabled?
RCL_renderComplex(
SFG_player.camera,
@ -4673,8 +4682,13 @@ void SFG_draw()
#if SFG_HEADBOB_ENABLED
// after rendering sprites substract back the head bob offset
SFG_player.camera.height -= headBobOffset;
#if SFG_HEADBOB_SHEAR != 0
SFG_player.camera.shear -= headBobShearOffset;
#endif
#endif // head bob enabled?
#if SFG_PREVIEW_MODE == 0
SFG_drawWeapon(weaponBobOffset);
#endif

View File

@ -33,6 +33,9 @@
#define SFG_REVEAL_MAP 1
// #define SFG_INFINITE_AMMO 1
#define SFG_SCREEN_RESOLUTION_X 800
#define SFG_SCREEN_RESOLUTION_Y 600
// #define SFG_SCREEN_RESOLUTION_X 88
// #define SFG_SCREEN_RESOLUTION_Y 110
@ -45,6 +48,7 @@
*/
#define SFG_PLAYER_DAMAGE_MULTIPLIER 1024
#define SFG_DITHERED_SHADOW 1
#define SFG_HEADBOB_SHEAR (-1 * SFG_SCREEN_RESOLUTION_Y / 80)
#define MUSIC_VOLUME 64

View File

@ -69,7 +69,7 @@
/**
How quickly player turns left/right, in degrees per second.
*/
#define SFG_PLAYER_TURN_SPEED 210
#define SFG_PLAYER_TURN_SPEED 180
/**
Distance, in RCL_Units, to which textures will be drawn. Textures behind this
@ -177,6 +177,14 @@
#define SFG_HEADBOB_OFFSET 200
#endif
/**
If head bob is on, this additionally sets additional camera shear bob, in
pixels, which can make bobbing look more "advanced". 0 turns this option off.
*/
#ifndef SFG_HEADBOB_SHEAR
#define SFG_HEADBOB_SHEAR 0
#endif
/**
Weapon bobbing offset in weapon image pixels.
*/