diff --git a/Crawler/Animation.h b/Crawler/Animation.h index d699e007..6f2a21db 100644 --- a/Crawler/Animation.h +++ b/Crawler/Animation.h @@ -17,4 +17,5 @@ enum AnimationState{ 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, + ENERGY_BOLT,ENERGY_PARTICLE }; \ No newline at end of file diff --git a/Crawler/Bullet.cpp b/Crawler/Bullet.cpp index 20c3633d..b6367e2a 100644 --- a/Crawler/Bullet.cpp +++ b/Crawler/Bullet.cpp @@ -18,6 +18,16 @@ Animate2D::Frame Bullet::GetFrame(){ return animation.GetFrame(internal_animState); } +void Bullet::Update(float fElapsedTime){ + if(animated){ + lastParticleSpawn=std::max(0.f,lastParticleSpawn-fElapsedTime); + if(lastParticleSpawn==0&&animation.GetFrame(internal_animState).GetSourceImage()==&game->GFX_EnergyBolt){ + lastParticleSpawn=0.03; + game->AddEffect(Effect(pos,float(rand()%500)/500,AnimationState::ENERGY_PARTICLE,float(rand()%1000)/500,0.5,{float(rand()%60)-30,float(rand()%60)-30})); + } + } +} + 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); diff --git a/Crawler/Bullet.h b/Crawler/Bullet.h index 006374cb..a85cb292 100644 --- a/Crawler/Bullet.h +++ b/Crawler/Bullet.h @@ -4,23 +4,27 @@ #include "olcUTIL_Animate2D.h" #include "Monster.h" +#define INFINITE 999999 + struct Bullet{ vf2d pos; vf2d vel; float radius; int damage; Pixel col; - float lifetime=99999; + float lifetime=INFINITE; bool hitsMultiple=false; bool rotates=false; bool animated=false; Animate2D::Animationanimation; Animate2D::AnimationState internal_animState; std::maphitList; + float lastParticleSpawn=0; Bullet(vf2d pos,vf2d vel,float radius,int damage,Pixel col=WHITE); //Initializes a bullet with an animation. - Bullet(vf2d pos,vf2d vel,float radius,int damage,AnimationState animation,bool hitsMultiple=false,float lifetime=999999,bool rotatesWithAngle=false,Pixel col=WHITE); + Bullet(vf2d pos,vf2d vel,float radius,int damage,AnimationState animation,bool hitsMultiple=false,float lifetime=INFINITE,bool rotatesWithAngle=false,Pixel col=WHITE); public: + void Update(float fElapsedTime); Animate2D::Frame GetFrame(); void Draw(); }; \ No newline at end of file diff --git a/Crawler/Crawler.cpp b/Crawler/Crawler.cpp index b4691d9e..840317d9 100644 --- a/Crawler/Crawler.cpp +++ b/Crawler/Crawler.cpp @@ -54,6 +54,8 @@ bool Crawler::OnUserCreate(){ GFX_SonicSlash.Load("assets/sonicslash.png"); GFX_BulletCircle.Load("assets/circle.png"); GFX_BulletCircleOutline.Load("assets/circle_outline.png"); + GFX_EnergyBolt.Load("assets/energy_bolt.png"); + GFX_EnergyParticle.Load("assets/energy_particle.png"); //Animations InitializeAnimations(); @@ -284,7 +286,7 @@ void Crawler::InitializeAnimations(){ 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}}}); + pl_wizard_attack_e.AddFrame({&GFX_Wizard_Sheet,{vi2d{4+i,3}*24,{24,24}}}); if(i==1){ pl_wizard_attack_e.AddFrame({&GFX_Wizard_Sheet,{vi2d{4,3}*24,{24,24}}}); } @@ -292,7 +294,7 @@ void Crawler::InitializeAnimations(){ 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}}}); + pl_wizard_attack_w.AddFrame({&GFX_Wizard_Sheet,{vi2d{4+i,2}*24,{24,24}}}); if(i==1){ pl_wizard_attack_w.AddFrame({&GFX_Wizard_Sheet,{vi2d{4,2}*24,{24,24}}}); } @@ -300,7 +302,7 @@ void Crawler::InitializeAnimations(){ 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}}}); + pl_wizard_attack_n.AddFrame({&GFX_Wizard_Sheet,{vi2d{4+i,1}*24,{24,24}}}); if(i==1){ pl_wizard_attack_n.AddFrame({&GFX_Wizard_Sheet,{vi2d{4,1}*24,{24,24}}}); } @@ -340,6 +342,15 @@ void Crawler::InitializeAnimations(){ sonicslash_effect.AddFrame({&GFX_SonicSlash,{{i*60,0},{60,60}}}); } ANIMATION_DATA[AnimationState::SONICSLASH]=sonicslash_effect; + Animate2D::FrameSequence energy_bolt; + energy_bolt.AddFrame({&GFX_EnergyBolt,{{0,0},{24,24}}}); + ANIMATION_DATA[AnimationState::ENERGY_BOLT]=energy_bolt; + + Animate2D::FrameSequence energy_particle; + for(int i=0;i<3;i++){ + energy_particle.AddFrame({&GFX_EnergyParticle,{{i*3,0},{3,3}}}); + } + ANIMATION_DATA[AnimationState::ENERGY_PARTICLE]=energy_particle; } bool Crawler::LeftHeld(){ @@ -582,6 +593,7 @@ void Crawler::UpdateEffects(float fElapsedTime){ void Crawler::UpdateBullets(float fElapsedTime){ for(std::vector::iterator it=BULLET_LIST.begin();it!=BULLET_LIST.end();++it){ Bullet&b=*it; + b.Update(fElapsedTime); b.pos+=b.vel*fElapsedTime; if(geom2d::overlaps(geom2d::circle(player.GetPos(),12*player.GetSizeMult()/2),geom2d::circle(b.pos,b.radius))){ if(player.Hurt(b.damage)){ @@ -608,6 +620,7 @@ void Crawler::UpdateBullets(float fElapsedTime){ } for(std::vector::iterator it=PLAYER_BULLET_LIST.begin();it!=PLAYER_BULLET_LIST.end();++it){ Bullet&b=*it; + b.Update(fElapsedTime); b.pos+=b.vel*fElapsedTime; for(Monster&m:MONSTER_LIST){ if(geom2d::overlaps(geom2d::circle(m.GetPos(),12*m.GetSizeMult()),geom2d::circle(b.pos,b.radius))){ @@ -615,7 +628,7 @@ void Crawler::UpdateBullets(float fElapsedTime){ if(!b.hitsMultiple){ it=PLAYER_BULLET_LIST.erase(it); if(it==PLAYER_BULLET_LIST.end()){ - break; + goto outsidePlayerBulletLoop; } } b.hitList[&m]=true; @@ -637,6 +650,8 @@ void Crawler::UpdateBullets(float fElapsedTime){ } b.animation.UpdateState(b.internal_animState,fElapsedTime); } + outsidePlayerBulletLoop: + int a; } void Crawler::HurtEnemies(vf2d pos,float radius,int damage){ for(Monster&m:MONSTER_LIST){ diff --git a/Crawler/Crawler.h b/Crawler/Crawler.h index 3d5d550b..3fc0db9a 100644 --- a/Crawler/Crawler.h +++ b/Crawler/Crawler.h @@ -22,9 +22,9 @@ class Crawler : public olc::PixelGameEngine Renderable GFX_Warrior_Sheet,GFX_Slime_Sheet,GFX_Circle, 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; + GFX_Battlecry_Effect,GFX_Mana,GFX_SonicSlash,GFX_EnergyParticle; public: - Renderable GFX_BulletCircle,GFX_BulletCircleOutline; + Renderable GFX_BulletCircle,GFX_BulletCircleOutline,GFX_EnergyBolt; private: std::vectorforegroundEffects,backgroundEffects; std::mapMAP_DATA; diff --git a/Crawler/DEFINES.h b/Crawler/DEFINES.h index f85e877e..1de04f5a 100644 --- a/Crawler/DEFINES.h +++ b/Crawler/DEFINES.h @@ -7,4 +7,5 @@ #define INCLUDE_MONSTER_DATA extern std::mapMONSTER_DATA; #define INCLUDE_BULLET_LIST extern std::vectorBULLET_LIST; #define INCLUDE_CLASS_DATA extern std::mapCLASS_DATA; -#define INCLUDE_PLAYER_BULLET_LIST extern std::vectorPLAYER_BULLET_LIST; \ No newline at end of file +#define INCLUDE_PLAYER_BULLET_LIST extern std::vectorPLAYER_BULLET_LIST; +#define INCLUDE_PARTICLE_LIST extern std::vectorPARTICLE_LIST; \ No newline at end of file diff --git a/Crawler/Effect.cpp b/Crawler/Effect.cpp index 5c5750b5..07934fa8 100644 --- a/Crawler/Effect.cpp +++ b/Crawler/Effect.cpp @@ -5,8 +5,8 @@ INCLUDE_ANIMATION_DATA INCLUDE_game -Effect::Effect(vf2d pos,float lifetime,AnimationState animation,float size,float fadeout) - :pos(pos),lifetime(lifetime),size(size),fadeout(fadeout),original_fadeoutTime(fadeout){ +Effect::Effect(vf2d pos,float lifetime,AnimationState animation,float size,float fadeout,vf2d spd) + :pos(pos),lifetime(lifetime),size(size),fadeout(fadeout),original_fadeoutTime(fadeout),spd(spd){ this->animation.AddState(animation,ANIMATION_DATA[animation]); } @@ -18,6 +18,7 @@ bool Effect::Update(float fElapsedTime){ return false; } } + pos+=spd*fElapsedTime; animation.UpdateState(internal_animState,fElapsedTime); return true; } diff --git a/Crawler/Effect.h b/Crawler/Effect.h index dcc36038..128af56d 100644 --- a/Crawler/Effect.h +++ b/Crawler/Effect.h @@ -8,7 +8,8 @@ struct Effect{ float lifetime=0; float fadeout=0; float size=1; - Effect(vf2d pos,float lifetime,AnimationState animation,float size=1.0f,float fadeout=0.0f); + vf2d spd={}; + Effect(vf2d pos,float lifetime,AnimationState animation,float size=1.0f,float fadeout=0.0f,vf2d spd={}); bool Update(float fElapsedTime); Animate2D::Frame GetFrame(); void Draw(); diff --git a/Crawler/Player.cpp b/Crawler/Player.cpp index fc4d04c6..2fb1de93 100644 --- a/Crawler/Player.cpp +++ b/Crawler/Player.cpp @@ -147,6 +147,40 @@ void Player::Update(float fElapsedTime){ if(it==buffList.end())break; } } + //Class-specific update events. + switch (cl) { + case WARRIOR: { + }break; + case THIEF: { + }break; + case RANGER: { + }break; + case BARD: { + }break; + case WIZARD: { + if(attack_cooldown_timer>0){ + CLASS_DATA[cl].idle_n=AnimationState::WIZARD_IDLE_ATTACK_N; + CLASS_DATA[cl].idle_e=AnimationState::WIZARD_IDLE_ATTACK_E; + CLASS_DATA[cl].idle_s=AnimationState::WIZARD_IDLE_ATTACK_S; + CLASS_DATA[cl].idle_w=AnimationState::WIZARD_IDLE_ATTACK_W; + CLASS_DATA[cl].walk_n=AnimationState::WIZARD_ATTACK_N; + CLASS_DATA[cl].walk_e=AnimationState::WIZARD_ATTACK_E; + CLASS_DATA[cl].walk_s=AnimationState::WIZARD_ATTACK_S; + CLASS_DATA[cl].walk_w=AnimationState::WIZARD_ATTACK_W; + } else { + CLASS_DATA[cl].idle_n=AnimationState::WIZARD_IDLE_N; + CLASS_DATA[cl].idle_e=AnimationState::WIZARD_IDLE_E; + CLASS_DATA[cl].idle_s=AnimationState::WIZARD_IDLE_S; + CLASS_DATA[cl].idle_w=AnimationState::WIZARD_IDLE_W; + CLASS_DATA[cl].walk_n=AnimationState::WIZARD_WALK_N; + CLASS_DATA[cl].walk_e=AnimationState::WIZARD_WALK_E; + CLASS_DATA[cl].walk_s=AnimationState::WIZARD_WALK_S; + CLASS_DATA[cl].walk_w=AnimationState::WIZARD_WALK_W; + } + }break; + case WITCH: { + }break; + } switch(state){ case SPIN:{ switch(facingDirection){ @@ -292,7 +326,8 @@ void Player::Update(float fElapsedTime){ }break; case WIZARD: { attack_cooldown_timer=MAGIC_ATTACK_COOLDOWN; - //PLAYER_BULLET_LIST.push_back(Bullet(); + float angleToCursor=atan2(game->GetWorldMousePos().y-pos.y,game->GetWorldMousePos().x-pos.x); + PLAYER_BULLET_LIST.push_back(Bullet(pos,{cos(angleToCursor)*200,sin(angleToCursor)*200},12,GetAttack(),AnimationState::ENERGY_BOLT,false,INFINITE,true)); }break; case WITCH: { }break; diff --git a/Crawler/Version.h b/Crawler/Version.h index 6bfe2dff..e6f83963 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 301 +#define VERSION_BUILD 316 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/Crawler/assets/energy_bolt.png b/Crawler/assets/energy_bolt.png new file mode 100644 index 00000000..c4e638a9 Binary files /dev/null and b/Crawler/assets/energy_bolt.png differ diff --git a/Crawler/assets/energy_particle.png b/Crawler/assets/energy_particle.png new file mode 100644 index 00000000..86be8fc3 Binary files /dev/null and b/Crawler/assets/energy_particle.png differ diff --git a/Crawler/assets/nico-wizard.png b/Crawler/assets/nico-wizard.png index 2df8fbe6..a67a4cc8 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 45461076..244d6022 100644 Binary files a/Crawler/assets/nico-wizard.xcf and b/Crawler/assets/nico-wizard.xcf differ