Added more indicators for healing, mana, and interruption.

pull/28/head
sigonasr2 1 year ago
parent 3605aa818d
commit 3f9543d93b
  1. 28
      Crawler/Crawler.cpp
  2. 4
      Crawler/DamageNumber.cpp
  3. 11
      Crawler/DamageNumber.h
  4. 2
      Crawler/Monster.h
  5. 17
      Crawler/Player.cpp
  6. 4
      Crawler/Player.h
  7. 2
      Crawler/Version.h
  8. BIN
      x64/Release/Crawler.exe

@ -1109,16 +1109,44 @@ void Crawler::RenderWorld(float fElapsedTime){
dn->lifeTime+=fElapsedTime; dn->lifeTime+=fElapsedTime;
if(dn->lifeTime<=1){ if(dn->lifeTime<=1){
if(dn->lifeTime<DamageNumber::MOVE_UP_TIME){ if(dn->lifeTime<DamageNumber::MOVE_UP_TIME){
if(dn->invertedDirection){
dn->pos.y+=20*fElapsedTime;
}else{
dn->pos.y-=20*fElapsedTime; dn->pos.y-=20*fElapsedTime;
} }
} }
} }
}
switch(dn->type){
case HEALTH_LOSS:{
std::string text=std::to_string(dn->damage); std::string text=std::to_string(dn->damage);
if(!dn->friendly){ if(!dn->friendly){
view.DrawStringPropDecal(dn->pos-GetTextSizeProp(text)/2,text,DARK_RED); view.DrawStringPropDecal(dn->pos-GetTextSizeProp(text)/2,text,DARK_RED);
}else{ }else{
view.DrawShadowStringPropDecal(dn->pos-GetTextSizeProp(text)/2,text,RED,VERY_DARK_GREY); view.DrawShadowStringPropDecal(dn->pos-GetTextSizeProp(text)/2,text,RED,VERY_DARK_GREY);
} }
}break;
case HEALTH_GAIN:{
std::string text="+"+std::to_string(dn->damage);
if(!dn->friendly){
view.DrawStringPropDecal(dn->pos-GetTextSizeProp(text)/2,text,DARK_GREEN);
}else{
view.DrawShadowStringPropDecal(dn->pos-GetTextSizeProp(text)/2,text,GREEN,VERY_DARK_GREY);
}
}break;
case MANA_GAIN:{
std::string text="+"+std::to_string(dn->damage);
if(dn->friendly){
view.DrawShadowStringPropDecal(dn->pos-GetTextSizeProp(text)/2,text,BLUE,VERY_DARK_GREY);
}
}break;
case INTERRUPT:{
std::string text="Interrupted!";
if(dn->friendly){
view.DrawShadowStringPropDecal(dn->pos-GetTextSizeProp(text)/2,text,BLACK,VERY_DARK_GREY,{0.5,1});
}
}break;
}
} }
if(DEBUG_PATHFINDING){ if(DEBUG_PATHFINDING){

@ -39,6 +39,6 @@ DamageNumber::DamageNumber()
:damage(0){ :damage(0){
} }
DamageNumber::DamageNumber(vf2d pos,int damage,bool friendly): DamageNumber::DamageNumber(vf2d pos,int damage,bool friendly,DamageNumberType type):
pos(pos),damage(damage),friendly(friendly){ pos(pos),damage(damage),friendly(friendly),type(type),invertedDirection(type==INTERRUPT){
} }

@ -34,13 +34,22 @@ SUCH DAMAGE.
#pragma once #pragma once
#include "olcPixelGameEngine.h" #include "olcPixelGameEngine.h"
enum DamageNumberType{
HEALTH_LOSS,
HEALTH_GAIN,
MANA_GAIN,
INTERRUPT
};
struct DamageNumber{ struct DamageNumber{
vf2d pos; vf2d pos;
int damage; int damage;
float lifeTime=0; float lifeTime=0;
float pauseTime=0; float pauseTime=0;
bool friendly=false; bool friendly=false;
bool invertedDirection=false;
DamageNumberType type=HEALTH_LOSS;
const static float MOVE_UP_TIME; const static float MOVE_UP_TIME;
DamageNumber(); DamageNumber();
DamageNumber(vf2d pos,int damage,bool friendly=false); DamageNumber(vf2d pos,int damage,bool friendly=false,DamageNumberType type=HEALTH_LOSS);
}; };

@ -37,7 +37,6 @@ SUCH DAMAGE.
#include "State.h" #include "State.h"
#include "Buff.h" #include "Buff.h"
#include "olcUTIL_Animate2D.h" #include "olcUTIL_Animate2D.h"
#include "DamageNumber.h"
#include "DEFINES.h" #include "DEFINES.h"
#include "Attributable.h" #include "Attributable.h"
#include "Item.h" #include "Item.h"
@ -45,6 +44,7 @@ SUCH DAMAGE.
INCLUDE_ITEM_DATA INCLUDE_ITEM_DATA
struct DamageNumber;
struct Player; struct Player;
class Crawler; class Crawler;

@ -248,7 +248,7 @@ void Player::Update(float fElapsedTime){
} }
while(manaTickTimer<=0){ while(manaTickTimer<=0){
manaTickTimer+=0.2; manaTickTimer+=0.2;
RestoreMana(1); RestoreMana(1,true);
} }
for(std::vector<Buff>::iterator it=buffList.begin();it!=buffList.end();++it){ for(std::vector<Buff>::iterator it=buffList.begin();it!=buffList.end();++it){
Buff&b=*it; Buff&b=*it;
@ -565,7 +565,7 @@ vf2d Player::GetVelocity(){
} }
bool Player::CanMove(){ bool Player::CanMove(){
return state!=State::CASTING&&state!=State::ANIMATION_LOCK; return state!=State::ANIMATION_LOCK;
} }
bool Player::CanAct(){ bool Player::CanAct(){
@ -632,6 +632,11 @@ Key Player::GetFacingDirection(){
} }
void Player::Moved(){ void Player::Moved(){
if(state==State::CASTING){
state=State::NORMAL;
castInfo={"",0};
DAMAGENUMBER_LIST.push_back(std::make_shared<DamageNumber>(GetPos(),0,true,INTERRUPT));
}
for(MonsterSpawner&spawner:SPAWNER_LIST){ for(MonsterSpawner&spawner:SPAWNER_LIST){
if(!spawner.SpawnTriggered()&&spawner.DoesUpperLevelSpawning()==OnUpperLevel()&&geom2d::contains(geom2d::rect<float>{spawner.GetPos(),spawner.GetRange()},pos)){ if(!spawner.SpawnTriggered()&&spawner.DoesUpperLevelSpawning()==OnUpperLevel()&&geom2d::contains(geom2d::rect<float>{spawner.GetPos(),spawner.GetRange()},pos)){
spawner.SetTriggered(true); spawner.SetTriggered(true);
@ -769,11 +774,17 @@ void Player::SetIframes(float duration){
bool Player::Heal(int damage){ bool Player::Heal(int damage){
hp=std::clamp(hp+damage,0,maxhp); hp=std::clamp(hp+damage,0,maxhp);
if(damage>0){
DAMAGENUMBER_LIST.push_back(std::make_shared<DamageNumber>(GetPos(),damage,true,HEALTH_GAIN));
}
return true; return true;
} }
void Player::RestoreMana(int amt){ void Player::RestoreMana(int amt,bool suppressDamageNumber){
mana=std::clamp(mana+amt,0,maxmana); mana=std::clamp(mana+amt,0,maxmana);
if(amt>0&&!suppressDamageNumber){
DAMAGENUMBER_LIST.push_back(std::make_shared<DamageNumber>(GetPos(),amt,true,MANA_GAIN));
}
} }
void Player::ConsumeMana(int amt){ void Player::ConsumeMana(int amt){

@ -39,13 +39,13 @@ SUCH DAMAGE.
#include "Ability.h" #include "Ability.h"
#include "Buff.h" #include "Buff.h"
#include "Pathfinding.h" #include "Pathfinding.h"
#include "DamageNumber.h"
#include "config.h" #include "config.h"
#include "Key.h" #include "Key.h"
#include "Class.h" #include "Class.h"
#include "Item.h" #include "Item.h"
#undef GetClassName #undef GetClassName
struct DamageNumber;
struct CastInfo{ struct CastInfo{
std::string name; std::string name;
@ -170,7 +170,7 @@ public:
bool CanAct(Ability&ability); bool CanAct(Ability&ability);
void Knockback(vf2d vel); void Knockback(vf2d vel);
void SetIframes(float duration); void SetIframes(float duration);
void RestoreMana(int amt); void RestoreMana(int amt,bool suppressDamageNumber=false);
void ConsumeMana(int amt); void ConsumeMana(int amt);
//Returns true if the move was valid and successful. //Returns true if the move was valid and successful.
bool SetX(float x); bool SetX(float x);

@ -35,7 +35,7 @@ SUCH DAMAGE.
#define VERSION_MAJOR 0 #define VERSION_MAJOR 0
#define VERSION_MINOR 2 #define VERSION_MINOR 2
#define VERSION_PATCH 1 #define VERSION_PATCH 1
#define VERSION_BUILD 3127 #define VERSION_BUILD 3137
#define stringify(a) stringify_(a) #define stringify(a) stringify_(a)
#define stringify_(a) #a #define stringify_(a) #a

Binary file not shown.
Loading…
Cancel
Save