Prep player class structure refactor. Add default destructors to all parent classes.
This commit is contained in:
parent
93cf655a40
commit
1f69848049
@ -27,6 +27,7 @@ public:
|
|||||||
Animate2D::Animation<AnimationState>animation;
|
Animate2D::Animation<AnimationState>animation;
|
||||||
Animate2D::AnimationState internal_animState;
|
Animate2D::AnimationState internal_animState;
|
||||||
std::map<Monster*,bool>hitList;
|
std::map<Monster*,bool>hitList;
|
||||||
|
virtual ~Bullet()=default;
|
||||||
Bullet(vf2d pos,vf2d vel,float radius,int damage,bool upperLevel,bool friendly=false,Pixel col=WHITE);
|
Bullet(vf2d pos,vf2d vel,float radius,int damage,bool upperLevel,bool friendly=false,Pixel col=WHITE);
|
||||||
//Initializes a bullet with an animation.
|
//Initializes a bullet with an animation.
|
||||||
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);
|
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);
|
||||||
|
BIN
Crawler/Crawler
BIN
Crawler/Crawler
Binary file not shown.
@ -87,7 +87,7 @@ bool Crawler::OnUserCreate(){
|
|||||||
|
|
||||||
LoadLevel(CAMPAIGN_1_1);
|
LoadLevel(CAMPAIGN_1_1);
|
||||||
|
|
||||||
player.SetClass(WARRIOR);
|
player.ChangeClass(WARRIOR);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -140,26 +140,26 @@ void Crawler::HandleUserInput(float fElapsedTime){
|
|||||||
if(GetMouseWheel()>0){
|
if(GetMouseWheel()>0){
|
||||||
switch(player.cl){
|
switch(player.cl){
|
||||||
case WARRIOR:{
|
case WARRIOR:{
|
||||||
player.SetClass(RANGER);
|
player.ChangeClass(RANGER);
|
||||||
}break;
|
}break;
|
||||||
case RANGER:{
|
case RANGER:{
|
||||||
player.SetClass(WIZARD);
|
player.ChangeClass(WIZARD);
|
||||||
}break;
|
}break;
|
||||||
case WIZARD:{
|
case WIZARD:{
|
||||||
player.SetClass(WARRIOR);
|
player.ChangeClass(WARRIOR);
|
||||||
}break;
|
}break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(GetMouseWheel()<0){
|
if(GetMouseWheel()<0){
|
||||||
switch(player.cl){
|
switch(player.cl){
|
||||||
case WARRIOR:{
|
case WARRIOR:{
|
||||||
player.SetClass(WIZARD);
|
player.ChangeClass(WIZARD);
|
||||||
}break;
|
}break;
|
||||||
case RANGER:{
|
case RANGER:{
|
||||||
player.SetClass(WARRIOR);
|
player.ChangeClass(WARRIOR);
|
||||||
}break;
|
}break;
|
||||||
case WIZARD:{
|
case WIZARD:{
|
||||||
player.SetClass(RANGER);
|
player.ChangeClass(RANGER);
|
||||||
}break;
|
}break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ struct Emitter{
|
|||||||
float frequency;
|
float frequency;
|
||||||
float timer;
|
float timer;
|
||||||
float lastEmit=0;
|
float lastEmit=0;
|
||||||
|
virtual ~Emitter()=default;
|
||||||
Emitter(float frequency,float timer);
|
Emitter(float frequency,float timer);
|
||||||
bool Update(float fElapsedTime);
|
bool Update(float fElapsedTime);
|
||||||
virtual void Emit()=0;
|
virtual void Emit()=0;
|
||||||
|
@ -19,7 +19,7 @@ const float Player::GROUND_SLAM_SPIN_TIME=0.6f;
|
|||||||
Player::Player():
|
Player::Player():
|
||||||
state(State::NORMAL),lastReleasedMovementKey(DOWN),facingDirection(DOWN){}
|
state(State::NORMAL),lastReleasedMovementKey(DOWN),facingDirection(DOWN){}
|
||||||
|
|
||||||
void Player::SetClass(Class cl){
|
void Player::ChangeClass(Class cl){
|
||||||
this->cl=CLASS_DATA[cl]->cl;
|
this->cl=CLASS_DATA[cl]->cl;
|
||||||
rightClickAbility=CLASS_DATA[cl]->rightClickAbility;
|
rightClickAbility=CLASS_DATA[cl]->rightClickAbility;
|
||||||
ability1=CLASS_DATA[cl]->ability1;
|
ability1=CLASS_DATA[cl]->ability1;
|
||||||
|
@ -10,15 +10,8 @@
|
|||||||
|
|
||||||
struct Player{
|
struct Player{
|
||||||
friend class Crawler;
|
friend class Crawler;
|
||||||
friend class Warrior;
|
|
||||||
friend class Thief;
|
|
||||||
friend class Ranger;
|
|
||||||
friend class Bard;
|
|
||||||
friend class Wizard;
|
|
||||||
friend class Witch;
|
|
||||||
friend class sig::Animation;
|
friend class sig::Animation;
|
||||||
private:
|
private:
|
||||||
Class cl=WARRIOR;
|
|
||||||
int hp=100,maxhp=hp;
|
int hp=100,maxhp=hp;
|
||||||
int mana=100,maxmana=mana;
|
int mana=100,maxmana=mana;
|
||||||
int atk=10;
|
int atk=10;
|
||||||
@ -54,6 +47,9 @@ struct Player{
|
|||||||
bool upperLevel=false;
|
bool upperLevel=false;
|
||||||
void AddAnimation(AnimationState state);
|
void AddAnimation(AnimationState state);
|
||||||
void Update(float fElapsedTime);
|
void Update(float fElapsedTime);
|
||||||
|
void ChangeClass(Class cl);
|
||||||
|
std::vector<Buff>buffList;
|
||||||
|
protected:
|
||||||
void SetSwordSwingTimer(float val);
|
void SetSwordSwingTimer(float val);
|
||||||
void SetState(State newState);
|
void SetState(State newState);
|
||||||
void SetFacingDirection(Key direction);
|
void SetFacingDirection(Key direction);
|
||||||
@ -66,9 +62,6 @@ struct Player{
|
|||||||
void SetZ(float z);
|
void SetZ(float z);
|
||||||
//Returns true if the move was valid and successful.
|
//Returns true if the move was valid and successful.
|
||||||
bool SetPos(vf2d pos);
|
bool SetPos(vf2d pos);
|
||||||
void SetClass(Class cl);
|
|
||||||
std::vector<Buff>buffList;
|
|
||||||
protected:
|
|
||||||
public:
|
public:
|
||||||
Player();
|
Player();
|
||||||
const static float GROUND_SLAM_SPIN_TIME;
|
const static float GROUND_SLAM_SPIN_TIME;
|
||||||
@ -109,4 +102,11 @@ struct Player{
|
|||||||
|
|
||||||
//Triggers when the player has moved.
|
//Triggers when the player has moved.
|
||||||
void Moved();
|
void Moved();
|
||||||
|
virtual ~Player()=default;
|
||||||
|
virtual Class GetClass();
|
||||||
|
virtual bool AutoAttack();
|
||||||
|
virtual bool Ability1();
|
||||||
|
virtual bool Ability2();
|
||||||
|
virtual bool Ability3();
|
||||||
|
virtual bool RightClickAbility();
|
||||||
};
|
};
|
@ -3,7 +3,7 @@ export AUTO_UPDATE=true
|
|||||||
source utils/define.sh
|
source utils/define.sh
|
||||||
|
|
||||||
define PROJECT_NAME "Crawler"
|
define PROJECT_NAME "Crawler"
|
||||||
define CUSTOM_PARAMS "-std=c++17 -lX11 -lGL -lpthread -lpng -lstdc++fs -I/usr/include/lua5.3"
|
define CUSTOM_PARAMS "-std=c++17 -lX11 -lpthread -lpng -lstdc++fs -I/usr/include/lua5.3"
|
||||||
define LANGUAGE "C++"
|
define LANGUAGE "C++"
|
||||||
|
|
||||||
source utils/main.sh
|
source utils/main.sh
|
||||||
|
Loading…
x
Reference in New Issue
Block a user