@ -40,6 +40,7 @@ All rights reserved.
# include "DEFINES.h"
# include "safemap.h"
# include "util.h"
# include "SoundEffect.h"
INCLUDE_ANIMATION_DATA
INCLUDE_game
@ -50,8 +51,8 @@ INCLUDE_WINDOW_SIZE
Bullet : : Bullet ( vf2d pos , vf2d vel , float radius , int damage , bool upperLevel , bool friendly , Pixel col , vf2d scale , float image_angle )
: pos ( pos ) , vel ( vel ) , radius ( radius ) , damage ( damage ) , col ( col ) , friendly ( friendly ) , upperLevel ( upperLevel ) , scale ( scale ) , image_angle ( image_angle ) { } ;
Bullet : : Bullet ( vf2d pos , vf2d vel , float radius , int damage , std : : string animation , bool upperLevel , bool hitsMultiple , float lifetime , bool rotatesWithAngle , bool friendly , Pixel col , vf2d scale , float image_angle )
: pos ( pos ) , vel ( vel ) , radius ( radius ) , damage ( damage ) , col ( col ) , animated ( true ) , rotates ( rotatesWithAngle ) , lifetime ( lifetime ) , hitsMultiple ( hitsMultiple ) , friendly ( friendly ) , upperLevel ( upperLevel ) , scale ( scale ) , image_angle ( image_angle ) {
Bullet : : Bullet ( vf2d pos , vf2d vel , float radius , int damage , std : : string animation , bool upperLevel , bool hitsMultiple , float lifetime , bool rotatesWithAngle , bool friendly , Pixel col , vf2d scale , float image_angle , std : : string_view hitSound )
: pos ( pos ) , vel ( vel ) , radius ( radius ) , damage ( damage ) , col ( col ) , animated ( true ) , rotates ( rotatesWithAngle ) , lifetime ( lifetime ) , hitsMultiple ( hitsMultiple ) , friendly ( friendly ) , upperLevel ( upperLevel ) , scale ( scale ) , image_angle ( image_angle ) , hitSound ( std : : string ( hitSound ) ) {
this - > animation . AddState ( animation , ANIMATION_DATA . at ( animation ) ) ;
this - > animation . ChangeState ( internal_animState , animation ) ;
} ;
@ -189,11 +190,13 @@ void Bullet::Draw(const Pixel blendCol)const{
BulletDestroyState Bullet : : _PlayerHit ( Player * player ) {
const BulletDestroyState destroyBullet = PlayerHit ( player ) ;
if ( iframeTimerOnHit > 0.f ) player - > ApplyIframes ( iframeTimerOnHit ) ;
if ( hitSound ) SoundEffect : : PlaySFX ( hitSound . value ( ) , pos ) ;
return destroyBullet ;
}
BulletDestroyState Bullet : : _MonsterHit ( Monster & monster ) {
const BulletDestroyState destroyBullet = MonsterHit ( monster ) ;
if ( iframeTimerOnHit > 0.f ) monster . ApplyIframes ( iframeTimerOnHit ) ;
if ( hitSound ) SoundEffect : : PlaySFX ( hitSound . value ( ) , pos ) ;
return destroyBullet ;
}
BulletDestroyState Bullet : : PlayerHit ( Player * player ) {