2023-06-16 01:41:38 -05:00
# pragma once
# include "olcPixelGameEngine.h"
2023-06-20 19:13:45 -07:00
# include "Animation.h"
# include "olcUTIL_Animate2D.h"
# include "Monster.h"
2023-07-06 18:03:35 +00:00
# include "DEFINES.h"
2023-06-16 01:41:38 -05:00
struct Bullet {
2023-07-05 05:34:21 -05:00
friend class Crawler ;
2023-06-16 01:41:38 -05:00
vf2d pos ;
vf2d vel ;
float radius ;
int damage ;
Pixel col ;
2023-06-24 02:14:11 -07:00
float lifetime = INFINITE ;
2023-06-20 19:13:45 -07:00
bool hitsMultiple = false ;
bool rotates = false ;
bool animated = false ;
2023-07-05 05:34:21 -05:00
bool deactivated = false ; //A deactivated bullet no longer interacts with the world. It's just a visual.
float fadeOutTime = 0 ;
bool friendly = false ; //Whether or not it's a player bullet or enemy bullet.
2023-07-07 06:42:49 -05:00
bool upperLevel = false ;
2023-07-05 05:34:21 -05:00
private :
float fadeOutTimer = 0 ;
void UpdateFadeTime ( float fElapsedTime ) ;
public :
2023-06-20 19:13:45 -07:00
Animate2D : : Animation < AnimationState > animation ;
Animate2D : : AnimationState internal_animState ;
std : : map < Monster * , bool > hitList ;
2023-07-07 06:42:49 -05:00
Bullet ( vf2d pos , vf2d vel , float radius , int damage , bool upperLevel , bool friendly = false , Pixel col = WHITE ) ;
2023-06-20 19:13:45 -07:00
//Initializes a bullet with an animation.
2023-07-07 06:42:49 -05:00
Bullet ( vf2d pos , vf2d vel , float radius , int damage , AnimationState animation , bool upperLevel , bool hitsMultiple = false , float lifetime = INFINITE , bool rotatesWithAngle = false , bool friendly = false , Pixel col = WHITE ) ;
2023-06-20 19:13:45 -07:00
public :
2023-06-30 15:44:41 -07:00
virtual void Update ( float fElapsedTime ) ;
2023-07-05 05:34:21 -05:00
//Return true when the bullet should be destroyed. Return false to handle it otherwise (like deactivating it instead). You become responsible for getting rid of the bullet.
virtual bool PlayerHit ( Player & player ) ;
//Return true when the bullet should be destroyed. Return false to handle it otherwise (like deactivating it instead). You become responsible for getting rid of the bullet.
virtual bool MonsterHit ( Monster & monster ) ;
2023-06-20 19:13:45 -07:00
Animate2D : : Frame GetFrame ( ) ;
void Draw ( ) ;
2023-07-07 06:42:49 -05:00
bool OnUpperLevel ( ) ;
2023-06-16 01:41:38 -05:00
} ;