Home
Products
Community
Manuals
Contact
Login or Signup

Code archives/3D Graphics - Effects/Zelda-Style Text Scroller

This code has been declared by its author to be Public Domain code.

Download source code

Zelda-Style Text Scroller by Rob the Great(Posted 1+ years ago)
I'm finally feeling brave enough to post something to the code archives. This is a command set I've designed which will take strings and scroll them in your game, very similar to the Legend of Zelda games. This command set includes many custom functions, as well as embedded string commands to spice up the text (e.g., changing color, pausing, skipping, ect.). Note that for speed reasons, you will need the FastImage library to run this demo. If you don't have it currently, you can check out the FastImage demo, which will show the full effect of my code, but you will eventually need to buy the FastImage library to use my command set in any game (it's a very reasonable price for what it can do).

You will also need to download the media required to run it (images, soundfx). The link is below, which will have everything minus the FastImage library files, but you can just copy those files to the root folder to use. When you download the file, run "Zelda-Text Demo.bb", and it will start the whole process.

Here's the link to the download. To download, click on the link, then go to File-->Download and save it to your computer. From there, just unzip and make sure the program has access to the FastImage .dll files.
https://docs.google.com/file/d/0BzVV3pB-PsxWbldIVU11MkNueHc/edit?pli=1

And, here's the code below. Keep in mind that I'm posting the code here so you can mentally preview what it does, but you will still need the media to run this code. If this is too much to take in, try the download link instead. The demo file uses Includes to break it all up and make it easier to understand.

If you have questions, read the help file I made (Zelda-Text Header Help.bb"). That will explain the whole command set in detail.

And, I ask that you please be kind with any criticism. Keep in mind that I'm a self-taught hobbyist programmer, so my techniques might not be the best approach regarding speed, efficiency, ect. However, I am certainly open to suggestions if anyone has advice to give.

EDIT: I've shortened the code to only show the demo file. This only shows the raw essentials to the demo (no functions, types, ect.). The rest is all in the include files, so try the download link and you're all set!
See the codebox above. It's cleaner in a codebox format for the archives, which I can't do in this box.

Comments

Rob the Great(Posted 1+ years ago)
Hmm...Apparently, my code is too large to post in the archives. Try the download link...In the meantime, I'll see what I can do to shorten it.


Guy Fawkes(Posted 1+ years ago)
Awesome! =D Any upgrades? :D


Rob the Great(Posted 1+ years ago)
Haha. Glad you like. No updates, but there is a small bug I've noticed when using it in my game. For some reason, it seems to pause for the set amount of time not only at the intended spot, but also at the end of the section of dialogue. I'm not sure why this is so, and I haven't picked up Blitz in a while since I'm busy playing the official new Zelda title, but when I take a look at the code again, I'll see if I can fix it and change the download source. Other than that, I don't think I'll be adding anything else.


Guy Fawkes(Posted 1+ years ago)
Well, I DID notice. it is HARD to incorperate it into other Blitzbasic projects. is there a way u can make it more simple to incorperate? :) Thanks! :)


Rob the Great(Posted 1+ years ago)
It's mostly hard because it's pretty complex. However, all of the hard stuff is contained in 1 line functions. As long as you have all of the Include files, such as:
Include "FastImage.bb" ;the fast image functions - Comes with the FastImage library.
Include "Zelda-Text Setup.bb" ;the setup file for Zelda-Text
Include "Zelda-Text Functions.bb" ;the functions for Zelda-Text
Include "Zelda-Text Scripts.bb" ;the scripts for Zelda-Text. Add your own scripts to this include file.
;There's no point in Including the Zelda-Text Header Help.bb file since it's all comments, but be sure to read it for help!

you can call any of these functions in your program. If you haven't done so, check out the "Help.bb" file. That has a detailed explanation of how to use my system in your Blitz file. All of the functions except for the co-dependent functions have details on how to use them and what their purposes are.

Essentially, to use my system, you will need the following lines of code:
Include "FastImage.bb" ;the fast image functions - Comes with the FastImage library.
Include "Zelda-Text Setup.bb" ;the setup file for Zelda-Text
Include "Zelda-Text Functions.bb" ;the functions for Zelda-Text
Include "Zelda-Text Scripts.bb" ;the scripts for Zelda-Text. Add your own scripts to this include file.

;Set up your game here (Graphics, meshes, levels, ect.)

Global dialogue = CreateScript("What you want to say",groupnumber,sectionnumber)
;In the function above, the string parameter will be scrolled, the group number
;is the number in which the dialogue belongs, and the section number 
;is the order in which the text should scroll. If you haven't
;seen Zelda's text system yet, you HAVE to see it first to really
;understand what that all means.

;Main Loop Here

   UpdateWorld
   RenderWorld
   DrawScrollingText(groupnumber)
   Flip
;End the Main Loop

;End the Game

This will scroll text. True, the demo is complex, but that's because it really does show everything this system is capable of. I originally designed it as a debugging system when I was designing it, so I had to make a program that would test everything to its fullest.

If the demo is too complex, let me know and I can provide some specific examples of what you are wanting to do. The functions are surprisingly easy to use, it's just a matter of knowing the functions and knowing when to use them.

Basically, what do you mean by "It's hard to incorporate into other projects"? I am seriously glad that you're interested, so I will do whatever I can to help you out.


Guy Fawkes(Posted 1+ years ago)
Will this work with 2D? :)


Rob the Great(Posted 1+ years ago)
2D in 3D only. To my understanding, FastImage makes use of sprites or something of that nature, again, for speed reasons. Blitz's 2D graphics have gone the way of the dodo bird, so I seriously doubt this will work in 2D mode. Plus, I vaguely remember seeing an error message saying "3D Graphics Not Set" when I was designing this.
You're more than welcome to give it a try, though. I don't have access to Blitz at the moment, but just try the following program:
Graphics 1024,768,0,2
Include "FastImage.bb"
Include "Zelda-Text Setup.bb"
Include "Zelda-Text Functions.bb"
;Include "Zelda-Text Scripts.bb" ;I don't think you need this for a small program

Global dialogue = CreateScript("Testing 2D Graphics!",1,1)

While Not KeyDown(1)

   Cls
   DrawScrollingText(1)
   Flip

Wend

End


EDIT: Sorry, I think I've been misleading you a little bit. Looking over what I just posted, I noticed that I made a variable to store what's returned from CreateScript, but CreateScript doesn't return a value. I'm not sure why I did that, I think I'm getting my old scroller and my new one mixed up.
This line:
Global dialogue = CreateScript("Testing 2D Graphics!",1,1)

Should instead be this:
CreateScript("Testing 2D Graphics!",1,1)



Guy Fawkes(Posted 1+ years ago)
As long as it's encrypted into the game itself, can we use this Royalty Free? I'm sure ALOT of ppl would appreciate it! :) Including myself! :)


Guy Fawkes(Posted 1+ years ago)
Sadface.... It didnt' work... :/





NOW where am I gonna get a 2D dialogue system as good as this? ><


Rob the Great(Posted 1+ years ago)
If I post it in the archives, I have no choice but to make it free source.

Plus, I will clearly state any of my code as copyrighted should I ever feel the need to do so, so if you see any pieces of my code floating around out there, you can assume that it's free unless I say otherwise. Note that I am referring to my code only. I think Yasha pointed out to you once that you shouldn't assume it's free, so it's good you asked.

Now, I don't know what the setup is for the Fast Library files. You've probably noticed that I can't legally or morally share that .dll file with the rest of Blitz programmers for this system. My stuff is free, but do check that you have a proper commercial license with the Fast libraries as I can't speak on behalf of them. I believe that when you buy the Fast Library, you are granted a commercial license with that, but do be sure to check with them first.

As far as it being encrypted, you don't have to waste your time encrypting my spot of code. I'm sure I'm not the first one to try and mimic the Zelda text styles, and I really could care less if someone "hacks" into my code. At least they spent the time to notice it was there, lol.


Guy Fawkes(Posted 1+ years ago)
I bought the license for all the Fast DLLs :)


Guy Fawkes(Posted 1+ years ago)
Can u recommend any 2D RPG dialogue text systems that are as easy & as good as this? :/ Because I was looking REALLY forward to using this in my upcoming, 2D MMORPG :/


Rob the Great(Posted 1+ years ago)
You changed the command to 3D graphics, not 2D.

I don't know if this was intentional, but remember that "Graphics3D" will setup 3D graphics, and "Graphics" will setup 2D graphics.

Are you using strictly 2D graphics, or are you using 2D in 3D? If you are using "Graphics3D", then this system should work.

Also, you can declare 3D graphics, but you don't have to use them. This:
Graphics 640,480,0,2
SetBuffer BackBuffer()
image = LoadImage("image.bmp")
While Not KeyDown(1)
   Cls
   DrawImage image,0,0
   Flip
Wend
End

will do the exact same thing as this:
Graphics3D 640,480,0,2
SetBuffer BackBuffer()
image = LoadImage("image.bmp")
While Not KeyDown(1)
   Cls
   DrawImage image,0,0
   Flip
Wend
End

I would recommend declaring 3D graphics, regardless of whether or not you intend to use them. Then you can implement my system without a lot of trouble. The only issue is that you might have some performance issues mixing 3D and 2D. I can remember someone saying that there are a lot of problems when you do that.

Or...

If you're interested, I have a really old spot of code on my computer, and if I remember right, it's based on Blitz's 2D command set. I can provide you with that, but it's horribly written and there isn't as much functionality to it as this system.


Guy Fawkes(Posted 1+ years ago)
Sure, I'd LOVE that! :) BUT. First, if there is a way to incorporate this into 2D, I would rather use this Dialogue system :) Is there a way u can trick Blitz?


If so, please let me know! :)


Thanks, Rob! :)


Rob the Great(Posted 1+ years ago)
Let me think about some solutions for a while...I'm looking over the old text scroller now, and I am completely ashamed to share it with anyone. It's bad code...

I'll see if there is any way to make this 2D compatible, but I can't make any promises.

While I'm doing so, I have to ask, how are you using the Fast Libraries WITHOUT calling 3D graphics? It always returns an error when you try to use it in 2D mode.


Guy Fawkes(Posted 1+ years ago)
It DID return an error, even in Debug mode. Memory Access Violation. on SetImage, I think...


Rob the Great(Posted 1+ years ago)
Right, that's the problem. I'm asking how you're able to get around the problem, as that's a great starting point for me.


Guy Fawkes(Posted 1+ years ago)
I have NO idea, Rob. If I knew that, then I wouldn't be asking u about it. LOL! :p


Rob the Great(Posted 1+ years ago)
Lol,

So, I assume that you're not using any of the Fast libraries in this 2D project, is that correct?


Guy Fawkes(Posted 1+ years ago)
I'm TRYING to. I need a working 2D Dialogue system.... :/ Other than ur Zelda demo being the closest, I haven't been able to find one. :(


Rob the Great(Posted 1+ years ago)
I'm re-working some of this code, and it's actually going a lot smoother than I thought it would. In the meantime, have you tried declaring 3D graphics in your game even though you don't need them? If you can do so without any problems or changes to your game in progress, let me know and I'll show you how 2D in 3D works.


Guy Fawkes(Posted 1+ years ago)
Nope. Tried it... :/


Rob the Great(Posted 1+ years ago)
Well, trying to modify what I've already done is going to be a pain. It would actually be easier to start from the beginning and design it from the ground up to work in 2D mode. Sorry, but I don't have that kind of time to dedicate to this problem.

There are a couple of options, though. I just looked at the old scroller, and it's not bad, maybe you could use it. There aren't as many commands as the new version, but it does have the basics, such as changing color, pausing, and inserting button pauses. It works entirely in 2D graphics, but it's not as neat as the 3D version, plus it still has a ton of bugs which you will see once in a while (spaces don't even themselves out for some reason.)

The other option is to send me a link with your entire game in progress. I'm 90% sure you should be able to use my system, but I would have to take a look at your code to know what's going on. If you wanted, I could look at your game and change your code to be able to use my system.


Guy Fawkes(Posted 1+ years ago)
Ok, here's my whole project.






ME_LevelEditor_Lib.bb (Credit: mk2y10):







The graphics go in the gfx folder:



http://www.mediafire.com/?8p58d6km7tparmh



Just extract the gfx folder to the main directory of the game :)



With the gfx folder and includes file, it should compile flawlessly :)



Thanks, Rob! :)


Rob the Great(Posted 1+ years ago)
Well, good news for you, IT WORKS!

Here's the changes to the main file:

This is important, so pay attention: In order for you to use my system, you will need to:
A) Create a new folder in your game's root called "Text Scrolling".
B) Inside that folder, drop all of the text scrolling related files. You can get them from the link above. This should total 3 folders called "Fonts", "Images", and "SoundFX", as well as 3 .bb files, the Zelda text functions and the Zelda text setup. I've chosen to put FastImage.bb inside this folder, but if you want to change it, be sure the Include command in your main file reflects the new location.
c) Eventually, you should consider adding a new file in this folder called "Zelda Text Scripts.bb" and keep all of your text-to-be-scrolled inside this file. Then just include this file in the Main (there's one already commented out in there for you), and your IDE will look a lot cleaner.

If you can get it to work, your next step is to read through the help file I've included. I know it's tedious, but there's some really good explanations of how the entire system works.

Let me know if you have any questions.

-Rob the Great


Guy Fawkes(Posted 1+ years ago)
OMG!OMG!OMG! HOW DID U DO THAT?! O_O U ROCK ROB! :D THANK YOU THANK YOU THANK YOU! =D


Is there a way I can control which text comes up for which NPC? :)


Take that Chu chu jelly in the corner for instance ;)


Rob the Great(Posted 1+ years ago)
Do you really think I would spend months on end designing a text scrolling system and forget to make the text interchangeable? lol.

Check this out: I'm just going to modify the code in the main file again, but look what happens:

Wow, I haven't used 2D in forever. The ImagesColide() command is glitchy, but notice how the text only comes up if you are touching the Chu Chu.


Guy Fawkes(Posted 1+ years ago)
NICE! :O Is there a way to make it so that the player cant go through the Chu chu jelly, and when the player is touching the Chu chu jelly and u press enter, then make the Chu jelly face u, THEN the text comes up? & allows the story to reset itself each time the NPC faces the player, so that the user can read over the text as many times as they choose? :D


Thanks, Rob! =D


Rob the Great(Posted 1+ years ago)
Yes, there is. However, I'm about Blitzed out for the day, and on top of that, this isn't related to the text scrolling process, it's related to programming 101.

Put what you just said into pseudo, and you've got it:
;If the player is touching the chu chu on the chu chu's right side
   ;And the player is walking left
      ;Stop the player from walking left
   ;End that situation
;End that situation

;Repeat the above for each of the four direction.

;If the player is touching the chu chu anywhere
   ;And if the player pushed (ENTER)
      ;Turn the chu chu to face the player
      DrawScrollingText(whichgroup) ;OK, I'll give you that one
   ;End that situation
;End that situation

;Finally, if the player is not touching the chu chu
   DrawScriptAgain(whichgroup) ;this will allow you to talk to him again
;End that situation

There you go. I did the logic part, now you just replace my words with Blitz commands and you're set.


Guy Fawkes(Posted 1+ years ago)
Thanks Rob! :) One more question. How can I tell if the Chu chu is on his right side? =D


Rob the Great(Posted 1+ years ago)
You know, it's been (thinking..........) about 7 years since I've programmed anything in pure 2D. I honestly can't remember how the whole command set works because I'm in complete 3D mode right now. Now, if you happen to know where the master sword is, I can place it in the pedestal of time and go back 7 years to see how it's done, but if not, I'm afraid I'm not the right person to answer that. I'll bet someone on the BlitzPlus forums could answer it, though.


Guy Fawkes(Posted 1+ years ago)
Thanks again, Rob! :) I GREATLY appreciate ur submission to the community! :D


Rob the Great(Posted 1+ years ago)
No problem. I'm glad you enjoy it, it's totally made my day.


Guy Fawkes(Posted 1+ years ago)
Hehe, I'm glad I could make ur day! ^_^ Ur awesome, Rob! :) This is TRUELY the BEST Text system for both 2D & 3D in the HISTORY of Blitz3D! :D Respect, Rob! :) Respect! B)


Blitzplotter(Posted 1+ years ago)
Very nice piece of coding - looking forward to having a good play with this, cheers Rob and Thundros.

[Edit] Truly awesome slice of code - brilliant fun.


Rob the Great(Posted 1+ years ago)
It's a pretty ugly piece of code, but it does some really nice things. It wasn't too ugly at first, but then I decided to add the ability to change stored variables in the strings. When I added the command, I was about 2/3 of the way finished with the entire project, so I had to make a function which would take the formatted string, de-format it, remove the old data, reinsert the new data, and reformat the string to basically what it was before. The function turned into a lot of copy-pasting with tiny changes in data values, and by the end, it was perhaps the longest and ugliest code I've ever written.

But, it does what it's supposed to do, and as long as it can scroll text efficiently, I don't care what the final code looks like, lol.


Guy Fawkes(Posted 1+ years ago)
@Rob, can u add an image NEXT to the text window, so that it appears as if a character is talking?


Rob the Great(Posted 1+ years ago)
What kind of image? Are you talking about moving the one that I have already, or using your own?

If you are using your own, just draw it over top of my text system:
DrawScrollingText(1)
StartDraw
   DrawImageEx(image,x,y)
EndDraw

That's quite literally all you have to do.

To change or reposition the image built in, you will need to modify the lines of code inside "Zelda-Text Functions.bb", inside the function "DrawScrollingText()". The lines that are responsible for this are:

They are located towards the end of the function. If you want to change the image location, just change the x,y coordinates in the DrawImageEx() commands, and base it off of a resolution of 1024,768. Don't worry if your game uses a different resolution, the system will adjust the position and scale to match the same layout.


Blitzplotter(Posted 1+ years ago)
But, it does what it's supposed to do, and as long as it can scroll text efficiently, I don't care what the final code looks like, lol.
- It certainly does that well - I was able to digest your code in no time at all - testament to a well written modular approach to coding.

Which is more than I can say for a 'little' project that I've been working on for a while - at times when I go back to it I'm like - now how the hell did I implement that?

Back to your text scrolling code - I'm using it to record my progress towards some goals - yeah I could just use word but it'd be nowhere near as nice to behold as your text scroller ;)


Rob the Great(Posted 1+ years ago)
Glad you like it.

What is modular programming? I just program as a hobby, so I really don't know what all of these terms mean. I tried a Wiki search, but it's worded so complex that I really don't understand it.


Yasha(Posted 1+ years ago)
What is modular programming?


Where you don't need to know anything about how it works, just call the functions and trust it to do its thing, and to not affect the rest of your application beyond what you request from it. It's a great way to build an application.

While some languages (notably BlitzMax) have formal support for it, you can really do it in any language as long as you have sensible naming conventions and clean includes.


Rob the Great(Posted 1+ years ago)
Ah, I see. Yeah, that definitely sums up my whole programming premise, as I prefer to not think about what's going on under the hood when I call a function, whether I've written it myself or someone else did.


Blitzplotter(Posted 1+ years ago)
Yeah, the 'include' function in Blitz 3D is great for breaking down a large project into easily digestable chunks.


Guy Fawkes(Posted 1+ years ago)
<3 I love this dang thing =D


Guy Fawkes(Posted 1+ years ago)
Sorry to bump an old thread, but Rob. Real quick question. Why is my text window glitching up, and not letting me exit it? Also, why does it change text colors at the end, and plays no sound for the letters?



Thanks for the help! :)


Rob the Great(Posted 1+ years ago)
From what you've provided, I haven't the slightest idea. My guess is that the include files have been tampered with too much and it's changing the way the scroller works. If the window is glitching, try downloading the file from above again and replacing it with the version you have. This will ensure that the code in the include files is how it was released. If it's just not letting you exit, remember that I defaulted the "Action Button" to the left Alt key on the keyboard. Also, the game window needs to be active to accept any input from the keyboard. As far as changing colors at the end, you do realize that I intentionally changed the color to green at the end of the first section, right? Also, remember that when you change the sections of a text (going from 1 to 2), the color is reset back to white. To override this, just add in another {Color} command at the beginning of the section. Finally, if it is not playing a sound and the include files are untouched from when you downloaded them, then make sure the sound files are in the correct folder to load. If they don't load, I believe that Blitz ignores the missing files and just doesn't play the sounds. I can't remember off of the top of my head where the sounds should be located at, but you can open up the Zelda-Text Setup.bb file and see where the sounds should be located relative to your game's root.

Aside from that, there should be no reason at all that the text is messing up. Everything above is formatted as needed to make it work. If the steps above do not solve the problem, please be more descriptive about what the problem is.


Guy Fawkes(Posted 1+ years ago)
Rob, I hate to bump an old thread, but I have one more question. Is there a way to control which model reads what text?

Thank You!


celticpiping(Posted 1+ years ago)
nvmd prob solved


Guy Fawkes(Posted 1 month ago)
Does anyone still have a copy of this? Thanks!


Rob the Great(Posted 1 month ago)
I think I still have the original source for this. Somewhere...I take it the link died? It was one of those free ftp sites, I wouldn't be surprised if it's gone now.


Rob the Great(Posted 1 month ago)
Yep, I just tracked it down and ran through the whole demo. It's amazing how much my coding skills have improved since I wrote this. It's almost to the point where I want to give myself a face-palm because of its design flaws. But it still looks cool.

Unfortunately, I have to leave for work in about thirty seconds, but I'll update the broken link later when I get home. I'll let you know when it's updated.


Guy Fawkes(Posted 1 month ago)
Thanks alot, Rob! :) And hey! Don't be so hard on yourself, mate. We all get better with age! :)


Rob the Great(Posted 1 month ago)
Ok. I've updated the link above and copied it here as well. This is uploaded via Google Drive, so I doubt the link will go bad anytime soon. All you have to do is click on the link, go to File-->Download and save it to your computer, unzip it, and then make sure you have the FastImage library DLLs in the appropriate folder to run it. Remember that I cannot share the FastImage library files with this project, so I have removed them from uploaded folder.

https://docs.google.com/file/d/0BzVV3pB-PsxWbldIVU11MkNueHc/edit?pli=1


Guy Fawkes(Posted 1 month ago)
THANK You, Rob! :D I was scouring my entire hard drives looking for it! :D


Code Archives Forum