Jump to content

aiaf's Blog

  • entries
    11
  • comments
    4
  • views
    6,615

[Example] Pulse text , and some thoughts


aiaf

1,112 views

 Share

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;
}

 

  • Like 3
 Share

1 Comment


Recommended Comments

Nice to read. It is to me simply interesting to read how people is actually feeling in this times of changes and maybe difficult time for indie game makers who have to find a way between creativity and engines business restrictions.  I would read much more about how people feeling about this and how possible it is to continue something about each one here once dreamt, I mean creating an own playable scene.

Link to comment
Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...