mirror of
https://gitlab.com/drummyfish/anarch.git
synced 2024-11-30 20:52:25 -05:00
Animate weapons
This commit is contained in:
parent
a150314eec
commit
5882b68f79
21
main.c
21
main.c
@ -107,6 +107,10 @@ void SFG_init();
|
|||||||
===============================================================================
|
===============================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define SFG_WEAPON_KNIFE 0
|
||||||
|
#define SFG_WEAPON_SHOTGUN 1
|
||||||
|
#define SFG_WEAPON_ROCKER_LAUNCHER 2
|
||||||
|
|
||||||
#define SFG_GAME_RESOLUTION_X \
|
#define SFG_GAME_RESOLUTION_X \
|
||||||
(SFG_SCREEN_RESOLUTION_X / SFG_RESOLUTION_SCALEDOWN)
|
(SFG_SCREEN_RESOLUTION_X / SFG_RESOLUTION_SCALEDOWN)
|
||||||
|
|
||||||
@ -1457,10 +1461,14 @@ void SFG_gameStep()
|
|||||||
|
|
||||||
int8_t shearing = 0;
|
int8_t shearing = 0;
|
||||||
|
|
||||||
if (SFG_keyJustPressed(SFG_KEY_B))
|
if (
|
||||||
|
SFG_keyIsDown(SFG_KEY_B) &&
|
||||||
|
(SFG_gameFrame - SFG_player.lastShotFrame >
|
||||||
|
SFG_WEAPON_SHOTGUN_COOLDOWN_FRAMES))
|
||||||
{
|
{
|
||||||
// fire
|
// fire
|
||||||
|
|
||||||
|
if (SFG_player.weapon == SFG_WEAPON_ROCKER_LAUNCHER)
|
||||||
SFG_launchProjectile(
|
SFG_launchProjectile(
|
||||||
SFG_PROJECTILE_FIREBALL,
|
SFG_PROJECTILE_FIREBALL,
|
||||||
SFG_player.camera.position,
|
SFG_player.camera.position,
|
||||||
@ -2133,6 +2141,9 @@ uint8_t SFG_drawNumber(
|
|||||||
return 5 - position;
|
return 5 - position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Draws the player weapon, handling the shooting animation.
|
||||||
|
*/
|
||||||
void SFG_drawWeapon(int16_t bobOffset)
|
void SFG_drawWeapon(int16_t bobOffset)
|
||||||
{
|
{
|
||||||
uint32_t shotAnimationFrame = SFG_gameFrame - SFG_player.lastShotFrame;
|
uint32_t shotAnimationFrame = SFG_gameFrame - SFG_player.lastShotFrame;
|
||||||
@ -2140,6 +2151,13 @@ void SFG_drawWeapon(int16_t bobOffset)
|
|||||||
uint32_t animationLength = SFG_WEAPON_SHOTGUN_COOLDOWN_FRAMES;
|
uint32_t animationLength = SFG_WEAPON_SHOTGUN_COOLDOWN_FRAMES;
|
||||||
|
|
||||||
if (shotAnimationFrame < animationLength)
|
if (shotAnimationFrame < animationLength)
|
||||||
|
{
|
||||||
|
if (SFG_player.weapon == SFG_WEAPON_KNIFE)
|
||||||
|
{
|
||||||
|
bobOffset = shotAnimationFrame < animationLength / 2 ? 0 :
|
||||||
|
2 * SFG_WEAPONBOB_OFFSET_PIXELS ;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
bobOffset +=
|
bobOffset +=
|
||||||
((animationLength - shotAnimationFrame) * SFG_WEAPON_IMAGE_SCALE * 20)
|
((animationLength - shotAnimationFrame) * SFG_WEAPON_IMAGE_SCALE * 20)
|
||||||
@ -2151,6 +2169,7 @@ void SFG_drawWeapon(int16_t bobOffset)
|
|||||||
SFG_WEAPON_IMAGE_POSITION_Y - (SFG_TEXTURE_SIZE / 3) * SFG_WEAPON_IMAGE_SCALE + bobOffset,
|
SFG_WEAPON_IMAGE_POSITION_Y - (SFG_TEXTURE_SIZE / 3) * SFG_WEAPON_IMAGE_SCALE + bobOffset,
|
||||||
SFG_WEAPON_IMAGE_SCALE);
|
SFG_WEAPON_IMAGE_SCALE);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SFG_blitImage(SFG_weaponImages[SFG_player.weapon],
|
SFG_blitImage(SFG_weaponImages[SFG_player.weapon],
|
||||||
SFG_WEAPON_IMAGE_POSITION_X,
|
SFG_WEAPON_IMAGE_POSITION_X,
|
||||||
|
Loading…
Reference in New Issue
Block a user