diff --git a/Crawler/Animation.h b/Crawler/Animation.h index ad84edee..d699e007 100644 --- a/Crawler/Animation.h +++ b/Crawler/Animation.h @@ -15,4 +15,6 @@ enum AnimationState{ WIZARD_IDLE_S,WIZARD_IDLE_E,WIZARD_IDLE_N,WIZARD_IDLE_W, BATTLECRY_EFFECT,SONICSLASH, WARRIOR_SWINGSONICSWORD_S,WARRIOR_SWINGSONICSWORD_E,WARRIOR_SWINGSONICSWORD_N,WARRIOR_SWINGSONICSWORD_W, + WIZARD_IDLE_ATTACK_S,WIZARD_IDLE_ATTACK_E,WIZARD_IDLE_ATTACK_N,WIZARD_IDLE_ATTACK_W, + WIZARD_ATTACK_S,WIZARD_ATTACK_E,WIZARD_ATTACK_N,WIZARD_ATTACK_W, }; \ No newline at end of file diff --git a/Crawler/Bullet.cpp b/Crawler/Bullet.cpp index ed8ed346..20c3633d 100644 --- a/Crawler/Bullet.cpp +++ b/Crawler/Bullet.cpp @@ -22,7 +22,7 @@ void Bullet::Draw(){ if(animated){ game->view.DrawPartialRotatedDecal(pos,GetFrame().GetSourceImage()->Decal(),rotates?atan2(vel.y,vel.x)-PI/2:0,GetFrame().GetSourceRect().size/2,GetFrame().GetSourceRect().pos,GetFrame().GetSourceRect().size,{1,1},col); } else { - game->view.FillCircle(pos,radius,col); - game->view.DrawCircle(pos,radius,WHITE,0xAA); + game->view.DrawDecal(pos,game->GFX_BulletCircle.Decal(),{radius,radius},col); + game->view.DrawDecal(pos,game->GFX_BulletCircleOutline.Decal(),{radius,radius},WHITE); } } \ No newline at end of file diff --git a/Crawler/Crawler.cpp b/Crawler/Crawler.cpp index e8605536..b4691d9e 100644 --- a/Crawler/Crawler.cpp +++ b/Crawler/Crawler.cpp @@ -52,6 +52,8 @@ bool Crawler::OnUserCreate(){ GFX_Battlecry_Effect.Load("assets/battlecry_effect.png"); GFX_Mana.Load("assets/mana.png"); GFX_SonicSlash.Load("assets/sonicslash.png"); + GFX_BulletCircle.Load("assets/circle.png"); + GFX_BulletCircleOutline.Load("assets/circle_outline.png"); //Animations InitializeAnimations(); @@ -88,6 +90,14 @@ bool Crawler::OnUserCreate(){ player.AddAnimation(AnimationState::WIZARD_IDLE_E); player.AddAnimation(AnimationState::WIZARD_IDLE_S); player.AddAnimation(AnimationState::WIZARD_IDLE_W); + player.AddAnimation(AnimationState::WIZARD_IDLE_ATTACK_N); + player.AddAnimation(AnimationState::WIZARD_IDLE_ATTACK_E); + player.AddAnimation(AnimationState::WIZARD_IDLE_ATTACK_S); + player.AddAnimation(AnimationState::WIZARD_IDLE_ATTACK_W); + player.AddAnimation(AnimationState::WIZARD_ATTACK_N); + player.AddAnimation(AnimationState::WIZARD_ATTACK_E); + player.AddAnimation(AnimationState::WIZARD_ATTACK_S); + player.AddAnimation(AnimationState::WIZARD_ATTACK_W); view=TileTransformedView{GetScreenSize(),{1,1}}; player.SetClass(WARRIOR); @@ -252,6 +262,50 @@ void Crawler::InitializeAnimations(){ Animate2D::FrameSequence pl_wizard_idle_n; pl_wizard_idle_n.AddFrame({&GFX_Wizard_Sheet,{vi2d{0,1}*24,{24,24}}}); ANIMATION_DATA[AnimationState::WIZARD_IDLE_N]=pl_wizard_idle_n; + Animate2D::FrameSequence pl_wizard_idle_attack_s; + pl_wizard_idle_attack_s.AddFrame({&GFX_Wizard_Sheet,{vi2d{4,0}*24,{24,24}}}); + ANIMATION_DATA[AnimationState::WIZARD_IDLE_ATTACK_S]=pl_wizard_idle_attack_s; + Animate2D::FrameSequence pl_wizard_idle_attack_e; + pl_wizard_idle_attack_e.AddFrame({&GFX_Wizard_Sheet,{vi2d{4,3}*24,{24,24}}}); + ANIMATION_DATA[AnimationState::WIZARD_IDLE_ATTACK_E]=pl_wizard_idle_attack_e; + Animate2D::FrameSequence pl_wizard_idle_attack_w; + pl_wizard_idle_attack_w.AddFrame({&GFX_Wizard_Sheet,{vi2d{4,2}*24,{24,24}}}); + ANIMATION_DATA[AnimationState::WIZARD_IDLE_ATTACK_W]=pl_wizard_idle_attack_w; + Animate2D::FrameSequence pl_wizard_idle_attack_n; + pl_wizard_idle_attack_n.AddFrame({&GFX_Wizard_Sheet,{vi2d{4,1}*24,{24,24}}}); + ANIMATION_DATA[AnimationState::WIZARD_IDLE_ATTACK_N]=pl_wizard_idle_attack_n; + Animate2D::FrameSequence pl_wizard_attack_s(0.2); + for(int i=0;i<3;i++){ + pl_wizard_attack_s.AddFrame({&GFX_Wizard_Sheet,{vi2d{4+i,0}*24,{24,24}}}); + if(i==1){ + pl_wizard_attack_s.AddFrame({&GFX_Wizard_Sheet,{vi2d{4,0}*24,{24,24}}}); + } + } + ANIMATION_DATA[AnimationState::WIZARD_ATTACK_S]=pl_wizard_attack_s; + Animate2D::FrameSequence pl_wizard_attack_e(0.2); + for(int i=0;i<3;i++){ + pl_wizard_attack_e.AddFrame({&GFX_Wizard_Sheet,{vi2d{4,3}*24,{24,24}}}); + if(i==1){ + pl_wizard_attack_e.AddFrame({&GFX_Wizard_Sheet,{vi2d{4,3}*24,{24,24}}}); + } + } + ANIMATION_DATA[AnimationState::WIZARD_ATTACK_E]=pl_wizard_attack_e; + Animate2D::FrameSequence pl_wizard_attack_w(0.2); + for(int i=0;i<3;i++){ + pl_wizard_attack_w.AddFrame({&GFX_Wizard_Sheet,{vi2d{4,2}*24,{24,24}}}); + if(i==1){ + pl_wizard_attack_w.AddFrame({&GFX_Wizard_Sheet,{vi2d{4,2}*24,{24,24}}}); + } + } + ANIMATION_DATA[AnimationState::WIZARD_ATTACK_W]=pl_wizard_attack_w; + Animate2D::FrameSequence pl_wizard_attack_n(0.2); + for(int i=0;i<3;i++){ + pl_wizard_attack_n.AddFrame({&GFX_Wizard_Sheet,{vi2d{4,1}*24,{24,24}}}); + if(i==1){ + pl_wizard_attack_n.AddFrame({&GFX_Wizard_Sheet,{vi2d{4,1}*24,{24,24}}}); + } + } + ANIMATION_DATA[AnimationState::WIZARD_ATTACK_N]=pl_wizard_attack_n; //Load slime animations. for(int slime=0;slime<4;slime++){ @@ -289,28 +343,28 @@ void Crawler::InitializeAnimations(){ } bool Crawler::LeftHeld(){ - return GetKey(LEFT).bHeld|GetKey(A).bHeld; + return GetKey(LEFT).bHeld||GetKey(A).bHeld; } bool Crawler::RightHeld(){ - return GetKey(RIGHT).bHeld|GetKey(D).bHeld; + return GetKey(RIGHT).bHeld||GetKey(D).bHeld; } bool Crawler::UpHeld(){ - return GetKey(UP).bHeld|GetKey(W).bHeld; + return GetKey(UP).bHeld||GetKey(W).bHeld; } bool Crawler::DownHeld(){ - return GetKey(DOWN).bHeld|GetKey(S).bHeld; + return GetKey(DOWN).bHeld||GetKey(S).bHeld; } bool Crawler::LeftReleased(){ - return GetKey(LEFT).bReleased|GetKey(A).bReleased; + return GetKey(LEFT).bReleased||GetKey(A).bReleased; } bool Crawler::RightReleased(){ - return GetKey(RIGHT).bReleased|GetKey(D).bReleased; + return GetKey(RIGHT).bReleased||GetKey(D).bReleased; } bool Crawler::UpReleased(){ - return GetKey(UP).bReleased|GetKey(W).bReleased; + return GetKey(UP).bReleased||GetKey(W).bReleased; } bool Crawler::DownReleased(){ - return GetKey(DOWN).bReleased|GetKey(S).bReleased; + return GetKey(DOWN).bReleased||GetKey(S).bReleased; } void Crawler::HandleUserInput(float fElapsedTime){ diff --git a/Crawler/Crawler.h b/Crawler/Crawler.h index 336c97c9..3d5d550b 100644 --- a/Crawler/Crawler.h +++ b/Crawler/Crawler.h @@ -23,6 +23,9 @@ class Crawler : public olc::PixelGameEngine GFX_Effect_GroundSlam_Back,GFX_Effect_GroundSlam_Front, GFX_Heart,GFX_BLOCK_BUBBLE,GFX_Ranger_Sheet,GFX_Wizard_Sheet, GFX_Battlecry_Effect,GFX_Mana,GFX_SonicSlash; +public: + Renderable GFX_BulletCircle,GFX_BulletCircleOutline; +private: std::vectorforegroundEffects,backgroundEffects; std::mapMAP_DATA; std::mapMAP_TILESETS; diff --git a/Crawler/Monster.cpp b/Crawler/Monster.cpp index 60ea8199..bdcc4aed 100644 --- a/Crawler/Monster.cpp +++ b/Crawler/Monster.cpp @@ -111,33 +111,39 @@ void Monster::PerformShootAnimation(){ }break; } } -void Monster::SetX(float x){ +bool Monster::SetX(float x){ vf2d newPos={x,pos.y}; vi2d tilePos=vi2d(newPos/24)*24; geom2d::rectcollisionRect=game->GetTileCollision(game->GetCurrentLevel(),newPos); if(collisionRect.pos==vi2d{0,0}&&collisionRect.size==vi2d{1,1}){ pos.x=std::clamp(x,12.f*GetSizeMult(),float(game->WORLD_SIZE.x*24-12*GetSizeMult())); + return true; } else { geom2d::rectcollision={collisionRect.pos,collisionRect.size}; collision.pos+=tilePos; if(!geom2d::overlaps(newPos,collision)){ pos.x=std::clamp(x,12.f*GetSizeMult(),float(game->WORLD_SIZE.x*24-12*GetSizeMult())); + return true; } } + return false; } -void Monster::SetY(float y){ +bool Monster::SetY(float y){ vf2d newPos={pos.x,y}; vi2d tilePos=vi2d(newPos/24)*24; geom2d::rectcollisionRect=game->GetTileCollision(game->GetCurrentLevel(),newPos); if(collisionRect.pos==vi2d{0,0}&&collisionRect.size==vi2d{1,1}){ pos.y=std::clamp(y,12.f*GetSizeMult(),float(game->WORLD_SIZE.y*24-12*GetSizeMult())); + return true; } else { geom2d::rectcollision={collisionRect.pos,collisionRect.size}; collision.pos+=tilePos; if(!geom2d::overlaps(newPos,collision)){ pos.y=std::clamp(y,12.f*GetSizeMult(),float(game->WORLD_SIZE.y*24-12*GetSizeMult())); + return true; } } + return false; } bool Monster::Update(float fElapsedTime){ if(IsAlive()){ @@ -208,25 +214,11 @@ bool Monster::Update(float fElapsedTime){ targetAcquireTimer=1; if(line.length()<24*6){ target=line.upoint(-1.2); - if(pos.x-12*size>1&&pos.x+12*sizeGetWorldSize().x*24-1&& - pos.y-12*size>1&&pos.y+12*sizeGetWorldSize().y*24-1){ + geom2d::line moveTowardsLine=geom2d::line(pos,target); + if(canMove&&abs(moveTowardsLine.vector().norm().x)>=0.5){ state=MOVE_AWAY; - } else - if(pos.x-12*size<=1||pos.x+12*size>=game->GetWorldSize().x*24-1){ - geom2d::line moveTowardsLine=geom2d::line(pos,target); - if(abs(moveTowardsLine.vector().norm().y)>=0.5){ - state=MOVE_AWAY; - } else { - state=NORMAL; - } - } else - if(pos.y-12*size<=1||pos.y+12*size>=game->GetWorldSize().y*24-1){ - geom2d::line moveTowardsLine=geom2d::line(pos,target); - if(abs(moveTowardsLine.vector().norm().x)>=0.5){ - state=MOVE_AWAY; - } else { - state=NORMAL; - } + } else { + state=NORMAL; } } else if(line.length()>24*7){ @@ -236,11 +228,12 @@ bool Monster::Update(float fElapsedTime){ state=NORMAL; } } + canMove=true; geom2d::line moveTowardsLine=geom2d::line(pos,target); switch(state){ case MOVE_TOWARDS:{ if(moveTowardsLine.length()>1){ - SetPosition(pos+moveTowardsLine.vector().norm()*100*fElapsedTime*GetMoveSpdMult()); + canMove=SetPosition(pos+moveTowardsLine.vector().norm()*100*fElapsedTime*GetMoveSpdMult()); } if(line.length()<=24*7){ state=NORMAL; @@ -254,7 +247,7 @@ bool Monster::Update(float fElapsedTime){ }break; case MOVE_AWAY:{ if(moveTowardsLine.length()>1){ - SetPosition(pos+moveTowardsLine.vector().norm()*100*fElapsedTime*GetMoveSpdMult()); + canMove=SetPosition(pos+moveTowardsLine.vector().norm()*100*fElapsedTime*GetMoveSpdMult()); } if(line.length()>=24*6){ state=NORMAL; @@ -329,9 +322,8 @@ void Monster::Collision(){ void Monster::SetVelocity(vf2d vel){ this->vel=vel; } -void Monster::SetPosition(vf2d pos){ - SetX(pos.x); - SetY(pos.y); +bool Monster::SetPosition(vf2d pos){ + return SetX(pos.x)|SetY(pos.y); } AnimationState Monster::GetDeathAnimationName(){ switch(type){ diff --git a/Crawler/Monster.h b/Crawler/Monster.h index c32fb786..d3f2094b 100644 --- a/Crawler/Monster.h +++ b/Crawler/Monster.h @@ -72,6 +72,7 @@ struct Monster{ std::vectorbuffList; AnimationState GetDeathAnimationName(); bool hasHitPlayer=false; + bool canMove=true; //Set to false when stuck due to collisions. public: Monster(); Monster(vf2d pos,MonsterData data); @@ -93,9 +94,12 @@ struct Monster{ void Collision(Monster&p); void Collision(); void SetVelocity(vf2d vel); - void SetPosition(vf2d pos); - void SetX(float x); - void SetY(float y); + //Returns false if the monster could not be moved to the requested location due to collision. + bool SetPosition(vf2d pos); + //Returns false if the monster could not be moved to the requested location due to collision. + bool SetX(float x); + //Returns false if the monster could not be moved to the requested location due to collision. + bool SetY(float y); void PerformJumpAnimation(); void PerformShootAnimation(); diff --git a/Crawler/Player.cpp b/Crawler/Player.cpp index 8d77c9a4..fc4d04c6 100644 --- a/Crawler/Player.cpp +++ b/Crawler/Player.cpp @@ -291,6 +291,8 @@ void Player::Update(float fElapsedTime){ case BARD: { }break; case WIZARD: { + attack_cooldown_timer=MAGIC_ATTACK_COOLDOWN; + //PLAYER_BULLET_LIST.push_back(Bullet(); }break; case WITCH: { }break; diff --git a/Crawler/Player.h b/Crawler/Player.h index 416f7d3b..3df6452f 100644 --- a/Crawler/Player.h +++ b/Crawler/Player.h @@ -23,6 +23,7 @@ struct Player{ float attack_range=1.5f; Ability rightClickAbility,ability1,ability2,ability3; const float ATTACK_COOLDOWN=0.35f; + const float MAGIC_ATTACK_COOLDOWN=0.85f; float attack_cooldown_timer=0; float spin_attack_timer=0; float spin_spd=0; diff --git a/Crawler/Version.h b/Crawler/Version.h index fcee0b03..6bfe2dff 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 295 +#define VERSION_BUILD 301 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/Crawler/assets/Campaigns/1_1_test.tmx b/Crawler/assets/Campaigns/1_1_test.tmx index 0b1c7a2e..7f9e699a 100644 --- a/Crawler/assets/Campaigns/1_1_test.tmx +++ b/Crawler/assets/Campaigns/1_1_test.tmx @@ -492,16 +492,16 @@ - + - + - + diff --git a/Crawler/assets/circle.png b/Crawler/assets/circle.png index 96197e76..6d9ee923 100644 Binary files a/Crawler/assets/circle.png and b/Crawler/assets/circle.png differ diff --git a/Crawler/assets/circle_outline.png b/Crawler/assets/circle_outline.png new file mode 100644 index 00000000..601d4f3e Binary files /dev/null and b/Crawler/assets/circle_outline.png differ diff --git a/Crawler/assets/nico-wizard.png b/Crawler/assets/nico-wizard.png index 31b1d8d1..2df8fbe6 100644 Binary files a/Crawler/assets/nico-wizard.png and b/Crawler/assets/nico-wizard.png differ diff --git a/Crawler/assets/nico-wizard.xcf b/Crawler/assets/nico-wizard.xcf index 385ce25b..45461076 100644 Binary files a/Crawler/assets/nico-wizard.xcf and b/Crawler/assets/nico-wizard.xcf differ