Update hello world

This commit is contained in:
Attila Uygun 2023-09-05 22:09:47 +02:00
parent 0b1220c114
commit ba7c823c91
2 changed files with 10 additions and 13 deletions

View File

@ -54,23 +54,21 @@ devenv out\vs\all.sln
## Hello World example: ## Hello World example:
Shows a smoothly rotating "Hello World!". Shows a smoothly rotating "Hello World".
```cpp ```cpp
class HelloWorld final : public eng::Game { class HelloWorld final : public eng::Game {
public: public:
~HelloWorld() final = default;
bool Initialize() final { bool Initialize() final {
eng::Engine::Get().SetImageSource( eng::Engine::Get().SetImageSource(
"hello_world_image", "hello_world_image",
std::bind(&eng::Engine::Print, &eng::Engine::Get(), "Hello World!", std::bind(&eng::Engine::Print, &eng::Engine::Get(), "Hello World",
base::Vector4f(1, 1, 1, 0))); /*bg_color*/ base::Vector4f(1, 1, 1, 0)));
hello_world_.Create("hello_world_image").SetVisible(true); hello_world_.Create("hello_world_image").SetVisible(true);
animator_.Attach(&hello_world_); animator_.Attach(&hello_world_);
animator_.SetRotation(base::PI2f, 3, animator_.SetRotation(base::PI2f, /*duration*/ 3,
std::bind(base::SmootherStep, std::placeholders::_1)); std::bind(base::SmootherStep, std::placeholders::_1));
animator_.Play(eng::Animator::kRotation, true); animator_.Play(eng::Animator::kRotation, /*loop*/ true);
return true; return true;
} }

View File

@ -1,4 +1,5 @@
#include "base/interpolation.h" #include "base/interpolation.h"
#include "base/vecmath.h"
#include "engine/animator.h" #include "engine/animator.h"
#include "engine/asset/image.h" #include "engine/asset/image.h"
#include "engine/engine.h" #include "engine/engine.h"
@ -8,19 +9,17 @@
class HelloWorld final : public eng::Game { class HelloWorld final : public eng::Game {
public: public:
~HelloWorld() final = default;
bool Initialize() final { bool Initialize() final {
eng::Engine::Get().SetImageSource( eng::Engine::Get().SetImageSource(
"hello_world_image", "hello_world_image",
std::bind(&eng::Engine::Print, &eng::Engine::Get(), "Hello World!", std::bind(&eng::Engine::Print, &eng::Engine::Get(), "Hello World",
base::Vector4f(1, 1, 1, 0))); /*bg_color*/ base::Vector4f(1, 1, 1, 0)));
hello_world_.Create("hello_world_image").SetVisible(true); hello_world_.Create("hello_world_image").SetVisible(true);
animator_.Attach(&hello_world_); animator_.Attach(&hello_world_);
animator_.SetRotation(base::PI2f, 3, animator_.SetRotation(base::PI2f, /*duration*/ 3,
std::bind(base::SmootherStep, std::placeholders::_1)); std::bind(base::SmootherStep, std::placeholders::_1));
animator_.Play(eng::Animator::kRotation, true); animator_.Play(eng::Animator::kRotation, /*loop*/ true);
return true; return true;
} }