Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix naming #4

Merged
merged 5 commits into from
Aug 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions src/Camera/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,35 @@ link_directories(
${PROJECT_SOURCE_DIR}
)


# Ray library
add_library(
ray
STATIC
src/ray.cpp
)

# Specify include directories for this library
target_include_directories(ray PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}
)

target_link_libraries(
ray
PUBLIC
vector
)

# Game object library
# camera library
add_library(
camera
STATIC
src/camera.cpp
src/raycaster.cpp
)

# Specify include directories for this library
target_include_directories(camera PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}
)


target_link_libraries(
camera
PUBLIC
Expand Down
21 changes: 11 additions & 10 deletions src/Camera/include/Camera/camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@
*
*/

#ifndef CAMERA_CAMERA_H
#define CAMERA_CAMERA_H
#ifndef CAMERA_INCLUDE_CAMERA_H
#define CAMERA_INCLUDE_CAMERA_H

#include "Camera/raycaster.h"
#include "Graphics/scene.h"
#include <Camera/ray.h>
#include <Camera/raycaster.h>
#include <Characters/character.h>
#include <GameObjects/game_object.h>
#include <GameObjects/static_object.h>
#include <Graphics/scene.h>
#include <Map/map.h>

#include <memory>
#include <optional>
#include <third-party/uuid_v4/uuid_v4.h>
#include <unordered_map>

namespace wolfenstein {
Expand All @@ -44,8 +44,8 @@ class Camera2D
void Update(const std::shared_ptr<Scene>& scene);

std::shared_ptr<RayVector> GetRays() const;
std::optional<RayPair> GetObjectRay(std::string id);
std::shared_ptr<Ray> GetCrosshairRay() const;
std::optional<RayPair> GetObjectRay(const std::string id);
Position2D GetPosition() const;
double GetFov() const;
double GetDeltaAngle() const;
Expand All @@ -56,14 +56,15 @@ class Camera2D
void InitRays();
void Calculate(const std::shared_ptr<IGameObject>& object);
double WorldAngleToCameraAngle(double angle) const;

Camera2DConfig config_;
std::shared_ptr<RayVector> rays_;
std::unordered_map<std::string, RayPair> objects_;
Position2D position_;
std::shared_ptr<RayCaster> ray_cast_;
std::shared_ptr<RayVector> rays_;
std::shared_ptr<Ray> crosshair_ray_;
Position2D position_;
std::unordered_map<std::string, RayPair> objects_;
};

} // namespace wolfenstein

#endif // CAMERA_CAMERA_H
#endif // CAMERA_INCLUDE_CAMERA_H
1 change: 1 addition & 0 deletions src/Camera/include/Camera/ray.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#define CAMERA_INCLUDE_CAMERA_RAY_H_

#include <Math/vector.h>

#include <vector>

namespace wolfenstein {
Expand Down
11 changes: 6 additions & 5 deletions src/Camera/include/Camera/raycaster.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
*
*/

#ifndef CAMERA_INCLUDE_RAYCASTER_H_
#define CAMERA_INCLUDE_RAYCASTER_H_
#ifndef CAMERA_INCLUDE_CAMERA_RAYCASTER_H_
#define CAMERA_INCLUDE_CAMERA_RAYCASTER_H_

#include "Camera/ray.h"
#include <Camera/ray.h>
#include <Characters/character.h>
#include <Map/map.h>
#include <Math/vector.h>

#include <memory>

namespace wolfenstein {
Expand All @@ -24,7 +25,7 @@ class RayCaster
{
public:
RayCaster(const int num_ray, const double fov, const double depth);
~RayCaster();
~RayCaster() = default;

void Update(const std::shared_ptr<Map>& map_ptr, const Position2D& position,
const std::shared_ptr<RayVector>& rays);
Expand All @@ -46,4 +47,4 @@ class RayCaster

} // namespace wolfenstein

#endif // CAMERA_INCLUDE_RAYCASTER_H_
#endif // CAMERA_INCLUDE_CAMERA_RAYCASTER_H_
11 changes: 6 additions & 5 deletions src/Camera/src/camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
*
*/

#include "Camera/camera.h"
#include "Camera/ray.h"
#include "Math/vector.h"
#include <Camera/camera.h>
#include <Camera/ray.h>
#include <Math/vector.h>
#include <TextureManager/texture_manager.h>

#include <cmath>
#include <string>

Expand All @@ -39,7 +40,7 @@ void Camera2D::Update(const std::shared_ptr<Scene>& scene) {
// Update object rays
objects_.clear();
for (const auto& object : scene->GetObjects()) {
if (object->GetObjectType() == ObjectType::STATIC_OBJECT) {
if (object->GetObjectType() != ObjectType::CHARACTER_PLAYER) {
Calculate(object);
}
}
Expand All @@ -49,7 +50,7 @@ std::shared_ptr<RayVector> Camera2D::GetRays() const {
return rays_;
}

std::optional<RayPair> Camera2D::GetObjectRay(std::string id) {
std::optional<RayPair> Camera2D::GetObjectRay(const std::string id) {
if (objects_.find(id) != objects_.end()) {
return objects_[id];
}
Expand Down
3 changes: 2 additions & 1 deletion src/Camera/src/ray.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "Camera/ray.h"
#include <Camera/ray.h>

#include <cmath>

namespace wolfenstein {
Expand Down
5 changes: 2 additions & 3 deletions src/Camera/src/raycaster.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "Camera/raycaster.h"
#include <Camera/raycaster.h>

#include <cmath>
#include <vector>

Expand All @@ -10,8 +11,6 @@ RayCaster::RayCaster(const int num_ray, const double fov, const double depth)
depth_(depth),
delta_theta_(fov_ / num_ray) {}

RayCaster::~RayCaster() {}

void RayCaster::Update(const std::shared_ptr<Map>& map_ptr,
const Position2D& position,
const std::shared_ptr<RayVector>& rays) {
Expand Down
22 changes: 0 additions & 22 deletions src/Characters/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ link_directories(
${CMAKE_CURRENT_SOURCE_DIR}/include
)

# Math library
add_library(
character
STATIC
src/player.cpp
src/enemy.cpp
)

# Specify include directories for this library
target_include_directories(character PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/include
Expand All @@ -25,23 +23,3 @@ target_link_libraries(
collision_manager
)


# Math library
add_library(
player
STATIC
src/player.cpp
)

# Specify include directories for this library
target_include_directories(player PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/include
)

target_link_libraries(
player
PUBLIC
character
collision_manager
)
9 changes: 3 additions & 6 deletions src/Characters/include/Characters/character.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
*
*/

#ifndef CHARACTERS_CHARACTER_H
#define CHARACTERS_CHARACTER_H
#ifndef CHARACTERS_INCLUDE_CHARACTER_H
#define CHARACTERS_INCLUDE_CHARACTER_H

#include <GameObjects/game_object.h>

Expand All @@ -34,7 +34,6 @@ struct CharacterConfig
double rotation_speed;
};

// Character.h
class ICharacter
{
public:
Expand All @@ -43,9 +42,7 @@ class ICharacter
virtual void SetPosition(Position2D position) = 0;
virtual Position2D GetPosition() const = 0;

private:
// Character specific data
};
} // namespace wolfenstein

#endif // CHARACTERS_CHARACTER_H
#endif // CHARACTERS_INCLUDE_CHARACTER_H
12 changes: 6 additions & 6 deletions src/Characters/include/Characters/enemy.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@
*
*/

#ifndef CHARACTERS_ENEMY_H_
#define CHARACTERS_ENEMY_H_
#ifndef CHARACTERS_INCLUDE_ENEMY_H_
#define CHARACTERS_INCLUDE_ENEMY_H_

#include "character.h"
#include <Utility/uuid_generator.h>
#include <Characters/character.h>

namespace wolfenstein {

Expand All @@ -26,9 +25,10 @@ class Enemy : public ICharacter, public IGameObject
void Update(double delta_time) override;

void SetPose(const vector2d& pose) override;
void SetPosition(Position2D position) override;

ObjectType GetObjectType() const override;
vector2d GetPose() const override;
void SetPosition(Position2D position) override;
Position2D GetPosition() const override;
std::string GetId() const override;

Expand All @@ -41,4 +41,4 @@ class Enemy : public ICharacter, public IGameObject

} // namespace wolfenstein

#endif // CHARACTERS_ENEMY_H_
#endif // CHARACTERS_INCLUDE_ENEMY_H_
3 changes: 1 addition & 2 deletions src/Characters/include/Characters/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
#ifndef CHARACTERS_PLAYER_H
#define CHARACTERS_PLAYER_H

#include "character.h"
#include <Utility/uuid_generator.h>
#include <Characters/character.h>
#include <functional>

namespace wolfenstein {
Expand Down
4 changes: 2 additions & 2 deletions src/Characters/src/enemy.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "Characters/enemy.h"
#include <Characters/enemy.h>
#include <Utility/uuid_generator.h>

namespace wolfenstein {

Expand Down Expand Up @@ -36,7 +37,6 @@ std::string Enemy::GetId() const {

void Enemy::Move(double delta_time) {
(void)delta_time;
// Move enemy
}

} // namespace wolfenstein
7 changes: 4 additions & 3 deletions src/Characters/src/player.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#include "Characters/player.h"
#include "CollisionManager/collision_manager.h"
#include "Math/vector.h"
#include <Characters/player.h>
#include <CollisionManager/collision_manager.h>
#include <Math/vector.h>
#include <SDL2/SDL.h>
#include <Utility/uuid_generator.h>

namespace wolfenstein {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
*
*/

#ifndef COLLISION_MANAGER_COLLISION_MANAGER_H
#define COLLISION_MANAGER_COLLISION_MANAGER_H
#ifndef COLLISION_MANAGER_INCLUDE_COLLISION_MANAGER_H
#define COLLISION_MANAGER_INCLUDE_COLLISION_MANAGER_H

#include "Map/map.h"
#include <GameObjects/game_object.h>
#include <Map/map.h>
#include <Math/vector.h>
#include <memory>

Expand Down Expand Up @@ -44,4 +44,4 @@ class CollisionManager
};
} // namespace wolfenstein

#endif // COLLISION_MANAGER_COLLISION_MANAGER_H
#endif // COLLISION_MANAGER_INCLUDE_COLLISION_MANAGER_H
2 changes: 1 addition & 1 deletion src/CollisionManager/src/collision_manager.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "CollisionManager/collision_manager.h"
#include <CollisionManager/collision_manager.h>
#include <cassert>

namespace wolfenstein {
Expand Down
1 change: 0 additions & 1 deletion src/Core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ target_link_libraries(
texture_manager
camera
character
player
game_object
map
vector
Expand Down
6 changes: 3 additions & 3 deletions src/Core/include/Core/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
*
*/

#ifndef CORE_GAME_H_
#define CORE_GAME_H_
#ifndef CORE_INCLUDE_CORE_GAME_H_
#define CORE_INCLUDE_CORE_GAME_H_

#include <Camera/camera.h>
#include <Characters/player.h>
Expand Down Expand Up @@ -65,4 +65,4 @@ class Game

} // namespace wolfenstein

#endif // CORE_GAME_H_
#endif // CORE_INCLUDE_CORE_GAME_H_
Loading