From 1ca9e371e43220cc4f5d805c495afa9aa4a88413 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20=C4=8C=C3=AD=C5=BE?= Date: Thu, 27 Feb 2020 16:13:19 +0100 Subject: [PATCH] Fix sprite size --- constants.h | 10 ++++++---- main.c | 16 +++++++++------- settings.h | 4 ++-- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/constants.h b/constants.h index 98f8501..7ee68b6 100644 --- a/constants.h +++ b/constants.h @@ -86,7 +86,7 @@ Distance at which level elements (sprites) collide, in RCL_Unit (1024 per square). */ -#define SFG_ELEMENT_COLLISION_RADIUS 1500 +#define SFG_ELEMENT_COLLISION_RADIUS 1900 /** Height, in RCL_Units, at which collisions happen with level elements @@ -176,6 +176,11 @@ */ #define SFG_WIN_ANIMATION_DURATION 2500 +/** + Vertical sprite size, in RCL_Units. +*/ +#define SFG_BASE_SPRITE_SIZE RCL_UNITS_PER_SQUARE + // ---------------------------- // derived constants @@ -187,9 +192,6 @@ #define SFG_MS_PER_FRAME (1000 / SFG_FPS) // ms per frame with target FPS -#define SFG_BASE_SPRITE_SIZE \ - (SFG_GAME_RESOLUTION_Y) - #if SFG_MS_PER_FRAME == 0 #define SFG_MS_PER_FRAME 1 #endif diff --git a/main.c b/main.c index ccdc4f4..f05eb17 100755 --- a/main.c +++ b/main.c @@ -151,9 +151,11 @@ typedef struct #define SFG_SPRITE_SIZE(size0to3) \ (((size0to3 + 3) * SFG_BASE_SPRITE_SIZE) / 4) +#define SFG_SPRITE_SIZE_PIXELS(size0to3) \ + ((SFG_SPRITE_SIZE(size0to3) * SFG_GAME_RESOLUTION_Y) / RCL_UNITS_PER_SQUARE) + #define SFG_SPRITE_SIZE_TO_HEIGHT_ABOVE_GROUND(size0to3) \ - ((SFG_SPRITE_SIZE(size0to3) * 2) / 3) - // ^TODO: why 3/4 and not 1/2? + (SFG_SPRITE_SIZE(size0to3) / 2) /** Holds information about one instance of a level item (a type of level element, @@ -3636,7 +3638,7 @@ void SFG_draw() SFG_drawScaledSprite(s, p.position.x * SFG_RAYCASTING_SUBSAMPLE,p.position.y, RCL_perspectiveScale( - SFG_SPRITE_SIZE(spriteSize), + SFG_SPRITE_SIZE_PIXELS(spriteSize), p.depth), p.depth / (RCL_UNITS_PER_SQUARE * 2),p.depth); } @@ -3678,7 +3680,7 @@ void SFG_draw() SFG_drawScaledSprite( sprite, p.position.x * SFG_RAYCASTING_SUBSAMPLE,p.position.y, - RCL_perspectiveScale(SFG_SPRITE_SIZE(spriteSize),p.depth), + RCL_perspectiveScale(SFG_SPRITE_SIZE_PIXELS(spriteSize),p.depth), p.depth / (RCL_UNITS_PER_SQUARE * 2),p.depth); } } @@ -3702,7 +3704,7 @@ void SFG_draw() const uint8_t *s = SFG_effectSprites[proj->type]; - int16_t spriteSize = SFG_SPRITE_SIZE(0); + int16_t spriteSize = SFG_SPRITE_SIZE_PIXELS(0); if (proj->type == SFG_PROJECTILE_EXPLOSION || proj->type == SFG_PROJECTILE_DUST) @@ -3710,10 +3712,10 @@ void SFG_draw() int16_t doubleFramesToLive = RCL_nonZero(SFG_GET_PROJECTILE_FRAMES_TO_LIVE(proj->type) / 2); - // grow the explosion sprite as an animation + // grow the explosion/dust sprite as an animation spriteSize = ( - SFG_BASE_SPRITE_SIZE * + SFG_SPRITE_SIZE_PIXELS(2) * RCL_sinInt( ((doubleFramesToLive - proj->doubleFramesToLive) * RCL_UNITS_PER_SQUARE / 4) diff --git a/settings.h b/settings.h index 987f09b..84af689 100644 --- a/settings.h +++ b/settings.h @@ -187,7 +187,7 @@ /** Developer cheat for immortality. */ -#define SFG_IMMORTAL 0 +#define SFG_IMMORTAL 1 /** Turn on for previes mode for map editing (flying, noclip, fast movement etc.). @@ -203,6 +203,6 @@ Skips menu and starts given level immediatelly, for development. 0 means this options is ignored, 1 means load level 1 etc. */ -#define SFG_START_LEVEL 5 +#define SFG_START_LEVEL 0 #endif // guard