arreglos en la estructura
afegida una escena de test
This commit is contained in:
1 parent
6961986ad2
commit
9b168f02eb
13 files changed
+142
-49
No files matched your search
@@ -1,4 +1,6 @@
|
||||
#include "rendering/video.hpp"
|
||||
// video.cpp
|
||||
|
||||
#include "video.hpp"
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
@@ -54,7 +56,7 @@ auto Video::initSDL() -> int {
|
||||
SDL_Quit();
|
||||
return 1;
|
||||
}
|
||||
//SDL_SetTextureScaleMode(game_texture_, toSdlScaleMode(config_.texture_filter));
|
||||
// SDL_SetTextureScaleMode(game_texture_, toSdlScaleMode(config_.texture_filter));
|
||||
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Video subsystem initialized successfully");
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// video.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
#include "system/director.hpp"
|
||||
|
||||
#include "rendering/video.hpp"
|
||||
#include "system/defaults.hpp"
|
||||
|
||||
Director::Director() {
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Game start!");
|
||||
|
||||
video = std::make_shared<Video>(
|
||||
Video::Config{
|
||||
Defaults::Video::FULLSCREEN,
|
||||
Defaults::Video::ZOOM,
|
||||
Defaults::Video::WIDTH,
|
||||
Defaults::Video::HEIGHT});
|
||||
}
|
||||
|
||||
Director::~Director() {
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Bye!");
|
||||
SDL_Quit();
|
||||
}
|
||||
|
||||
auto Director::iterate() -> int {
|
||||
return 0;
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "rendering/video.hpp"
|
||||
|
||||
class Director {
|
||||
public:
|
||||
Director();
|
||||
~Director();
|
||||
|
||||
auto iterate() -> int;
|
||||
|
||||
private:
|
||||
std::shared_ptr<Video> video;
|
||||
};
|
||||
@@ -1,3 +1,5 @@
|
||||
// defaults.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace Defaults::Video {
|
||||
@@ -0,0 +1,51 @@
|
||||
// director.cpp
|
||||
|
||||
#include "director.hpp"
|
||||
|
||||
#include "core/rendering/video.hpp"
|
||||
#include "defaults.hpp"
|
||||
#include "game/scenes/scenes.hpp"
|
||||
#include "game/scenes/test.hpp"
|
||||
|
||||
Director::Director() {
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Game start!");
|
||||
|
||||
video_ = std::make_shared<Video>(
|
||||
Video::Config{
|
||||
Defaults::Video::FULLSCREEN,
|
||||
Defaults::Video::ZOOM,
|
||||
Defaults::Video::WIDTH,
|
||||
Defaults::Video::HEIGHT});
|
||||
scene_ = std::make_unique<Test>();
|
||||
}
|
||||
|
||||
Director::~Director() {
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Bye!");
|
||||
SDL_Quit();
|
||||
}
|
||||
|
||||
auto Director::iterate() -> int {
|
||||
while (scene_) {
|
||||
scene_->render();
|
||||
switch (scene_->update()) {
|
||||
case Scenes::CONTINUE:
|
||||
break;
|
||||
case Scenes::LOGO:
|
||||
break;
|
||||
case Scenes::INTRO:
|
||||
break;
|
||||
case Scenes::GAME:
|
||||
break;
|
||||
case Scenes::TEST:
|
||||
scene_ = std::make_unique<Test>();
|
||||
break;
|
||||
case Scenes::QUIT:
|
||||
scene_.reset();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
// director.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "core/rendering/video.hpp"
|
||||
#include "game/scenes/scene.hpp"
|
||||
|
||||
class Director {
|
||||
public:
|
||||
Director();
|
||||
~Director();
|
||||
|
||||
auto iterate() -> int;
|
||||
|
||||
private:
|
||||
// Core
|
||||
std::shared_ptr<Video> video_;
|
||||
|
||||
// Game
|
||||
std::unique_ptr<Scene> scene_;
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
// scene.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "scenes.hpp"
|
||||
|
||||
class Scene {
|
||||
public:
|
||||
virtual ~Scene() = default;
|
||||
|
||||
virtual auto update() -> Scenes = 0;
|
||||
virtual void render() = 0;
|
||||
};
|
||||
@@ -0,0 +1,12 @@
|
||||
// scenes.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
enum class Scenes {
|
||||
INTRO,
|
||||
LOGO,
|
||||
GAME,
|
||||
TEST,
|
||||
CONTINUE,
|
||||
QUIT
|
||||
};
|
||||
@@ -0,0 +1,16 @@
|
||||
// test.cpp
|
||||
|
||||
#include "test.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
||||
auto Test::update() -> Scenes {
|
||||
static int count = 0;
|
||||
std::cout << count++ << "\n";
|
||||
if (count == 100) { return Scenes::QUIT; }
|
||||
return Scenes::CONTINUE;
|
||||
}
|
||||
|
||||
void Test::render() {
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// test.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "scene.hpp"
|
||||
|
||||
class Test final : public Scene {
|
||||
public:
|
||||
auto update() -> Scenes override;
|
||||
void render() override;
|
||||
};
|
||||
@@ -1,8 +1,10 @@
|
||||
// main.cpp
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "system/director.hpp"
|
||||
#include "game/director.hpp"
|
||||
|
||||
auto main() -> int {
|
||||
auto director = std::make_unique<Director>();
|
||||
return 0;
|
||||
return director->iterate();
|
||||
}
|
||||
Reference in new issue
Block a user