From ba7c823c91306cb474d9796dcbc29e05d6b97203 Mon Sep 17 00:00:00 2001 From: Attila Uygun Date: Tue, 5 Sep 2023 22:09:47 +0200 Subject: [PATCH] Update hello world --- README.md | 12 +++++------- src/hello_world/hello_world.cc | 11 +++++------ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 35bc119..7ca07c1 100644 --- a/README.md +++ b/README.md @@ -54,23 +54,21 @@ devenv out\vs\all.sln ## Hello World example: -Shows a smoothly rotating "Hello World!". +Shows a smoothly rotating "Hello World". ```cpp class HelloWorld final : public eng::Game { public: - ~HelloWorld() final = default; - bool Initialize() final { eng::Engine::Get().SetImageSource( "hello_world_image", - std::bind(&eng::Engine::Print, &eng::Engine::Get(), "Hello World!", - base::Vector4f(1, 1, 1, 0))); + std::bind(&eng::Engine::Print, &eng::Engine::Get(), "Hello World", + /*bg_color*/ base::Vector4f(1, 1, 1, 0))); hello_world_.Create("hello_world_image").SetVisible(true); animator_.Attach(&hello_world_); - animator_.SetRotation(base::PI2f, 3, + animator_.SetRotation(base::PI2f, /*duration*/ 3, std::bind(base::SmootherStep, std::placeholders::_1)); - animator_.Play(eng::Animator::kRotation, true); + animator_.Play(eng::Animator::kRotation, /*loop*/ true); return true; } diff --git a/src/hello_world/hello_world.cc b/src/hello_world/hello_world.cc index 234327a..ab75d89 100644 --- a/src/hello_world/hello_world.cc +++ b/src/hello_world/hello_world.cc @@ -1,4 +1,5 @@ #include "base/interpolation.h" +#include "base/vecmath.h" #include "engine/animator.h" #include "engine/asset/image.h" #include "engine/engine.h" @@ -8,19 +9,17 @@ class HelloWorld final : public eng::Game { public: - ~HelloWorld() final = default; - bool Initialize() final { eng::Engine::Get().SetImageSource( "hello_world_image", - std::bind(&eng::Engine::Print, &eng::Engine::Get(), "Hello World!", - base::Vector4f(1, 1, 1, 0))); + std::bind(&eng::Engine::Print, &eng::Engine::Get(), "Hello World", + /*bg_color*/ base::Vector4f(1, 1, 1, 0))); hello_world_.Create("hello_world_image").SetVisible(true); animator_.Attach(&hello_world_); - animator_.SetRotation(base::PI2f, 3, + animator_.SetRotation(base::PI2f, /*duration*/ 3, std::bind(base::SmootherStep, std::placeholders::_1)); - animator_.Play(eng::Animator::kRotation, true); + animator_.Play(eng::Animator::kRotation, /*loop*/ true); return true; }