class Typewriter {
protected:
string text;
int progress;
int delay;
FONT *font;
PALETTE pal;
public:
Typewriter(const char *t) {
text = t;
progress = 0;
delay = 0;
}
void initialize() {
font = load_font("united1.pcx", pal, 0);
set_palette(pal);
}
void Update() {
if (delay == 0) {
delay = 10;
++progress;
progress = MIN(progress, text.size());
}
else {
--delay;
}
}
void Draw(BITMAP *buffer, int x, int y) {
char buf[256];
ustrncpy(buf, text.c_str(), progress);
buf[progress] = 0;
textprintf_ex(buffer, font, x, y, -1, -1, buf);
}
};
Getting that typewriter text output effect
Does anyone know any nice algorithms for obtaining a typewriter effect that keeps text inside a specific space as well.
Example:
Dialogs in Role Playing Games like Chrono Trigger and other RPG's on SNES. Conversations in Meganman X.
The main thing I'm trying to figure out is how to keep the text inside a specific space(bitmap).
This is a class that I've written that just does the Typewriter effect only.
Sorry, answered before I re-read the question and missed the part about the typewriter effect.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement