-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
61 lines (49 loc) · 1.49 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <iostream>
#include <turbo/Engine.hpp>
#include <turbo/sound/MusicStream.hpp>
class TestScene: public turbo::Scene {
public:
TestScene() = default;
void load() override {
turbo::Path* path = turbo::Path::get_resources_path();
path->drop_tail();
path->drop_tail();
path->drop_tail();
path->append_component("assets/demo");
path->set_filename("png-test.png");
this->texture = new turbo::Texture(path);
auto* sprite = new turbo::Sprite(texture);
sprite->rect.x = 150;
sprite->rect.width = 100;
auto* root = new turbo::GameObject(nullptr, "root");
root->set_position(100,100);
root->set_drawable(sprite);
this->root_gameobject = root;
delete path;
}
void unload() override {
delete this->root_gameobject;
delete this->texture;
this->root_gameobject = nullptr;
this->texture = nullptr;
}
private:
turbo::Texture* texture;
};
int main() {
turbo::Engine engine = turbo::Engine();
TestScene* test_scene = new TestScene();
engine.scene_manager.register_scene(test_scene, "test scene");
engine.scene_manager.set_active_scene("test scene");
try {
engine.start_window("Turbo Engine", 1600, 900);
engine.loop();
engine.stop_window();
test_scene->unload();
delete test_scene;
} catch (std::exception& e) {
turbo::Logger::log(e.what());
return 1;
}
return 0;
}