Advertisement Jump to content
Sign in to follow this  
eppskevin

Getting that typewriter text output effect

This topic is 4876 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!