Implement Z axis for monster rendering. Fix up shadow sizing for the player.

sigonasr2 2 years ago
parent 3a4f6c8b18
commit 8f644e7375
  1. 4
      Crawler/Bullet.h
  2. 24
      Crawler/Crawler.cpp
  3. 12
      Crawler/Monster.cpp
  4. 1
      Crawler/Monster.h
  5. 2
      Crawler/Version.h

@ -35,9 +35,9 @@ public:
Bullet(vf2d pos,vf2d vel,float radius,int damage,std::string animation,bool upperLevel,bool hitsMultiple=false,float lifetime=INFINITE,bool rotatesWithAngle=false,bool friendly=false,Pixel col=WHITE,vf2d scale={1,1});
public:
virtual void Update(float fElapsedTime);
//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.
//Used by special bullets to control custom despawning behavior! 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.
//Used by special bullets to control custom despawning behavior! 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);
Animate2D::Frame GetFrame();
virtual void Draw();

@ -448,11 +448,13 @@ void Crawler::UpdateBullets(float fElapsedTime){
if(geom2d::overlaps(geom2d::circle(m.GetPos(),12*m.GetSizeMult()),geom2d::circle(b->pos,b->radius))){
if(b->hitList.find(&m)==b->hitList.end()&&m.Hurt(b->damage,b->OnUpperLevel())){
if(!b->hitsMultiple){
it=BULLET_LIST.erase(it);
if(it==BULLET_LIST.end()){
goto outsideBulletLoop;
if(b->MonsterHit(m)){
it=BULLET_LIST.erase(it);
if(it==BULLET_LIST.end()){
goto outsideBulletLoop;
}
goto continueBulletLoop;
}
goto continueBulletLoop;
}
b->hitList[&m]=true;
}
@ -461,11 +463,13 @@ void Crawler::UpdateBullets(float fElapsedTime){
} else {
if(geom2d::overlaps(geom2d::circle(player->GetPos(),12*player->GetSizeMult()/2),geom2d::circle(b->pos,b->radius))){
if(player->Hurt(b->damage,b->OnUpperLevel())){
it=BULLET_LIST.erase(it);
if(it==BULLET_LIST.end()){
goto outsideBulletLoop;
if(b->PlayerHit(player.get())){
it=BULLET_LIST.erase(it);
if(it==BULLET_LIST.end()){
goto outsideBulletLoop;
}
goto continueBulletLoop;
}
goto continueBulletLoop;
}
}
}
@ -611,8 +615,8 @@ void Crawler::RenderWorld(float fElapsedTime){
PopulateRenderLists(monstersBeforeLower,monstersBeforeUpper,monstersAfterLower,monstersAfterUpper,bulletsLower,bulletsUpper,backgroundEffectsLower,backgroundEffectsUpper,foregroundEffectsLower,foregroundEffectsUpper);
if(player->GetZ()>0){
vf2d shadowScale=vf2d{8/3.f,1}/std::max(1.f,player->GetZ()/4);
view.DrawDecal(player->GetPos()-vf2d{3,3}*shadowScale/2+vf2d{0,6},GFX_Circle.Decal(),shadowScale,BLACK);
vf2d shadowScale=vf2d{8*player->GetSizeMult()/3.f,1}/std::max(1.f,player->GetZ()/24);
view.DrawDecal(player->GetPos()-vf2d{3,3}*shadowScale/2+vf2d{0,6*player->GetSizeMult()},GFX_Circle.Decal(),shadowScale,BLACK);
}
for(Effect*e:backgroundEffectsLower){
e->Draw();

@ -174,10 +174,14 @@ Key Monster::GetFacingDirection(){
return facingDirection;
}
void Monster::Draw(){
if(GetZ()>0){
vf2d shadowScale=vf2d{8*GetSizeMult()/3.f,1}/std::max(1.f,GetZ()/24);
game->view.DrawDecal(GetPos()-vf2d{3,3}*shadowScale/2+vf2d{0,6*GetSizeMult()},game->GFX_Circle.Decal(),shadowScale,BLACK);
}
if(GetFacingDirection()==RIGHT){
game->view.DrawPartialDecal((GetPos()+vf2d{float(GetFrame().GetSourceRect().size.x),0}*GetSizeMult())-vf2d{12,12}*GetSizeMult(),GetFrame().GetSourceImage()->Decal(),GetFrame().GetSourceRect().pos,GetFrame().GetSourceRect().size,vf2d(GetSizeMult()*-1,GetSizeMult()),GetBuffs(BuffType::SLOWDOWN).size()>0?Pixel{uint8_t(255*abs(sin(1.4*GetBuffs(BuffType::SLOWDOWN)[0].duration))),uint8_t(255*abs(sin(1.4*GetBuffs(BuffType::SLOWDOWN)[0].duration))),uint8_t(128+127*abs(sin(1.4*GetBuffs(BuffType::SLOWDOWN)[0].duration)))}:WHITE);
game->view.DrawPartialDecal((GetPos()+vf2d{float(GetFrame().GetSourceRect().size.x),0}*GetSizeMult())-vf2d{12,12}*GetSizeMult()-vf2d{0,GetZ()},GetFrame().GetSourceImage()->Decal(),GetFrame().GetSourceRect().pos,GetFrame().GetSourceRect().size,vf2d(GetSizeMult()*-1,GetSizeMult()),GetBuffs(BuffType::SLOWDOWN).size()>0?Pixel{uint8_t(255*abs(sin(1.4*GetBuffs(BuffType::SLOWDOWN)[0].duration))),uint8_t(255*abs(sin(1.4*GetBuffs(BuffType::SLOWDOWN)[0].duration))),uint8_t(128+127*abs(sin(1.4*GetBuffs(BuffType::SLOWDOWN)[0].duration)))}:WHITE);
} else {
game->view.DrawPartialDecal(GetPos()-vf2d{12,12}*GetSizeMult(),GetFrame().GetSourceImage()->Decal(),GetFrame().GetSourceRect().pos,GetFrame().GetSourceRect().size,vf2d(GetSizeMult(),GetSizeMult()),GetBuffs(BuffType::SLOWDOWN).size()>0?Pixel{uint8_t(255*abs(sin(1.4*GetBuffs(BuffType::SLOWDOWN)[0].duration))),uint8_t(255*abs(sin(1.4*GetBuffs(BuffType::SLOWDOWN)[0].duration))),uint8_t(128+127*abs(sin(1.4*GetBuffs(BuffType::SLOWDOWN)[0].duration)))}:WHITE);
game->view.DrawPartialDecal(GetPos()-vf2d{12,12}*GetSizeMult()-vf2d{0,GetZ()},GetFrame().GetSourceImage()->Decal(),GetFrame().GetSourceRect().pos,GetFrame().GetSourceRect().size,vf2d(GetSizeMult(),GetSizeMult()),GetBuffs(BuffType::SLOWDOWN).size()>0?Pixel{uint8_t(255*abs(sin(1.4*GetBuffs(BuffType::SLOWDOWN)[0].duration))),uint8_t(255*abs(sin(1.4*GetBuffs(BuffType::SLOWDOWN)[0].duration))),uint8_t(128+127*abs(sin(1.4*GetBuffs(BuffType::SLOWDOWN)[0].duration)))}:WHITE);
}
}
void Monster::Collision(Player*p){
@ -345,4 +349,8 @@ void Monster::InitializeStrategies(){
bool Monster::HasIframes(){
return iframe_timer>0;
}
float Monster::GetZ(){
return z;
}

@ -126,6 +126,7 @@ public:
void SetState(State newState);
static void InitializeStrategies();
bool HasIframes();
float GetZ();
private:
struct STRATEGY{
static int _GetInt(Monster&m,std::string param,int strategyNumber,int index=0);

@ -2,7 +2,7 @@
#define VERSION_MAJOR 0
#define VERSION_MINOR 2
#define VERSION_PATCH 0
#define VERSION_BUILD 1011
#define VERSION_BUILD 1020
#define stringify(a) stringify_(a)
#define stringify_(a) #a

Loading…
Cancel
Save