A small game engine for 2D games based of Raylib
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

39 行
1.4 KiB

#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"
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::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::entities::utilities::background_entity>(BLACK));
auto ref = std::chrono::steady_clock::now();
std::chrono::duration<double> frame_time = ref - ref;
while(not WindowShouldClose()) {
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;
}