|
|
- #include <iostream>
- #include "raylib.h"
- #include "scene.h"
- #include "render_state.h"
- #include "entities/ui_fps_entity.h"
- #include "entities/background_entity.h"
- #include "components/sprite_component.h"
- #include "components/panel_component.h"
-
- using namespace std::string_literals;
-
- int main() {
- InitWindow(800, 600, "Example");
- ant::core::scene::current = std::make_shared<ant::core::scene>();
-
- ant::core::scene::current->root_nodes.push_back(ant::core::make_entity<ant::entities::utilities::ui_fps_entity>());
- ant::core::scene::current->root_nodes.push_back(ant::core::make_entity<ant::entities::utilities::background_entity>(BLACK));
-
- ant::core::scene::current->root_nodes.push_back(ant::core::make_entity<ant::core::entity>());
- ant::core::scene::current->root_nodes.back()
- ->add_component<ant::components::graphical::sprite_component>(
- "Engine/assets/apple.png"s,
- 0,
- ant::core::transform<>{{560/2, 640/2}, 60},
- ant::core::Vec2<>{0.5,0.5}
- );
- ant::core::scene::current->root_nodes.back()->transform().position = {250,250};
- ant::core::scene::current->root_nodes.back()->transform().angle = 120;
-
- ant::core::scene::current->root_nodes.push_back(ant::core::make_entity<ant::core::entity>());
- ant::core::scene::current->root_nodes.back()
- ->add_component<ant::components::ui::panel_component>(
- 100,
- BLUE,
- ant::core::Vec2<>{400, 400},
- ant::core::Vec2<>{1,1}
- );
- ant::core::scene::current->root_nodes.back()->transform().position = {390, 10};
-
- auto child = ant::core::make_entity(ant::core::scene::current->root_nodes.back());
- child->transform().position = {150,150};
- child
- ->add_component<ant::components::ui::panel_component>(
- 12,
- RED,
- ant::core::Vec2<>{100, 100},
- ant::core::Vec2<>{1,1}
- )->initialize();
- // TODO: investigate the rendering of subpanels
-
- auto ref = std::chrono::steady_clock::now();
- std::chrono::duration<double> frame_time = ref - ref;
- while(not WindowShouldClose()) {
- std::cout << "Frame start\n";
- ant::core::scene::current->update(frame_time);
- ant::core::scene::current->render();
- BeginDrawing();
- ant::render::render_all();
- EndDrawing();
- auto new_time = std::chrono::steady_clock::now();
- frame_time = new_time - ref;
- ref = new_time;
- }
- CloseWindow();
- return 0;
- }
|