From ad773474c9a30f521593c83692055df86eab7071 Mon Sep 17 00:00:00 2001 From: Relintai Date: Sat, 6 Jan 2024 00:05:01 +0100 Subject: [PATCH] Added extremely simple core test example. --- tools/merger/test_core_1/compile_linux.sh | 8 ++++ tools/merger/test_core_1/main.cpp | 47 +++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100755 tools/merger/test_core_1/compile_linux.sh create mode 100644 tools/merger/test_core_1/main.cpp diff --git a/tools/merger/test_core_1/compile_linux.sh b/tools/merger/test_core_1/compile_linux.sh new file mode 100755 index 0000000..d31d97a --- /dev/null +++ b/tools/merger/test_core_1/compile_linux.sh @@ -0,0 +1,8 @@ + +ccache g++ -Wall -g -c sfw.cpp -o sfw.o +ccache g++ -Wall -g -c main.cpp -o main.o + +#-static-libgcc -static-libstdc++ + +ccache g++ -Wall -lm -ldl -lpthread -lX11 -g sfw.o main.o -o game + diff --git a/tools/merger/test_core_1/main.cpp b/tools/merger/test_core_1/main.cpp new file mode 100644 index 0000000..7e8e535 --- /dev/null +++ b/tools/merger/test_core_1/main.cpp @@ -0,0 +1,47 @@ + +#include "sfw.h" + +class GameApplication : public Application { + SFW_OBJECT(GameApplication, Application); + +public: + virtual void input_event(const Ref &event) {} + virtual void update(float delta) { + _font_pos.x += 500 * delta; + if (_font_pos.x > 1800) { + _font_pos.x = 0; + } + } + virtual void render() { + Renderer::get_singleton()->clear_screen(Color()); + Renderer::get_singleton()->draw_text_2d("Test!", _font, _font_pos); + } + + GameApplication() { + _font.instance(); + _font->load_default(31.5); + _font_pos = Vector2(0, 500); + + Renderer::initialize(); + } + + ~GameApplication() { + Renderer::destroy(); + } + + Vector2 _font_pos; + Ref _font; +}; + + +int main(int argc, char **argv) { + Application *application = memnew(GameApplication()); + + while (application->running) { + application->main_loop(); + } + + memdelete(application); + + return 0; +}