Tune constants

This commit is contained in:
Miloslav Číž 2020-02-23 11:45:32 +01:00
parent e6367982b1
commit 840a3b0d57
2 changed files with 27 additions and 21 deletions

View File

@ -24,7 +24,7 @@
/** /**
How quickly player moves, in squares per second. How quickly player moves, in squares per second.
*/ */
#define SFG_PLAYER_MOVE_SPEED 10 #define SFG_PLAYER_MOVE_SPEED 7
/** /**
Gravity acceleration in squares / (second^2). Gravity acceleration in squares / (second^2).
@ -86,7 +86,7 @@
Distance at which level elements (sprites) collide, in RCL_Unit (1024 per Distance at which level elements (sprites) collide, in RCL_Unit (1024 per
square). square).
*/ */
#define SFG_ELEMENT_COLLISION_DISTANCE 2500 #define SFG_ELEMENT_COLLISION_RADIUS 1500
/** /**
Height, in RCL_Units, at which collisions happen with level elements Height, in RCL_Units, at which collisions happen with level elements
@ -98,7 +98,7 @@
Distance at which explosion does damage and throws away the player and Distance at which explosion does damage and throws away the player and
monsters, in RCL_Units. monsters, in RCL_Units.
*/ */
#define SFG_EXPLOSION_DISTANCE 2048 #define SFG_EXPLOSION_RADIUS 2048
/** /**
How much damage triggers a barrel explosion. How much damage triggers a barrel explosion.

42
main.c
View File

@ -1102,7 +1102,10 @@ RCL_Unit SFG_ceilingHeightAt(int16_t x, int16_t y)
SFG_game.frameTime - SFG_currentLevel.timeStart); SFG_game.frameTime - SFG_currentLevel.timeStart);
} }
void SFG_getLevelElementSprite( // TODO: this is just for items -- rename? /**
Gets sprite (image and sprite size) for given item.
*/
void SFG_getItemSprite(
uint8_t elementType, uint8_t *spriteIndex, uint8_t *spriteSize) uint8_t elementType, uint8_t *spriteIndex, uint8_t *spriteSize)
{ {
*spriteSize = 0; *spriteSize = 0;
@ -1134,7 +1137,10 @@ void SFG_getLevelElementSprite( // TODO: this is just for items -- rename?
} }
} }
uint8_t SFG_levelElementCollides(uint8_t elementType) // TODO: better name? /**
Says whether given item type collides, i.e. stops player from moving.
*/
uint8_t SFG_itemCollides(uint8_t elementType)
{ {
return return
elementType == SFG_LEVEL_ELEMENT_BARREL || elementType == SFG_LEVEL_ELEMENT_BARREL ||
@ -1243,7 +1249,7 @@ void SFG_setAndInitLevel(const SFG_Level *level)
if (e->type == SFG_LEVEL_ELEMENT_TELEPORT) if (e->type == SFG_LEVEL_ELEMENT_TELEPORT)
SFG_currentLevel.teleportCount++; SFG_currentLevel.teleportCount++;
if (SFG_levelElementCollides(e->type)) if (SFG_itemCollides(e->type))
SFG_setItemCollisionMapBit(e->coords[0],e->coords[1],1); SFG_setItemCollisionMapBit(e->coords[0],e->coords[1],1);
} }
else else
@ -1628,7 +1634,7 @@ void SFG_createExplosion(RCL_Unit x, RCL_Unit y, RCL_Unit z)
uint8_t damage = SFG_getDamageValue(SFG_WEAPON_FIRE_TYPE_FIREBALL); uint8_t damage = SFG_getDamageValue(SFG_WEAPON_FIRE_TYPE_FIREBALL);
if (SFG_pushPlayerAway(x,y,SFG_EXPLOSION_DISTANCE)) if (SFG_pushPlayerAway(x,y,SFG_EXPLOSION_RADIUS))
SFG_playerChangeHealth(-1 * damage); SFG_playerChangeHealth(-1 * damage);
for (uint16_t i = 0; i < SFG_currentLevel.monsterRecordCount; ++i) for (uint16_t i = 0; i < SFG_currentLevel.monsterRecordCount; ++i)
@ -1647,7 +1653,7 @@ void SFG_createExplosion(RCL_Unit x, RCL_Unit y, RCL_Unit z)
if (SFG_taxicabDistance( if (SFG_taxicabDistance(
SFG_MONSTER_COORD_TO_RCL_UNITS(monster->coords[0]), SFG_MONSTER_COORD_TO_RCL_UNITS(monster->coords[0]),
SFG_MONSTER_COORD_TO_RCL_UNITS(monster->coords[1]),monsterHeight, SFG_MONSTER_COORD_TO_RCL_UNITS(monster->coords[1]),monsterHeight,
x,y,z) <= SFG_EXPLOSION_DISTANCE) x,y,z) <= SFG_EXPLOSION_RADIUS)
{ {
SFG_monsterChangeHealth(monster, SFG_monsterChangeHealth(monster,
-1 * SFG_getDamageValue(SFG_WEAPON_FIRE_TYPE_FIREBALL)); -1 * SFG_getDamageValue(SFG_WEAPON_FIRE_TYPE_FIREBALL));
@ -1679,7 +1685,7 @@ void SFG_createExplosion(RCL_Unit x, RCL_Unit y, RCL_Unit z)
SFG_floorHeightAt(element.coords[0],element.coords[1]); SFG_floorHeightAt(element.coords[0],element.coords[1]);
if (SFG_taxicabDistance( if (SFG_taxicabDistance(
x,y,z,elementX,elementY,elementHeight) <= SFG_EXPLOSION_DISTANCE) x,y,z,elementX,elementY,elementHeight) <= SFG_EXPLOSION_RADIUS)
{ {
SFG_explodeBarrel(i,elementX,elementY,elementHeight); SFG_explodeBarrel(i,elementX,elementY,elementHeight);
i--; i--;
@ -1996,7 +2002,7 @@ static inline uint8_t SFG_elementCollides(
{ {
return return
SFG_taxicabDistance(pointX,pointY,pointZ,elementX,elementY,elementHeight) SFG_taxicabDistance(pointX,pointY,pointZ,elementX,elementY,elementHeight)
<= SFG_ELEMENT_COLLISION_DISTANCE; <= SFG_ELEMENT_COLLISION_RADIUS;
} }
/** /**
@ -2739,7 +2745,8 @@ void SFG_gameStepPlaying()
uint8_t collidesWithTeleport = 0; uint8_t collidesWithTeleport = 0;
// items: /* item collisions with player (only those that don't stop player's movement
-- these are handled differently, via itemCollisionMap): */
for (int16_t i = 0; i < SFG_currentLevel.itemRecordCount; ++i) for (int16_t i = 0; i < SFG_currentLevel.itemRecordCount; ++i)
// ^ has to be int16_t (signed) // ^ has to be int16_t (signed)
{ {
@ -2755,15 +2762,14 @@ void SFG_gameStepPlaying()
ePos.x = SFG_ELEMENT_COORD_TO_RCL_UNITS(e->coords[0]); ePos.x = SFG_ELEMENT_COORD_TO_RCL_UNITS(e->coords[0]);
ePos.y = SFG_ELEMENT_COORD_TO_RCL_UNITS(e->coords[1]); ePos.y = SFG_ELEMENT_COORD_TO_RCL_UNITS(e->coords[1]);
if ( if (!SFG_itemCollides(e->type) &&
SFG_elementCollides( SFG_elementCollides(
SFG_player.camera.position.x, SFG_player.camera.position.x,
SFG_player.camera.position.y, SFG_player.camera.position.y,
SFG_player.camera.height, SFG_player.camera.height,
ePos.x, ePos.x,
ePos.y, ePos.y,
SFG_floorHeightAt(e->coords[0],e->coords[1]) SFG_floorHeightAt(e->coords[0],e->coords[1]))
)
) )
{ {
uint8_t eliminate = 1; uint8_t eliminate = 1;
@ -3636,7 +3642,7 @@ void SFG_draw()
uint8_t spriteIndex; uint8_t spriteIndex;
uint8_t spriteSize; uint8_t spriteSize;
SFG_getLevelElementSprite(e.type,&spriteIndex,&spriteSize); SFG_getItemSprite(e.type,&spriteIndex,&spriteSize);
RCL_PixelInfo p = RCL_PixelInfo p =
RCL_mapToScreen( RCL_mapToScreen(