diff --git a/.gitignore b/.gitignore index 6b1f226..023fa27 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ xcuserdata/ *.xcscmblueprint *.xccheckout +.vscode/ # Compiled Object files *.slo @@ -40,3 +41,6 @@ xcuserdata/ *.exe *.out *.app +build/ + + diff --git a/1 - Game Loop/CMakeLists.txt b/1 - Game Loop/CMakeLists.txt new file mode 100644 index 0000000..e528a3c --- /dev/null +++ b/1 - Game Loop/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.16) + +project(gameLoop_1) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") + +find_package(SFML 2.5 COMPONENTS audio graphics window system REQUIRED) + +set(APP_SOURCES + src/Main.cpp + src/Game.cpp + src/Window.cpp +) + +add_executable(${PROJECT_NAME} ${APP_SOURCES}) +target_link_libraries(${PROJECT_NAME} sfml-audio sfml-graphics sfml-window sfml-system) diff --git a/1 - Game Loop/src/Game.hpp b/1 - Game Loop/src/Game.hpp index de80644..4068978 100644 --- a/1 - Game Loop/src/Game.hpp +++ b/1 - Game Loop/src/Game.hpp @@ -3,7 +3,6 @@ #include -#include "WorkingDirectory.hpp" #include "Window.hpp" #include diff --git a/10 - Object Management/CMakeLists.txt b/10 - Object Management/CMakeLists.txt new file mode 100644 index 0000000..9b897c8 --- /dev/null +++ b/10 - Object Management/CMakeLists.txt @@ -0,0 +1,29 @@ +cmake_minimum_required(VERSION 3.16) + +project(objMgmt_10) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") + +find_package(SFML 2.5 COMPONENTS audio graphics window system REQUIRED) + +set(APP_SOURCES + src/Bitmask.cpp + src/C_KeyboardMovement.cpp + src/C_Sprite.cpp + src/C_Transform.cpp + src/Game.cpp + src/Input.cpp + src/Main.cpp + src/Object.cpp + src/ObjectCollection.cpp + src/SceneGame.cpp + src/SceneSplashScreen.cpp + src/SceneStateMachine.cpp + src/Window.cpp + src/WorkingDirectory.cpp +) + +file(COPY resources DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) +add_executable(${PROJECT_NAME} ${APP_SOURCES}) +target_link_libraries(${PROJECT_NAME} sfml-audio sfml-graphics sfml-window sfml-system) diff --git a/10 - Object Management/src/Object.hpp b/10 - Object Management/src/Object.hpp index f5f0efe..f1cc304 100644 --- a/10 - Object Management/src/Object.hpp +++ b/10 - Object Management/src/Object.hpp @@ -1,6 +1,7 @@ #ifndef Object_hpp #define Object_hpp +#include #include #include "Window.hpp" diff --git a/10 - Object Management/src/WorkingDirectory.cpp b/10 - Object Management/src/WorkingDirectory.cpp index 1cbb124..6bb8207 100644 --- a/10 - Object Management/src/WorkingDirectory.cpp +++ b/10 - Object Management/src/WorkingDirectory.cpp @@ -2,7 +2,7 @@ WorkingDirectory::WorkingDirectory() { - path = "./"; + path = "./resources/"; #ifdef MACOS diff --git a/11 - Animation Part 1/CMakeLists.txt b/11 - Animation Part 1/CMakeLists.txt new file mode 100644 index 0000000..7adc9e5 --- /dev/null +++ b/11 - Animation Part 1/CMakeLists.txt @@ -0,0 +1,31 @@ +cmake_minimum_required(VERSION 3.16) + +project(animationsP1_11) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") + +find_package(SFML 2.5 COMPONENTS audio graphics window system REQUIRED) + +set(APP_SOURCES + src/Animation.cpp + src/Bitmask.cpp + src/C_Animation.cpp + src/C_KeyboardMovement.cpp + src/C_Sprite.cpp + src/C_Transform.cpp + src/Game.cpp + src/Input.cpp + src/Main.cpp + src/Object.cpp + src/ObjectCollection.cpp + src/SceneGame.cpp + src/SceneSplashScreen.cpp + src/SceneStateMachine.cpp + src/Window.cpp + src/WorkingDirectory.cpp +) + +file(COPY resources DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) +add_executable(${PROJECT_NAME} ${APP_SOURCES}) +target_link_libraries(${PROJECT_NAME} sfml-audio sfml-graphics sfml-window sfml-system) diff --git a/11 - Animation Part 1/resources/Viking.json b/11 - Animation Part 1/resources/Viking.json deleted file mode 100644 index 8fe1f78..0000000 --- a/11 - Animation Part 1/resources/Viking.json +++ /dev/null @@ -1,183 +0,0 @@ -{"frames": [ - -{ - "filename": "attack_0.png", - "frame": {"x":0,"y":0,"w":200,"h":145}, - "rotated": false, - "trimmed": false, - "spriteSourceSize": {"x":0,"y":0,"w":200,"h":145}, - "sourceSize": {"w":200,"h":145}, - "pivot": {"x":0.5,"y":0.5} -}, -{ - "filename": "attack_1.png", - "frame": {"x":200,"y":0,"w":200,"h":145}, - "rotated": false, - "trimmed": false, - "spriteSourceSize": {"x":0,"y":0,"w":200,"h":145}, - "sourceSize": {"w":200,"h":145}, - "pivot": {"x":0.5,"y":0.5} -}, -{ - "filename": "attack_2.png", - "frame": {"x":400,"y":0,"w":200,"h":145}, - "rotated": false, - "trimmed": false, - "spriteSourceSize": {"x":0,"y":0,"w":200,"h":145}, - "sourceSize": {"w":200,"h":145}, - "pivot": {"x":0.5,"y":0.5} -}, -{ - "filename": "idle_0.png", - "frame": {"x":600,"y":0,"w":200,"h":145}, - "rotated": false, - "trimmed": false, - "spriteSourceSize": {"x":0,"y":0,"w":200,"h":145}, - "sourceSize": {"w":200,"h":145}, - "pivot": {"x":0.5,"y":0.5} -}, -{ - "filename": "idle_1.png", - "frame": {"x":800,"y":0,"w":200,"h":145}, - "rotated": false, - "trimmed": false, - "spriteSourceSize": {"x":0,"y":0,"w":200,"h":145}, - "sourceSize": {"w":200,"h":145}, - "pivot": {"x":0.5,"y":0.5} -}, -{ - "filename": "idle_2.png", - "frame": {"x":0,"y":145,"w":200,"h":145}, - "rotated": false, - "trimmed": false, - "spriteSourceSize": {"x":0,"y":0,"w":200,"h":145}, - "sourceSize": {"w":200,"h":145}, - "pivot": {"x":0.5,"y":0.5} -}, -{ - "filename": "idle_3.png", - "frame": {"x":200,"y":145,"w":200,"h":145}, - "rotated": false, - "trimmed": false, - "spriteSourceSize": {"x":0,"y":0,"w":200,"h":145}, - "sourceSize": {"w":200,"h":145}, - "pivot": {"x":0.5,"y":0.5} -}, -{ - "filename": "jump_0.png", - "frame": {"x":400,"y":145,"w":200,"h":145}, - "rotated": false, - "trimmed": false, - "spriteSourceSize": {"x":0,"y":0,"w":200,"h":145}, - "sourceSize": {"w":200,"h":145}, - "pivot": {"x":0.5,"y":0.5} -}, -{ - "filename": "jump_1.png", - "frame": {"x":600,"y":145,"w":200,"h":145}, - "rotated": false, - "trimmed": false, - "spriteSourceSize": {"x":0,"y":0,"w":200,"h":145}, - "sourceSize": {"w":200,"h":145}, - "pivot": {"x":0.5,"y":0.5} -}, -{ - "filename": "jump_2.png", - "frame": {"x":800,"y":145,"w":200,"h":145}, - "rotated": false, - "trimmed": false, - "spriteSourceSize": {"x":0,"y":0,"w":200,"h":145}, - "sourceSize": {"w":200,"h":145}, - "pivot": {"x":0.5,"y":0.5} -}, -{ - "filename": "jump_3.png", - "frame": {"x":0,"y":290,"w":200,"h":145}, - "rotated": false, - "trimmed": false, - "spriteSourceSize": {"x":0,"y":0,"w":200,"h":145}, - "sourceSize": {"w":200,"h":145}, - "pivot": {"x":0.5,"y":0.5} -}, -{ - "filename": "jump_4.png", - "frame": {"x":200,"y":290,"w":200,"h":145}, - "rotated": false, - "trimmed": false, - "spriteSourceSize": {"x":0,"y":0,"w":200,"h":145}, - "sourceSize": {"w":200,"h":145}, - "pivot": {"x":0.5,"y":0.5} -}, -{ - "filename": "jump_5.png", - "frame": {"x":400,"y":290,"w":200,"h":145}, - "rotated": false, - "trimmed": false, - "spriteSourceSize": {"x":0,"y":0,"w":200,"h":145}, - "sourceSize": {"w":200,"h":145}, - "pivot": {"x":0.5,"y":0.5} -}, -{ - "filename": "run_0.png", - "frame": {"x":600,"y":290,"w":200,"h":145}, - "rotated": false, - "trimmed": false, - "spriteSourceSize": {"x":0,"y":0,"w":200,"h":145}, - "sourceSize": {"w":200,"h":145}, - "pivot": {"x":0.5,"y":0.5} -}, -{ - "filename": "run_1.png", - "frame": {"x":800,"y":290,"w":200,"h":145}, - "rotated": false, - "trimmed": false, - "spriteSourceSize": {"x":0,"y":0,"w":200,"h":145}, - "sourceSize": {"w":200,"h":145}, - "pivot": {"x":0.5,"y":0.5} -}, -{ - "filename": "run_2.png", - "frame": {"x":0,"y":435,"w":200,"h":145}, - "rotated": false, - "trimmed": false, - "spriteSourceSize": {"x":0,"y":0,"w":200,"h":145}, - "sourceSize": {"w":200,"h":145}, - "pivot": {"x":0.5,"y":0.5} -}, -{ - "filename": "run_3.png", - "frame": {"x":200,"y":435,"w":200,"h":145}, - "rotated": false, - "trimmed": false, - "spriteSourceSize": {"x":0,"y":0,"w":200,"h":145}, - "sourceSize": {"w":200,"h":145}, - "pivot": {"x":0.5,"y":0.5} -}, -{ - "filename": "run_4.png", - "frame": {"x":400,"y":435,"w":200,"h":145}, - "rotated": false, - "trimmed": false, - "spriteSourceSize": {"x":0,"y":0,"w":200,"h":145}, - "sourceSize": {"w":200,"h":145}, - "pivot": {"x":0.5,"y":0.5} -}, -{ - "filename": "run_5.png", - "frame": {"x":600,"y":435,"w":200,"h":145}, - "rotated": false, - "trimmed": false, - "spriteSourceSize": {"x":0,"y":0,"w":200,"h":145}, - "sourceSize": {"w":200,"h":145}, - "pivot": {"x":0.5,"y":0.5} -}], -"meta": { - "app": "https://www.codeandweb.com/texturepacker", - "version": "1.0", - "image": "Viking.png", - "format": "RGBA8888", - "size": {"w":1000,"h":580}, - "scale": "1", - "smartupdate": "$TexturePacker:SmartUpdate:faeaa13596034d08083436ea66f24413:0d097659d4a2cf5e39f760e16f4e7ee1:d64eee29f56c425b737f70fc9128c68e$" -} -} diff --git a/11 - Animation Part 1/src/Object.hpp b/11 - Animation Part 1/src/Object.hpp index 4d14673..2d8d210 100644 --- a/11 - Animation Part 1/src/Object.hpp +++ b/11 - Animation Part 1/src/Object.hpp @@ -1,6 +1,7 @@ #ifndef Object_hpp #define Object_hpp +#include #include #include "Window.hpp" diff --git a/11 - Animation Part 1/src/WorkingDirectory.cpp b/11 - Animation Part 1/src/WorkingDirectory.cpp index 1cbb124..6bb8207 100644 --- a/11 - Animation Part 1/src/WorkingDirectory.cpp +++ b/11 - Animation Part 1/src/WorkingDirectory.cpp @@ -2,7 +2,7 @@ WorkingDirectory::WorkingDirectory() { - path = "./"; + path = "./resources/"; #ifdef MACOS diff --git a/11 - Animation Part 1/src/knight.png b/11 - Animation Part 1/src/knight.png deleted file mode 100755 index 556eb51..0000000 Binary files a/11 - Animation Part 1/src/knight.png and /dev/null differ diff --git a/11 - Animation Part 1/src/that_games_guy_logo.png b/11 - Animation Part 1/src/that_games_guy_logo.png deleted file mode 100644 index 7a21586..0000000 Binary files a/11 - Animation Part 1/src/that_games_guy_logo.png and /dev/null differ diff --git a/11 - Animation Part 1/src/viking.png b/11 - Animation Part 1/src/viking.png deleted file mode 100644 index 66ed11c..0000000 Binary files a/11 - Animation Part 1/src/viking.png and /dev/null differ diff --git a/12 - Animation Part 2/CMakeLists.txt b/12 - Animation Part 2/CMakeLists.txt new file mode 100644 index 0000000..3b75287 --- /dev/null +++ b/12 - Animation Part 2/CMakeLists.txt @@ -0,0 +1,31 @@ +cmake_minimum_required(VERSION 3.16) + +project(animationsP2_12) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") + +find_package(SFML 2.5 COMPONENTS audio graphics window system REQUIRED) + +set(APP_SOURCES + src/Animation.cpp + src/Bitmask.cpp + src/C_Animation.cpp + src/C_KeyboardMovement.cpp + src/C_Sprite.cpp + src/C_Transform.cpp + src/Game.cpp + src/Input.cpp + src/Main.cpp + src/Object.cpp + src/ObjectCollection.cpp + src/SceneGame.cpp + src/SceneSplashScreen.cpp + src/SceneStateMachine.cpp + src/Window.cpp + src/WorkingDirectory.cpp +) + +file(COPY resources DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) +add_executable(${PROJECT_NAME} ${APP_SOURCES}) +target_link_libraries(${PROJECT_NAME} sfml-audio sfml-graphics sfml-window sfml-system) diff --git a/12 - Animation Part 2/src/Object.hpp b/12 - Animation Part 2/src/Object.hpp index 4d14673..2d8d210 100644 --- a/12 - Animation Part 2/src/Object.hpp +++ b/12 - Animation Part 2/src/Object.hpp @@ -1,6 +1,7 @@ #ifndef Object_hpp #define Object_hpp +#include #include #include "Window.hpp" diff --git a/12 - Animation Part 2/src/WorkingDirectory.cpp b/12 - Animation Part 2/src/WorkingDirectory.cpp index 1cbb124..6bb8207 100644 --- a/12 - Animation Part 2/src/WorkingDirectory.cpp +++ b/12 - Animation Part 2/src/WorkingDirectory.cpp @@ -2,7 +2,7 @@ WorkingDirectory::WorkingDirectory() { - path = "./"; + path = "./resources/"; #ifdef MACOS diff --git a/2 - First Draw/CMakeLists.txt b/2 - First Draw/CMakeLists.txt new file mode 100644 index 0000000..d8b4d97 --- /dev/null +++ b/2 - First Draw/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 3.16) + +project(firstDraw_2) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") + +find_package(SFML 2.5 COMPONENTS audio graphics window system REQUIRED) + +set(APP_SOURCES + src/Main.cpp + src/Game.cpp + src/Window.cpp + src/WorkingDirectory.cpp +) + +file(COPY resources DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) +add_executable(${PROJECT_NAME} ${APP_SOURCES}) +target_link_libraries(${PROJECT_NAME} sfml-audio sfml-graphics sfml-window sfml-system) diff --git a/2 - First Draw/src/WorkingDirectory.cpp b/2 - First Draw/src/WorkingDirectory.cpp index 1cbb124..6bb8207 100644 --- a/2 - First Draw/src/WorkingDirectory.cpp +++ b/2 - First Draw/src/WorkingDirectory.cpp @@ -2,7 +2,7 @@ WorkingDirectory::WorkingDirectory() { - path = "./"; + path = "./resources/"; #ifdef MACOS diff --git a/3 - Frame Independent Movement/CMakeLists.txt b/3 - Frame Independent Movement/CMakeLists.txt new file mode 100644 index 0000000..280976c --- /dev/null +++ b/3 - Frame Independent Movement/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 3.16) + +project(frameIndipendentMov_3) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") + +find_package(SFML 2.5 COMPONENTS audio graphics window system REQUIRED) + +set(APP_SOURCES + src/Main.cpp + src/Game.cpp + src/Window.cpp + src/WorkingDirectory.cpp +) + +file(COPY resources DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) +add_executable(${PROJECT_NAME} ${APP_SOURCES}) +target_link_libraries(${PROJECT_NAME} sfml-audio sfml-graphics sfml-window sfml-system) diff --git a/3 - Frame Independent Movement/src/WorkingDirectory.cpp b/3 - Frame Independent Movement/src/WorkingDirectory.cpp index 1cbb124..6bb8207 100644 --- a/3 - Frame Independent Movement/src/WorkingDirectory.cpp +++ b/3 - Frame Independent Movement/src/WorkingDirectory.cpp @@ -2,7 +2,7 @@ WorkingDirectory::WorkingDirectory() { - path = "./"; + path = "./resources/"; #ifdef MACOS diff --git a/4 - Bitmasks/CMakeLists.txt b/4 - Bitmasks/CMakeLists.txt new file mode 100644 index 0000000..66691e2 --- /dev/null +++ b/4 - Bitmasks/CMakeLists.txt @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 3.16) + +project(bitmask_4) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") + +find_package(SFML 2.5 COMPONENTS audio graphics window system REQUIRED) + +set(APP_SOURCES + src/Main.cpp + src/Game.cpp + src/Window.cpp + src/WorkingDirectory.cpp + src/Bitmask.cpp +) + +file(COPY resources DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) +add_executable(${PROJECT_NAME} ${APP_SOURCES}) +target_link_libraries(${PROJECT_NAME} sfml-audio sfml-graphics sfml-window sfml-system) diff --git a/4 - Bitmasks/src/Game.hpp b/4 - Bitmasks/src/Game.hpp index 01e18ba..962dc63 100644 --- a/4 - Bitmasks/src/Game.hpp +++ b/4 - Bitmasks/src/Game.hpp @@ -5,30 +5,27 @@ #include "WorkingDirectory.hpp" #include "Window.hpp" -#include "Input.hpp" class Game { public: Game(); - + void Update(); void LateUpdate(); void Draw(); void CalculateDeltaTime(); bool IsRunning() const; - + private: Window window; WorkingDirectory workingDir; - + sf::Texture vikingTexture; sf::Sprite vikingSprite; sf::Clock clock; float deltaTime; - - Input input; }; #endif /* Game_hpp */ diff --git a/4 - Bitmasks/src/WorkingDirectory.cpp b/4 - Bitmasks/src/WorkingDirectory.cpp index 1cbb124..6bb8207 100644 --- a/4 - Bitmasks/src/WorkingDirectory.cpp +++ b/4 - Bitmasks/src/WorkingDirectory.cpp @@ -2,7 +2,7 @@ WorkingDirectory::WorkingDirectory() { - path = "./"; + path = "./resources/"; #ifdef MACOS diff --git a/5 - Real Time Input/CMakeLists.txt b/5 - Real Time Input/CMakeLists.txt new file mode 100644 index 0000000..88f7323 --- /dev/null +++ b/5 - Real Time Input/CMakeLists.txt @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 3.16) + +project(input_5) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") + +find_package(SFML 2.5 COMPONENTS audio graphics window system REQUIRED) + +set(APP_SOURCES + src/Main.cpp + src/Game.cpp + src/Window.cpp + src/WorkingDirectory.cpp + src/Bitmask.cpp + src/Input.cpp +) + +file(COPY resources DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) +add_executable(${PROJECT_NAME} ${APP_SOURCES}) +target_link_libraries(${PROJECT_NAME} sfml-audio sfml-graphics sfml-window sfml-system) diff --git a/5 - Real Time Input/src/WorkingDirectory.cpp b/5 - Real Time Input/src/WorkingDirectory.cpp index 1cbb124..6bb8207 100644 --- a/5 - Real Time Input/src/WorkingDirectory.cpp +++ b/5 - Real Time Input/src/WorkingDirectory.cpp @@ -2,7 +2,7 @@ WorkingDirectory::WorkingDirectory() { - path = "./"; + path = "./resources/"; #ifdef MACOS diff --git a/6 - Scene Management/CMakeLists.txt b/6 - Scene Management/CMakeLists.txt new file mode 100644 index 0000000..e63ec5a --- /dev/null +++ b/6 - Scene Management/CMakeLists.txt @@ -0,0 +1,24 @@ +cmake_minimum_required(VERSION 3.16) + +project(sceneManager_6) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") + +find_package(SFML 2.5 COMPONENTS audio graphics window system REQUIRED) + +set(APP_SOURCES + src/Bitmask.cpp + src/Game.cpp + src/Input.cpp + src/Main.cpp + src/SceneGame.cpp + src/SceneSplashScreen.cpp + src/SceneStateMachine.cpp + src/Window.cpp + src/WorkingDirectory.cpp +) + +file(COPY resources DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) +add_executable(${PROJECT_NAME} ${APP_SOURCES}) +target_link_libraries(${PROJECT_NAME} sfml-audio sfml-graphics sfml-window sfml-system) diff --git a/6 - Scene Management/src/Game.cpp b/6 - Scene Management/src/Game.cpp index bd91724..d308ab8 100644 --- a/6 - Scene Management/src/Game.cpp +++ b/6 - Scene Management/src/Game.cpp @@ -2,19 +2,18 @@ Game::Game() : window("that game engine") { - std::shared_ptr splashScreen = std::make_shared(workingDir, sceneStateMachine, window); - + std::shared_ptr splashScreen = std::make_shared(workingDir, sceneManager, window); + std::shared_ptr gameScene = std::make_shared(workingDir); - - unsigned int splashScreenID = sceneStateMachine.Add(splashScreen); - unsigned int gameSceneID = sceneStateMachine.Add(gameScene); - + + unsigned int splashScreenID = sceneManager.Add(splashScreen); + unsigned int gameSceneID = sceneManager.Add(gameScene); + splashScreen->SetSwitchToScene(gameSceneID); - - sceneStateMachine.SwitchTo(splashScreenID); - - deltaTime = clock.restart().asSeconds(); + sceneManager.SwitchTo(splashScreenID); + + deltaTime = clock.restart().asSeconds(); } void Game::CaptureInput() @@ -25,7 +24,7 @@ void Game::CaptureInput() void Game::Update() { window.Update(); - + sceneManager.Update(deltaTime); } @@ -37,9 +36,9 @@ void Game::LateUpdate() void Game::Draw() { window.BeginDraw(); - + sceneManager.Draw(window); - + window.EndDraw(); } diff --git a/6 - Scene Management/src/SceneSplashScreen.cpp b/6 - Scene Management/src/SceneSplashScreen.cpp index a6640f8..f4955aa 100644 --- a/6 - Scene Management/src/SceneSplashScreen.cpp +++ b/6 - Scene Management/src/SceneSplashScreen.cpp @@ -1,20 +1,19 @@ #include "SceneSplashScreen.hpp" -SceneSplashScreen::SceneSplashScreen(WorkingDirectory& workingDir, SceneStateMachine& sceneStateMachine, Window& window) -: sceneStateMachine(sceneStateMachine), workingDir(workingDir), window(window), switchToState(0), currentSeconds(0.f), showForSeconds(3.f) +SceneSplashScreen::SceneSplashScreen(WorkingDirectory &workingDir, SceneStateMachine &sceneStateMachine, Window &window) + : sceneStateMachine(sceneStateMachine), workingDir(workingDir), window(window), switchToState(0), currentSeconds(0.f), showForSeconds(3.f) { - } void SceneSplashScreen::OnCreate() { splashTexture.loadFromFile(workingDir.Get() + "that_games_guy_logo.png"); splashSprite.setTexture(splashTexture); - + sf::FloatRect spriteSize = splashSprite.getLocalBounds(); - splashSprite.setOrigin(spriteSize.width * 0.5f, spriteSize.height * 0.5f); / + splashSprite.setOrigin(spriteSize.width * 0.5f, spriteSize.height * 0.5f); splashSprite.setScale(0.5f, 0.5f); - + sf::Vector2u windowCentre = window.GetCentre(); splashSprite.setPosition(windowCentre.x, windowCentre.y); } @@ -24,7 +23,7 @@ void SceneSplashScreen::OnActivate() currentSeconds = 0.f; } -void SceneSplashScreen::OnDestroy() { } +void SceneSplashScreen::OnDestroy() {} void SceneSplashScreen::SetSwitchToScene(unsigned int id) { @@ -34,15 +33,14 @@ void SceneSplashScreen::SetSwitchToScene(unsigned int id) void SceneSplashScreen::Update(float deltaTime) { currentSeconds += deltaTime; - - if(currentSeconds >= showForSeconds) + + if (currentSeconds >= showForSeconds) { sceneStateMachine.SwitchTo(switchToState); } } -void SceneSplashScreen::Draw(Window& window) +void SceneSplashScreen::Draw(Window &window) { window.Draw(splashSprite); } - diff --git a/6 - Scene Management/src/WorkingDirectory.cpp b/6 - Scene Management/src/WorkingDirectory.cpp index 1cbb124..6bb8207 100644 --- a/6 - Scene Management/src/WorkingDirectory.cpp +++ b/6 - Scene Management/src/WorkingDirectory.cpp @@ -2,7 +2,7 @@ WorkingDirectory::WorkingDirectory() { - path = "./"; + path = "./resources/"; #ifdef MACOS diff --git a/7 - ECS Part 1/CMakeLists.txt b/7 - ECS Part 1/CMakeLists.txt new file mode 100644 index 0000000..9a51c68 --- /dev/null +++ b/7 - ECS Part 1/CMakeLists.txt @@ -0,0 +1,26 @@ +cmake_minimum_required(VERSION 3.16) + +project(ecsP1_7) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") + +find_package(SFML 2.5 COMPONENTS audio graphics window system REQUIRED) + +set(APP_SOURCES + src/Bitmask.cpp + src/C_Sprite.cpp + src/Game.cpp + src/Input.cpp + src/Main.cpp + src/Object.cpp + src/SceneGame.cpp + src/SceneSplashScreen.cpp + src/SceneStateMachine.cpp + src/Window.cpp + src/WorkingDirectory.cpp +) + +file(COPY resources DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) +add_executable(${PROJECT_NAME} ${APP_SOURCES}) +target_link_libraries(${PROJECT_NAME} sfml-audio sfml-graphics sfml-window sfml-system) diff --git a/7 - ECS Part 1/src/Object.hpp b/7 - ECS Part 1/src/Object.hpp index f32bd3e..015eebe 100644 --- a/7 - ECS Part 1/src/Object.hpp +++ b/7 - ECS Part 1/src/Object.hpp @@ -2,6 +2,7 @@ #define Object_hpp #include +#include #include "Window.hpp" #include "Component.hpp" diff --git a/7 - ECS Part 1/src/WorkingDirectory.cpp b/7 - ECS Part 1/src/WorkingDirectory.cpp index 1cbb124..6bb8207 100644 --- a/7 - ECS Part 1/src/WorkingDirectory.cpp +++ b/7 - ECS Part 1/src/WorkingDirectory.cpp @@ -2,7 +2,7 @@ WorkingDirectory::WorkingDirectory() { - path = "./"; + path = "./resources/"; #ifdef MACOS diff --git a/8 - ECS Part 2/CMakeLists.txt b/8 - ECS Part 2/CMakeLists.txt new file mode 100644 index 0000000..2992f31 --- /dev/null +++ b/8 - ECS Part 2/CMakeLists.txt @@ -0,0 +1,28 @@ +cmake_minimum_required(VERSION 3.16) + +project(ecsP2_8) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") + +find_package(SFML 2.5 COMPONENTS audio graphics window system REQUIRED) + +set(APP_SOURCES + src/Bitmask.cpp + src/C_KeyboardMovement.cpp + src/C_Sprite.cpp + src/C_Transform.cpp + src/Game.cpp + src/Input.cpp + src/Main.cpp + src/Object.cpp + src/SceneGame.cpp + src/SceneSplashScreen.cpp + src/SceneStateMachine.cpp + src/Window.cpp + src/WorkingDirectory.cpp +) + +file(COPY resources DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) +add_executable(${PROJECT_NAME} ${APP_SOURCES}) +target_link_libraries(${PROJECT_NAME} sfml-audio sfml-graphics sfml-window sfml-system) diff --git a/8 - ECS Part 2/src/Object.hpp b/8 - ECS Part 2/src/Object.hpp index a9600b2..510699c 100644 --- a/8 - ECS Part 2/src/Object.hpp +++ b/8 - ECS Part 2/src/Object.hpp @@ -2,6 +2,7 @@ #define Object_hpp #include +#include #include "Window.hpp" #include "Component.hpp" diff --git a/8 - ECS Part 2/src/SceneGame.hpp b/8 - ECS Part 2/src/SceneGame.hpp index b412efa..089d2d4 100644 --- a/8 - ECS Part 2/src/SceneGame.hpp +++ b/8 - ECS Part 2/src/SceneGame.hpp @@ -1,6 +1,8 @@ #ifndef SceneGame_hpp #define SceneGame_hpp +#include + #include "Scene.hpp" #include "Input.hpp" #include "WorkingDirectory.hpp" diff --git a/8 - ECS Part 2/src/WorkingDirectory.cpp b/8 - ECS Part 2/src/WorkingDirectory.cpp index 1cbb124..6bb8207 100644 --- a/8 - ECS Part 2/src/WorkingDirectory.cpp +++ b/8 - ECS Part 2/src/WorkingDirectory.cpp @@ -2,7 +2,7 @@ WorkingDirectory::WorkingDirectory() { - path = "./"; + path = "./resources/"; #ifdef MACOS diff --git a/9 - Generic Resource Allocator/CMakeLists.txt b/9 - Generic Resource Allocator/CMakeLists.txt new file mode 100644 index 0000000..9a0c92d --- /dev/null +++ b/9 - Generic Resource Allocator/CMakeLists.txt @@ -0,0 +1,28 @@ +cmake_minimum_required(VERSION 3.16) + +project(resAllocator_9) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") + +find_package(SFML 2.5 COMPONENTS audio graphics window system REQUIRED) + +set(APP_SOURCES + src/Bitmask.cpp + src/C_KeyboardMovement.cpp + src/C_Sprite.cpp + src/C_Transform.cpp + src/Game.cpp + src/Input.cpp + src/Main.cpp + src/Object.cpp + src/SceneGame.cpp + src/SceneSplashScreen.cpp + src/SceneStateMachine.cpp + src/Window.cpp + src/WorkingDirectory.cpp +) + +file(COPY resources DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) +add_executable(${PROJECT_NAME} ${APP_SOURCES}) +target_link_libraries(${PROJECT_NAME} sfml-audio sfml-graphics sfml-window sfml-system) diff --git a/9 - Generic Resource Allocator/src/Object.hpp b/9 - Generic Resource Allocator/src/Object.hpp index a9600b2..510699c 100644 --- a/9 - Generic Resource Allocator/src/Object.hpp +++ b/9 - Generic Resource Allocator/src/Object.hpp @@ -2,6 +2,7 @@ #define Object_hpp #include +#include #include "Window.hpp" #include "Component.hpp" diff --git a/9 - Generic Resource Allocator/src/WorkingDirectory.cpp b/9 - Generic Resource Allocator/src/WorkingDirectory.cpp index 1cbb124..6bb8207 100644 --- a/9 - Generic Resource Allocator/src/WorkingDirectory.cpp +++ b/9 - Generic Resource Allocator/src/WorkingDirectory.cpp @@ -2,7 +2,7 @@ WorkingDirectory::WorkingDirectory() { - path = "./"; + path = "./resources/"; #ifdef MACOS