Skip to content

Commit

Permalink
Capabilities and Game folder
Browse files Browse the repository at this point in the history
  • Loading branch information
curzel-it committed Jun 23, 2024
1 parent 1d70685 commit 5ecb066
Show file tree
Hide file tree
Showing 16 changed files with 35 additions and 25 deletions.
24 changes: 18 additions & 6 deletions Sources/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,28 @@ set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED True)

include_directories("src")
include_directories("src/sprites")
include_directories("src/capabilities")
include_directories("src/game")
include_directories("src/species")
include_directories("src/sprites")
include_directories("src/utils")

# Get all sources except tests
file(GLOB MAIN_SOURCES "src/*.cpp")
list(FILTER MAIN_SOURCES EXCLUDE REGEX ".*_tests\\.cpp$")

file(GLOB SPRITES_SOURCES "src/sprites/*.cpp")
list(FILTER SPRITES_SOURCES EXCLUDE REGEX ".*_tests\\.cpp$")
file(GLOB CAPABILITIES_SOURCES "src/capabilities/*.cpp")
list(FILTER CAPABILITIES_SOURCES EXCLUDE REGEX ".*_tests\\.cpp$")

file(GLOB GAME_SOURCES "src/game/*.cpp")
list(FILTER GAME_SOURCES EXCLUDE REGEX ".*_tests\\.cpp$")

file(GLOB SPECIES_SOURCES "src/species/*.cpp")
list(FILTER SPECIES_SOURCES EXCLUDE REGEX ".*_tests\\.cpp$")

file(GLOB SPRITES_SOURCES "src/sprites/*.cpp")
list(FILTER SPRITES_SOURCES EXCLUDE REGEX ".*_tests\\.cpp$")

file(GLOB UTILS_SOURCES "src/utils/*.cpp")
list(FILTER UTILS_SOURCES EXCLUDE REGEX ".*_tests\\.cpp$")

Expand All @@ -33,7 +41,7 @@ find_package(Qt6 COMPONENTS Widgets REQUIRED)
find_package(nlohmann_json 3.2.0 REQUIRED)

# App executable
add_executable(Main ${MAIN_SOURCES} ${UTILS_SOURCES} ${SPECIES_SOURCES} ${SPRITES_SOURCES})
add_executable(Main ${MAIN_SOURCES} ${CAPABILITIES_SOURCES} ${GAME_SOURCES} ${SPECIES_SOURCES} ${SPRITES_SOURCES} ${UTILS_SOURCES})
target_link_libraries(Main PRIVATE nlohmann_json::nlohmann_json Qt6::Widgets)

# Google Test
Expand All @@ -45,14 +53,18 @@ include(GoogleTest)
file(GLOB TEST_SOURCES "src/*.cpp")
list(FILTER TEST_SOURCES EXCLUDE REGEX ".*main\\.cpp$")

file(GLOB TEST_SPRITES_SOURCES "src/sprites/*.cpp")
file(GLOB TEST_CAPABILITIES_SOURCES "src/capabilities/*.cpp")

file(GLOB TEST_GAME_SOURCES "src/game/*.cpp")

file(GLOB TEST_SPECIES_SOURCES "src/species/*.cpp")

file(GLOB TEST_SPRITES_SOURCES "src/sprites/*.cpp")

file(GLOB TEST_UTILS_SOURCES "src/utils/*.cpp")

# Test executable
add_executable(Test ${TEST_SOURCES} ${TEST_SPRITES_SOURCES} ${TEST_SPECIES_SOURCES} ${TEST_UTILS_SOURCES})
add_executable(Test ${TEST_SOURCES} ${TEST_CAPABILITIES_SOURCES} ${TEST_GAME_SOURCES} ${TEST_SPECIES_SOURCES} ${TEST_SPRITES_SOURCES} ${TEST_UTILS_SOURCES})
target_link_libraries(Test GTest::GTest GTest::Main Qt6::Widgets)

# Test discovery
Expand Down
2 changes: 1 addition & 1 deletion Sources/cpp/src/app_window.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "app_window.h"
#include "geometry.h"
#include "game/game.h"
#include "utils/utils.h"
#include "sprites/sprites.h"

Expand Down
1 change: 1 addition & 0 deletions Sources/cpp/src/capabilities/capabilities.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "linear_movement.h"
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <chrono>
#include <iostream>

#include "geometry.h"
#include "../game/game.h"

void LinearMovement::update(std::chrono::milliseconds timeSinceLastUpdate, Entity * entity) {
auto frameDuration = std::chrono::duration_cast<std::chrono::milliseconds>(timeSinceLastUpdate).count();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <chrono>

#include "entity.h"
#include "../game/game.h"

class LinearMovement : public EntityCapability {
public:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
#include <string>
#include <vector>

#include "geometry.h"
#include "linear_movement.h"
#include "sprites/sprites.h"
#include "utils/utils.h"
#include "../game/game.h"
#include "../capabilities/capabilities.h"
#include "../sprites/sprites.h"
#include "../utils/utils.h"

Entity::Entity(
double fps,
Expand Down
4 changes: 2 additions & 2 deletions Sources/cpp/src/entity.h → Sources/cpp/src/game/entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#include <vector>

#include "geometry.h"
#include "species/species.h"
#include "sprites/sprites.h"
#include "../species/species.h"
#include "../sprites/sprites.h"

class EntityCapability;

Expand Down
2 changes: 1 addition & 1 deletion Sources/cpp/src/game.cpp → Sources/cpp/src/game/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <sstream>

#include "geometry.h"
#include "utils/utils.h"
#include "../utils/utils.h"

RenderedItem::RenderedItem(std::string spritePath, Rect frame) : spritePath(spritePath), frame(frame) {}

Expand Down
1 change: 1 addition & 0 deletions Sources/cpp/src/game.h → Sources/cpp/src/game/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <vector>

#include "entity.h"
#include "geometry.h"

struct RenderedItem {
std::string spritePath;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "game.h"
#include "geometry.h"
#include "species/species.h"
#include "sprites/sprites.h"
#include "../species/species.h"
#include "../sprites/sprites.h"

#include <chrono>
#include <gtest/gtest.h>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 1 addition & 2 deletions Sources/cpp/src/game_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@

#include <format>

#include "game.h"
#include "game/game.h"
#include "game_window.h"
#include "geometry.h"
#include "utils/utils.h"
#include "sprites/sprites.h"

Expand Down
3 changes: 1 addition & 2 deletions Sources/cpp/src/game_window.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#ifndef GAME_WINDOW_H
#define GAME_WINDOW_H

#include "game.h"
#include "geometry.h"
#include "game/game.h"

#include <QGraphicsScene>
#include <QLabel>
Expand Down
4 changes: 1 addition & 3 deletions Sources/cpp/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
#include <thread>

#include "app_window.h"
#include "game.h"
#include "game/game.h"
#include "game_window.h"
#include "geometry.h"
#include "entity.h"

#include "species/species.h"
#include "sprites/sprites.h"
Expand Down

0 comments on commit 5ecb066

Please sign in to comment.