[Example] Pulse text , and some thoughts
2019 was slow year for my gamedev hobby.
Forth community project really has some good original content, i will make sure it gets released in a form or another.
Still working on my game when i find the time.
Lurking around and reading about leadwerks 5 progress heh, go Josh!
Maybe we get another tournament after Le5 is release Somehow the tournament gives good motivation to make games.
Cheers to everyone and a good new year.
Some pulsating text example:
#ifndef __S_PULSETEXT_H__ #define __S_PULSETEXT_H__ #include <string> #include "Leadwerks.h" using namespace Leadwerks; class PulseText { private: Leadwerks::Context* context; std::string text; double alphaInitial; float x,y; double r,g,b; bool pulse; float rate; public: PulseText(Leadwerks::Context* context, float x, float y, std::string text); void SetColor(float r, float g, float b); void SetPulse(bool active); void SetRate(float rate); void Update(); }; #endif
#include "PulseText.h" using namespace Leadwerks; PulseText::PulseText(Leadwerks::Context* context, float x, float y, std::string text) { this->context = context; this->text = text; this->x = x; this->y = y; r = 0.7; g = 0.7; b = 0.7; alphaInitial = 1.0; pulse = true; rate = 0.005; } void PulseText::Update() { context->SetBlendMode(Blend::Alpha); context->SetColor(r, g, b, alphaInitial); if (pulse) { if (alphaInitial > 0) { alphaInitial = alphaInitial - Time::GetSpeed() * rate; } else { alphaInitial = 1.0; } } context->DrawText(text, x, y); context->SetColor(0.7, 0.7, 0.7, 1.0); context->SetBlendMode(Blend::Solid); } void PulseText::SetColor(float r, float g, float b) { this->r = r; this->g = g; this->b = b; } void PulseText::SetPulse(bool active) { pulse = active; } void PulseText::SetRate(float rate) { this->rate = rate; }
- 3
1 Comment
Recommended Comments