sfw/demos/minimal_app/main.cpp

48 lines
930 B
C++
Raw Normal View History

2024-01-05 17:08:06 +01:00
#include "sfw.h"
class GameApplication : public Application {
SFW_OBJECT(GameApplication, Application);
public:
virtual void input_event(const Ref<InputEvent> &event) {}
virtual void update(float delta) {
2024-01-13 20:44:02 +01:00
_font_pos.x += 500 * delta;
if (_font_pos.x > 1800) {
_font_pos.x = 0;
}
2024-01-05 17:08:06 +01:00
}
virtual void render() {
Renderer::get_singleton()->clear_screen(Color());
2024-01-13 20:44:02 +01:00
Renderer::get_singleton()->camera_2d_projection_set_to_window();
2024-01-05 17:08:06 +01:00
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();
}
2024-01-13 20:44:02 +01:00
Vector2 _font_pos;
2024-01-05 17:08:06 +01:00
Ref<Font> _font;
};
int main(int argc, char **argv) {
Application *application = memnew(GameApplication());
while (application->running) {
application->main_loop();
}
memdelete(application);
return 0;
}