Skip to content

Commit

Permalink
Update animation refs
Browse files Browse the repository at this point in the history
  • Loading branch information
bilalkah committed Dec 18, 2024
1 parent 18ea2ce commit 146df21
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 23 deletions.
19 changes: 9 additions & 10 deletions src/Core/src/game.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "Core/game.h"
#include "Animation/time_based_single_animation.h"
#include "Animation/looped_animation.h"
#include "Camera/single_raycaster.h"
#include "Characters/enemy.h"
#include "GameObjects/dynamic_object.h"
Expand Down Expand Up @@ -228,30 +227,30 @@ void Game::PrepareEnemies() {
}

void Game::PrepareDynamicObjects() {
const auto animation_green_light = TBSAnimation(
const auto animation_green_light = LoopedAnimation(
TextureManager::GetInstance().GetTextureCollection("green_light"), 0.1);
const auto animation_red_light = TBSAnimation(
const auto animation_red_light = LoopedAnimation(
TextureManager::GetInstance().GetTextureCollection("red_light"), 0.1);

scene_->AddObject(std::make_shared<DynamicObject>(
vector2d(12.1, 8.15),
std::make_shared<TBSAnimation>(animation_red_light), 0.2, 0.9));
std::make_unique<LoopedAnimation>(animation_red_light), 0.2, 0.9));
scene_->AddObject(std::make_shared<DynamicObject>(
vector2d(10.9, 8.15),
std::make_shared<TBSAnimation>(animation_red_light), 0.2, 0.9));
std::make_unique<LoopedAnimation>(animation_red_light), 0.2, 0.9));

scene_->AddObject(std::make_shared<DynamicObject>(
vector2d(9.9, 10.9),
std::make_shared<TBSAnimation>(animation_green_light), 0.2, 0.9));
std::make_unique<LoopedAnimation>(animation_green_light), 0.2, 0.9));
scene_->AddObject(std::make_shared<DynamicObject>(
vector2d(9.9, 13.10),
std::make_shared<TBSAnimation>(animation_green_light), 0.2, 0.9));
std::make_unique<LoopedAnimation>(animation_green_light), 0.2, 0.9));
scene_->AddObject(std::make_shared<DynamicObject>(
vector2d(12.1, 13.1),
std::make_shared<TBSAnimation>(animation_green_light), 0.2, 0.9));
std::make_unique<LoopedAnimation>(animation_green_light), 0.2, 0.9));
scene_->AddObject(std::make_shared<DynamicObject>(
vector2d(12.1, 10.9),
std::make_shared<TBSAnimation>(animation_green_light), 0.2, 0.9));
std::make_unique<LoopedAnimation>(animation_green_light), 0.2, 0.9));
}

void Game::PrepareStaticObjects() {
Expand Down
4 changes: 2 additions & 2 deletions src/State/include/State/enemy_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#ifndef STATE_INCLUDE_STATE_ENEMY_STATE_H_
#define STATE_INCLUDE_STATE_ENEMY_STATE_H_

#include "Animation/time_based_single_animation.h"
#include "Animation/looped_animation.h"
#include "State/state.h"
#include <memory>
#include <vector>
Expand All @@ -37,7 +37,7 @@ class EnemyState : public State<Enemy>
int GetCurrentFrame() const override;

protected:
std::unique_ptr<TBSAnimation> animation_;
std::unique_ptr<LoopedAnimation> animation_;
};

typedef std::shared_ptr<EnemyState> EnemyStatePtr;
Expand Down
4 changes: 2 additions & 2 deletions src/State/include/State/weapon_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#ifndef STATE_INCLUDE_STATE_WEAPON_STATE_H_
#define STATE_INCLUDE_STATE_WEAPON_STATE_H_

#include "Animation/time_based_single_animation.h"
#include "Animation/looped_animation.h"
#include "State/state.h"
#include <memory>

Expand All @@ -36,7 +36,7 @@ class WeaponState : public State<Weapon>
int GetCurrentFrame() const override;

protected:
std::unique_ptr<TBSAnimation> animation_;
std::unique_ptr<LoopedAnimation> animation_;
};

typedef std::shared_ptr<WeaponState> WeaponStatePtr;
Expand Down
8 changes: 4 additions & 4 deletions src/State/src/enemy_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void IdleState::OnContextSet() {
const auto config = context_->GetStateConfig();
animation_speed_ = config.animation_time.idle_animation_speed;
range_ = config.follow_range_max;
animation_ = std::make_unique<TBSAnimation>(
animation_ = std::make_unique<LoopedAnimation>(
TextureManager::GetInstance().GetTextureCollection(
context_->GetBotName() + "_idle"),
animation_speed_);
Expand Down Expand Up @@ -98,7 +98,7 @@ void WalkState::Update(const double& delta_time) {
void WalkState::OnContextSet() {
attack_rate_ = context_->GetWeapon()->GetAttackRate();
attack_range_ = context_->GetWeapon()->GetAttackRange();
animation_ = std::make_unique<TBSAnimation>(
animation_ = std::make_unique<LoopedAnimation>(
context_->GetBotName() + "_walk", animation_speed_);
}

Expand Down Expand Up @@ -129,7 +129,7 @@ void AttackState::Update(const double& delta_time) {

void AttackState::OnContextSet() {
animation_speed_ = context_->GetWeapon()->GetAttackSpeed();
animation_ = std::make_unique<TBSAnimation>(
animation_ = std::make_unique<LoopedAnimation>(
context_->GetBotName() + "_attack", animation_speed_);
}

Expand All @@ -156,7 +156,7 @@ void PainState::Update(const double& delta_time) {
}

void PainState::OnContextSet() {
animation_ = std::make_unique<TBSAnimation>(
animation_ = std::make_unique<LoopedAnimation>(
context_->GetBotName() + "_pain", animation_speed_);
}

Expand Down
9 changes: 4 additions & 5 deletions src/State/src/weapon_state.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "State/weapon_state.h"
#include "Animation/time_based_single_animation.h"
#include "Animation/looped_animation.h"
#include "ShootingManager/shooting_manager.h"
#include "State/state.h"
#include "Strike/weapon.h"
Expand Down Expand Up @@ -43,7 +42,7 @@ WeaponStateType LoadedState::GetType() const {

void LoadedState::OnContextSet() {
fire_rate_ = context_->GetAttackSpeed();
animation_ = std::make_unique<TBSAnimation>(
animation_ = std::make_unique<LoopedAnimation>(
context_->GetWeaponName() + "_loaded", fire_rate_);
}

Expand Down Expand Up @@ -80,7 +79,7 @@ WeaponStateType OutOfAmmoState::GetType() const {

void OutOfAmmoState::OnContextSet() {
fire_rate_ = context_->GetAttackSpeed();
animation_ = std::make_unique<TBSAnimation>(
animation_ = std::make_unique<LoopedAnimation>(
context_->GetWeaponName() + "_outofammo", fire_rate_);
}

Expand Down Expand Up @@ -114,7 +113,7 @@ WeaponStateType ReloadingState::GetType() const {

void ReloadingState::OnContextSet() {
reload_speed_ = context_->GetReloadSpeed();
animation_ = std::make_unique<TBSAnimation>(
animation_ = std::make_unique<LoopedAnimation>(
context_->GetWeaponName() + "_reload", reload_speed_);
}

Expand Down

0 comments on commit 146df21

Please sign in to comment.