mirror of
https://gitlab.com/drummyfish/anarch.git
synced 2024-11-21 16:35:08 -05:00
Hurt player
This commit is contained in:
parent
98dc694ba3
commit
2a7528cad0
10
constants.h
10
constants.h
@ -89,6 +89,11 @@
|
||||
*/
|
||||
#define SFG_EXPLOSION_DISTANCE 2048
|
||||
|
||||
/**
|
||||
How much damage explosion causes in its range.
|
||||
*/
|
||||
#define SFG_EXPLOSION_DAMAGE 18
|
||||
|
||||
/**
|
||||
Time, in ms, after which shotgun can be fired again.
|
||||
*/
|
||||
@ -99,4 +104,9 @@
|
||||
*/
|
||||
#define SFG_PLAYER_MAX_HEALTH 100
|
||||
|
||||
/**
|
||||
At which value health indicator shows a warning (red color).
|
||||
*/
|
||||
#define SFG_PLAYER_HEALTH_WARNING_LEVEL 20
|
||||
|
||||
#endif // guard
|
||||
|
23
main.c
23
main.c
@ -1387,6 +1387,21 @@ RCL_Vector2D SFG_resolveCollisionWithElement(
|
||||
return moveOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
Adds or substracts player's health, which either hurts him (negative value)
|
||||
or heals him (positive value).
|
||||
*/
|
||||
void SFG_playerChangeHealth(int8_t healthAdd)
|
||||
{
|
||||
int16_t health = SFG_player.health;
|
||||
|
||||
health += healthAdd;
|
||||
|
||||
health = RCL_clamp(health,0,SFG_PLAYER_MAX_HEALTH);
|
||||
|
||||
SFG_player.health = health;
|
||||
}
|
||||
|
||||
void SFG_createExplosion(RCL_Unit x, RCL_Unit y, RCL_Unit z)
|
||||
{
|
||||
SFG_ProjectileRecord explostion;
|
||||
@ -1405,6 +1420,8 @@ void SFG_createExplosion(RCL_Unit x, RCL_Unit y, RCL_Unit z)
|
||||
|
||||
SFG_createProjectile(explostion);
|
||||
|
||||
SFG_playerChangeHealth(-1 * SFG_EXPLOSION_DAMAGE);
|
||||
|
||||
SFG_pushPlayerAway(x,y,SFG_EXPLOSION_DISTANCE);
|
||||
}
|
||||
|
||||
@ -2343,15 +2360,15 @@ void SFG_draw()
|
||||
|
||||
// draw the HUD:
|
||||
|
||||
SFG_drawNumber(
|
||||
SFG_drawNumber( // health
|
||||
SFG_player.health,
|
||||
SFG_HUD_MARGIN,
|
||||
SFG_GAME_RESOLUTION_Y - SFG_HUD_MARGIN -
|
||||
SFG_FONT_CHARACTER_SIZE * SFG_FONT_SIZE_MEDIUM,
|
||||
SFG_FONT_SIZE_MEDIUM,
|
||||
7);
|
||||
SFG_player.health > SFG_PLAYER_HEALTH_WARNING_LEVEL ? 7 : 175);
|
||||
|
||||
SFG_drawNumber(
|
||||
SFG_drawNumber( // ammo
|
||||
20,
|
||||
SFG_GAME_RESOLUTION_X - SFG_HUD_MARGIN -
|
||||
SFG_FONT_CHARACTER_SIZE * SFG_FONT_SIZE_MEDIUM * 3,
|
||||
|
Loading…
Reference in New Issue
Block a user