Fix suction/player pull-in effect for item drops.

pull/28/head
sigonasr2 1 year ago
parent 403690747d
commit e7f60c01d3
  1. 23
      Crawler/ItemDrop.cpp
  2. 2
      Crawler/Version.h

@ -50,6 +50,7 @@ ItemDrop::ItemDrop(ItemInfo*item,vf2d pos)
speed.x=util::random("ItemDrop.Item Drop Horizontal Speed"_f[1]-"ItemDrop.Item Drop Horizontal Speed"_f[0])+"ItemDrop.Item Drop Horizontal Speed"_f[0];
speed.y=util::random("ItemDrop.Item Drop Vertical Speed"_f[1]-"ItemDrop.Item Drop Vertical Speed"_f[0])+"ItemDrop.Item Drop Vertical Speed"_f[0];
zSpeed="ItemDrop.Item Drop Initial Rise Speed"_F;
randomSpinOffset=util::random(PI/2);
}
vf2d ItemDrop::GetPos(){
@ -68,9 +69,14 @@ void ItemDrop::Draw(){
}
#pragma endregion
game->view.DrawRotatedDecal(pos-vf2d{0,GetZ()},item->Decal(),0,item->Decal()->sprite->Size()/2,{"ItemDrop.Item Drop Scale"_F,"ItemDrop.Item Drop Scale"_F});
float yOffset=0;
if(GetZ()==0){
yOffset=sin((game->levelTime+randomSpinOffset)*3)*0.5;
}
game->view.DrawRotatedDecal(pos-vf2d{0,GetZ()+yOffset},GFX["skill_overlay_icon_overlay.png"].Decal(),0,GFX["skill_overlay_icon_overlay.png"].Decal()->sprite->Size()/2,{"ItemDrop.Item Drop Scale"_F,"ItemDrop.Item Drop Scale"_F},YELLOW);
game->view.DrawRotatedDecal(pos-vf2d{0,GetZ()+yOffset},item->Decal(),0,item->Decal()->sprite->Size()/2,{"ItemDrop.Item Drop Scale"_F,"ItemDrop.Item Drop Scale"_F},{255,255,255,128});
game->SetDecalMode(DecalMode::ADDITIVE);
game->view.DrawRotatedDecal(pos-vf2d{0,GetZ()},item->Decal(),0,item->Decal()->sprite->Size()/2,{"ItemDrop.Item Drop Scale"_F,"ItemDrop.Item Drop Scale"_F},{uint8_t(abs(sin(game->levelTime*1.5)*255.f)),uint8_t(abs(sin(game->levelTime*1.5)*255.f)),uint8_t(abs(sin(game->levelTime*1.5)*255.f)),255});
game->view.DrawRotatedDecal(pos-vf2d{0,GetZ()+yOffset},item->Decal(),0,item->Decal()->sprite->Size()/2,{"ItemDrop.Item Drop Scale"_F,"ItemDrop.Item Drop Scale"_F},{uint8_t(abs(sin(game->levelTime*1.5)*255.f)),uint8_t(abs(sin(game->levelTime*1.5)*255.f)),uint8_t(abs(sin(game->levelTime*1.5)*255.f)),128});
game->SetDecalMode(DecalMode::NORMAL);
}
@ -78,7 +84,10 @@ void ItemDrop::UpdateDrops(float fElapsedTime){
for(ItemDrop&drop:drops){
#pragma region Handle Z Speed
drop.z+=drop.zSpeed*fElapsedTime;
if(drop.z<0)drop.zSpeed=0;
if(drop.z<=0){
drop.zSpeed=0;
drop.z=0;
}
else{
drop.zSpeed+=gravity*fElapsedTime;
drop.pos+=drop.speed*fElapsedTime;
@ -90,8 +99,12 @@ void ItemDrop::UpdateDrops(float fElapsedTime){
geom2d::line<float>lineTo=geom2d::line<float>(drop.pos,game->GetPlayer()->GetPos());
float dist=lineTo.length();
if(dist<="ItemDrop.Item Drop Suction Range"_F){
vf2d pointVel=lineTo.vector();
drop.pos+=pointVel*(1/dist*fElapsedTime);
vf2d pointVel=lineTo.vector().norm();
if((1.f/dist)*200*fElapsedTime>dist){
drop.pos=game->GetPlayer()->GetPos();
}else{
drop.pos+=pointVel*(1.f/dist)*200*fElapsedTime;
}
}
}
#pragma endregion

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

Loading…
Cancel
Save