diff --git a/Crawler/Crawler.cpp b/Crawler/Crawler.cpp index 7ded8558..1d1b0424 100644 --- a/Crawler/Crawler.cpp +++ b/Crawler/Crawler.cpp @@ -570,6 +570,11 @@ void Crawler::RenderWorld(float fElapsedTime){ vf2d playerScale=vf2d(player->GetSizeMult(),player->GetSizeMult()); vf2d playerPosition=player->GetPos(); auto RenderPlayer=[&](){ + int count=0; + for(vf2d&pos:player->ghostPositions){ + view.DrawPartialRotatedDecal(pos,player->GetFrame().GetSourceImage()->Decal(),player->GetSpinAngle(),{12,12},player->GetFrame().GetSourceRect().pos,player->GetFrame().GetSourceRect().size,playerScale,{0,0,0,uint8_t(float(count)/player->RETREAT_GHOST_FRAMES*255)}); + count++; + } if(player->teleportAnimationTimer>0){ playerScale.x=120*abs(pow(player->teleportAnimationTimer-0.175,3)); playerPosition=player->teleportStartPosition.lerp(player->teleportTarget,(0.35-player->teleportAnimationTimer)/0.35); @@ -577,7 +582,7 @@ void Crawler::RenderWorld(float fElapsedTime){ } else { view.DrawPartialRotatedDecal(playerPosition+vf2d{0,-player->GetZ()},player->GetFrame().GetSourceImage()->Decal(),player->GetSpinAngle(),{12,12},player->GetFrame().GetSourceRect().pos,player->GetFrame().GetSourceRect().size,playerScale,player->GetBuffs(BuffType::ATTACK_UP).size()>0?Pixel{255,uint8_t(255*abs(sin(1.4*player->GetBuffs(BuffType::ATTACK_UP)[0].duration))),uint8_t(255*abs(sin(1.4*player->GetBuffs(BuffType::ATTACK_UP)[0].duration)))}:WHITE); } - } + }; //define end if(!player->upperLevel){ RenderPlayer(); diff --git a/Crawler/Player.cpp b/Crawler/Player.cpp index 77f3c29a..e7f5be5f 100644 --- a/Crawler/Player.cpp +++ b/Crawler/Player.cpp @@ -541,4 +541,19 @@ void Player::PrepareCast(Ability&ability){ void Player::SetVelocity(vf2d vel){ this->vel=vel; +} + +void Player::SetAnimationBasedOnTargetingDirection(float targetDirection){ + if(targetDirection<=PI/4&&targetDirection>-PI/4){ + UpdateAnimation(AnimationState::RANGER_SHOOT_E); + } else + if(targetDirection>=3*PI/4||targetDirection<-3*PI/4){ + UpdateAnimation(AnimationState::RANGER_SHOOT_W); + } else + if(targetDirection<=3*PI/4&&targetDirection>PI/4){ + UpdateAnimation(AnimationState::RANGER_SHOOT_S); + } else + if(targetDirection>=-3*PI/4&&targetDirection<-PI/4){ + UpdateAnimation(AnimationState::RANGER_SHOOT_N); + } } \ No newline at end of file diff --git a/Crawler/Player.h b/Crawler/Player.h index 8243267d..3681714c 100644 --- a/Crawler/Player.h +++ b/Crawler/Player.h @@ -152,6 +152,7 @@ public: virtual AnimationState&GetIdleWAnimation()=0; CastInfo&GetCastInfo(); + void SetAnimationBasedOnTargetingDirection(float targetDirection); }; struct Warrior:Player{ diff --git a/Crawler/Ranger.cpp b/Crawler/Ranger.cpp index 2b56e890..423883b8 100644 --- a/Crawler/Ranger.cpp +++ b/Crawler/Ranger.cpp @@ -40,6 +40,7 @@ void Ranger::OnUpdate(float fElapsedTime){ if(retreatTimer<=0){ SetVelocity({}); SetZ(0); + SetState(State::NORMAL); } } if(ghostRemoveTimer>0){ @@ -53,27 +54,23 @@ void Ranger::OnUpdate(float fElapsedTime){ } } } + if(ghostFrameTimer>0){ + ghostFrameTimer-=fElapsedTime; + if(ghostFrameTimer<=0&&GetState()==State::RETREAT){ + ghostPositions.push_back(GetPos()+vf2d{0,-GetZ()}); + ghostFrameTimer=RETREAT_GHOST_FRAME_DELAY; + } + } } bool Ranger::AutoAttack(){ - attack_cooldown_timer=ARROW_ATTACK_COOLDOWN; geom2d::line pointTowardsCursor(GetPos(),game->GetWorldMousePos()); vf2d extendedLine=pointTowardsCursor.upoint(1.1); float angleToCursor=atan2(extendedLine.y-GetPos().y,extendedLine.x-GetPos().x); + attack_cooldown_timer=ARROW_ATTACK_COOLDOWN; BULLET_LIST.push_back(std::make_unique(Arrow(GetPos(),extendedLine,vf2d{cos(angleToCursor)*250,float(sin(angleToCursor)*250-PI/8*250)}+movementVelocity,12,GetAttack(),OnUpperLevel(),true))); SetState(State::SHOOT_ARROW); - if(angleToCursor<=PI/4&&angleToCursor>-PI/4){ - UpdateAnimation(AnimationState::RANGER_SHOOT_E); - } else - if(angleToCursor>=3*PI/4||angleToCursor<-3*PI/4){ - UpdateAnimation(AnimationState::RANGER_SHOOT_W); - } else - if(angleToCursor<=3*PI/4&&angleToCursor>PI/4){ - UpdateAnimation(AnimationState::RANGER_SHOOT_S); - } else - if(angleToCursor>=-3*PI/4&&angleToCursor<-PI/4){ - UpdateAnimation(AnimationState::RANGER_SHOOT_N); - } + SetAnimationBasedOnTargetingDirection(angleToCursor); return false; } @@ -86,9 +83,12 @@ void Ranger::InitializeClassAbilities(){ p->SetVelocity(mouseDir.vector().norm()*velocity); p->retreatTimer=p->RETREAT_TIME; p->iframe_time=p->RETREAT_TIME; - p->ghostPositions.push_back(p->GetPos()); + p->ghostPositions.push_back(p->GetPos()+vf2d{0,-p->GetZ()}); p->ghostFrameTimer=p->RETREAT_GHOST_FRAME_DELAY; p->ghostRemoveTimer=p->RETREAT_GHOST_FRAMES*p->RETREAT_GHOST_FRAME_DELAY; + float angleToCursor=atan2(game->GetWorldMousePos().y-p->GetPos().y,game->GetWorldMousePos().x-p->GetPos().x); + p->SetAnimationBasedOnTargetingDirection(angleToCursor); + p->SetState(State::RETREAT); return true; }; #pragma endregion diff --git a/Crawler/Version.h b/Crawler/Version.h index 5bafc01a..21917f3d 100644 --- a/Crawler/Version.h +++ b/Crawler/Version.h @@ -2,7 +2,7 @@ #define VERSION_MAJOR 0 #define VERSION_MINOR 2 #define VERSION_PATCH 0 -#define VERSION_BUILD 810 +#define VERSION_BUILD 828 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/Crawler/test b/Crawler/test new file mode 100644 index 00000000..8bed73c2 --- /dev/null +++ b/Crawler/test @@ -0,0 +1,3 @@ +test 1 +test 2 +test 3 \ No newline at end of file