December 10, 2019, 02:26:54 PM

Author Topic: [bb] Zelda-Style Text Scroller by Rob the Great [ 1+ years ago ]  (Read 3585 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
Title : Zelda-Style Text Scroller
Author : Rob the Great
Posted : 1+ years ago

Description : 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.
<a href="https://docs.google.com/file/d/0BzVV3pB-PsxWbldIVU11MkNueHc/edit?pli=1" target="_blank">https://docs.google.com/file/d/0BzVV3pB-PsxWbldIVU11MkNueHc/edit?pli=1[/url]

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!
Code: BlitzBasic
  1. AppTitle "Zelda-Style Text Scroller 2011"
  2.  
  3. Graphics3D 1024,768,0,2
  4. InitDraw()
  5.  
  6. SetBuffer BackBuffer()
  7.  
  8. Include "FastImage.bb" ;the fast image functions - Comes with the FastImage library.
  9. Include "Zelda-Text Setup.bb" ;the setup file for Zelda-Text
  10. Include "Zelda-Text Functions.bb" ;the functions for Zelda-Text
  11. Include "Zelda-Text Scripts.bb" ;the scripts for Zelda-Text. Add your own scripts to this include file.
  12. ;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!
  13.  
  14. Global rupees = 100 ;Just a variable for storing rupees. Not needed outside of this demo.
  15. Global testinteger% = 1 ;This is used to demonstrate the {Data} command later. Not needed outside of this demo.
  16. Global testfloat# = 1.1 ;This is used to demonstrate the {Data} command later. Not needed outside of this demo.
  17. Global teststr$ = "RANDOM STRING VARIABLE" ;This is used to demonstrate the {Data} command later. Not needed outside of this demo.
  18.  
  19. Global camera = CreateCamera() ;set up a small scene...
  20. Global triforce = CreatePivot() ;What would Zelda be without a triforce?
  21. Local tripower = CreateCylinder(3,1)
  22. Local triwisdom = CreateCylinder(3,1)
  23. Local tricourage = CreateCylinder(3,1)
  24. Local light = CreateLight()
  25.  
  26. EntityColor tripower,255,255,100
  27. EntityColor triwisdom,255,255,100
  28. EntityColor tricourage,255,255,100
  29. EntityShininess tripower,1.0
  30. EntityShininess triwisdom,1.0
  31. EntityShininess tricourage,1.0
  32.  
  33. RotateEntity tripower,-90,0,0
  34. ScaleEntity tripower,1.0,0.15,1.0
  35. PositionEntity tripower,0,1,3
  36.  
  37. RotateEntity triwisdom,-90,0,0
  38. ScaleEntity triwisdom,1.0,0.15,1.0
  39. PositionEntity triwisdom,0.865,-0.5,3
  40.  
  41. RotateEntity tricourage,-90,0,0
  42. ScaleEntity tricourage,1.0,0.15,1.0
  43. PositionEntity tricourage,-0.865,-0.5,3
  44.  
  45. PositionEntity triforce,0,0,3
  46. EntityParent tripower,triforce
  47. EntityParent triwisdom,triforce
  48. EntityParent tricourage,triforce
  49. Global hiddentext = 0
  50. MoveEntity triforce,0,0,1
  51.  
  52. PointEntity camera,triforce
  53.  
  54. PositionEntity light,EntityX(triforce) + 10,EntityY(triforce),EntityZ(triforce),True
  55. PointEntity light,triforce ;This is the end of the background scene
  56.  
  57. SetTextScrollingRate(0.6,20.0) ;TAKE CAUTION WITH QUICK SCROLL RATES. PAUSE FUNCTIONS STRUGGLE WITH THOSE
  58.  
  59. ;Here are some variables to know when certain text has finished. I like using Globals in this situation, but use whatever method suits you best.
  60. Global script1done = 0
  61. Global script2done = 0
  62. Global script3done = 0
  63.  
  64. ;Before we start the main, I wanted to include some intro text. Rather than make the Main more complex than it is currently, I've
  65. ;just decided to make a mini-loop at the beginning. You can completely ignore this code if you want, it doesn't demonstrate concept at all.
  66. Local continue = 0
  67.  
  68. While continue = 0
  69.  
  70.         If KeyDown(1) Then End
  71.        
  72.         RenderWorld
  73.         UpdateWorld
  74.        
  75.         Cls ;don't care about the background scene yet.
  76.        
  77.         continue = DrawScrollingText(7) ;This just draws the intro text. Like I said, ignore this block because it doesn't demonstrate the command set well.
  78.        
  79.         Flip
  80.        
  81. Wend
  82.        
  83.  
  84. While Not KeyDown(1) ;And the MAIN! Here we go...
  85.  
  86.         TurnEntity triforce,0,0.5,0,True
  87.        
  88.         If KeyHit(17) ;the W Key, if you push it, it changes the CameraClsColor() so that you can see what the textbox looks like in it's fullest.
  89.                 Local clsred
  90.                 Local clsgreen
  91.                 Local clsblue
  92.                 clsred = 255 - clsred
  93.                 clsgreen = 255 - clsgreen
  94.                 clsblue = 255 - clsblue
  95.                 CameraClsColor(camera,clsred,clsgreen,clsblue)
  96.         EndIf
  97.        
  98.         If KeyHit(2) ;all of these quick if's are used to demonstrate the {Data} command later on.
  99.                 testinteger = testinteger + 1
  100.         EndIf
  101.         If KeyHit(3)
  102.                 testinteger = testinteger - 1
  103.         EndIf
  104.         If KeyHit(4)
  105.                 testfloat# = testfloat# + 0.1
  106.         EndIf
  107.         If KeyHit(5)
  108.                 testfloat# = testfloat# - 0.1
  109.         EndIf
  110.         If KeyHit(6)
  111.                 If Len(teststr$) < 50
  112.                         teststr$ = teststr$ + Chr$(Rand(33,126))
  113.                 EndIf
  114.                 If Len(teststr$) >= 50
  115.                         teststr$ = "RANDOM STRING VARIABLE"
  116.                 EndIf
  117.         EndIf
  118.        
  119.         UpdateWorld
  120.         RenderWorld
  121.         ;This is one of a billion examples of how to start the text scrolling process.
  122.         ;The example below just starts the scrolling once it hits this line, and will quit on it's own once it reaches the end of the group.
  123.         script1done = DrawScrollingText(1)
  124.         ;More likely than not, you'll want to wait for an event trigger to start text scrolling.
  125.         ;In this situation, I've decided to use the ending of script 1 as the starting trigger for script 2.
  126.         If script1done = 1
  127.                 UpdateScriptIntData("testinteger%",testinteger%) ;Used to demonstrate the {Data} command. Have to call this before the DrawScrollingText() function.
  128.                 UpdateScriptFloatData("testfloat#",testfloat#) ;Used to demonstrate the {Data} command. Have to call this before the DrawScrollingText() function.
  129.                 UpdateScriptStringData("teststr$",teststr$) ;Used to demonstrate the {Data} command. Have to call this before the DrawScrollingText() function.
  130.                 script2done = DrawScrollingText(2)
  131.         EndIf
  132.         If script2done = 1 ;If group 2 is finished scrolling...
  133.                 UpdateScriptIntData("rupees%",rupees%) ;Update the rupees data in the strings.
  134.                 Local currentsection = GetCurrentDrawingSection(3) ;Let's remember the currect section we're on so we can use it to change the game with Yes/No commands.
  135.                 script3done = DrawScrollingText(3)
  136.                 If currentsection = 6 ;If we were at section 6 of group 3 of the scrolling text (Do you want me to take 10 rupees away?)
  137.                         If script3done = 2 ;If we selected "Yes"
  138.                                 If rupees < 10 ;If they don't have at least 10 rupees
  139.                                         SetCurrentDrawingSection(3,9) ;Change the text to reflect this scenario
  140.                                 EndIf
  141.                                 If rupees >= 10 ;If they have at least 10 rupees
  142.                                         rupees = rupees - 10
  143.                                 EndIf
  144.                         EndIf
  145.                         If script3done = 3 ;If we selected "No"
  146.                                 If rupees < 20 ;If they don't have at least 20 rupees
  147.                                         SetCurrentDrawingSection(3,GetMaximumScriptSection(3)) ;Change the text to reflect this scenario. The last section of group 3 is the right text.
  148.                                 EndIf
  149.                                 If rupees >= 20 ;If they have at least 20 rupees
  150.                                         rupees = rupees - 20
  151.                                 EndIf
  152.                         EndIf
  153.                 EndIf
  154.         EndIf
  155.         ;later, you could reset the scripts and start the drawing over again.
  156.         If script3done = 1 And hiddentext = 0
  157.                 script1done = 0 ;Let's reset our trigger system.
  158.                 script2done = 0
  159.                 script3done = 0
  160.                 DrawScriptAgain(1) ;Don't let the function name confuse you. This only resets scompleted back to 0 so that DrawScrollingText(1) will start over.
  161.                 DrawScriptAgain(2) ;Same as above
  162.                 DrawScriptAgain(3) ;Same as above
  163.         EndIf
  164.         ;some extra stuff...
  165.         StartDraw
  166.                 SetScale(0.75,0.75)
  167.                 SetColor(0,0,0) ;Set the color to black in case CameraClsColor() is white
  168.                 DrawText("Hit W to change the CameraClsColor()",50,50)
  169.                 DrawText("Rupees: " + rupees,50,70)
  170.                 SetColor(255,255,255) ;Set the color to white in case the CameraClsColor() is black
  171.                 DrawText("Hit W to change the CameraClsColor()",50,90)
  172.                 DrawText("Rupees: " + rupees,50,110)
  173.                 SetScale(1.0,1.0)
  174.         EndDraw
  175.         If KeyDown(14) ;debugging stuff...Holding Backspace Delays 1 second
  176.                 Delay 1000
  177.         EndIf
  178.         If KeyDown(31) ;Holding 'S' skips to the end of the current section. There's not a function for this, but this is essentially all you have to do.
  179.                                    ;Keep in mind that this is very useful, but I wouldn't ever do this during the last section of a group or with an {End Group} command.
  180.                                    ;doing so causes one of the dialogue sounds to skip when it should play. Not a major bug, but one to be concerned with regardless.
  181.                 scrollingtextpointer = 10000
  182.         EndIf
  183.         If GetCurrentDrawingSection(3) = GetMaximumScriptSection(3) - 1
  184.                 If KeyDown(44)
  185.                         hiddentext = 1
  186.                         ResetScripts()
  187.                         QuitTextDrawing(1)
  188.                         QuitTextDrawing(2)
  189.                         QuitTextDrawing(3)
  190.                 EndIf
  191.         EndIf
  192.         If hiddentext = 1
  193.                 Cls
  194.                 SetTextBoxColor(155,100,255,255)
  195.                 Local xtradone = DrawScrollingText(4)
  196.                 If xtradone = 1
  197.                         SetTextBoxColor()
  198.                         Local xtradone2 = DrawScrollingText(5,0,1,True)
  199.                 EndIf
  200.                 If xtradone2 = 1
  201.                         SetTextBoxColor(155,100,255,255)
  202.                         Local xtradone3 = DrawScrollingText(6)
  203.                 EndIf
  204.                 If xtradone3 = 1
  205.                         SetTextBoxColor()
  206.                         script1done = 0
  207.                         script2done = 0
  208.                         script3done = 0
  209.                         xtradone = 0
  210.                         xtradone2 = 0
  211.                         xtradone3 = 0
  212.                         hiddentext = 0
  213.                         ResetScripts()
  214.                         DrawAllScriptsAgain()
  215.                 EndIf
  216.         EndIf
  217.         If KeyHit(32) ;more debugging stuff...don't need to copy...
  218.                                   ;If you push "D", this will dump a lot of information to the log,
  219.                                   ;so be patient. Could take up to 30 seconds in some situations.
  220.                                   ;Esc will exit...
  221.                 DebugLog " "
  222.                 DebugLog " "
  223.                 DebugLog " "
  224.                 DebugLog " "
  225.                 Local counting = 0
  226.                 Local s.script
  227.                 For s.script = Each script
  228.                         If KeyDown(1) Then End
  229.                         Cls
  230.                         Text 0,0,"Please wait. Dumping debug information. Can take over 30 seconds to complete. Esc Key will exit the demo."
  231.                         Flip
  232.                         counting = counting + 1
  233.                         DebugLog "This is pass " + counting
  234.                         DebugLog "s     hestring$ = " + s       hestring$
  235.                         DebugLog "scolorr = " + scolorr
  236.                         DebugLog "scolorg = " + scolorg
  237.                         DebugLog "scolorb = " + scolorb
  238.                         DebugLog "soriginal = " + soriginal
  239.                         DebugLog "spause = " + spause
  240.                         DebugLog "spadded = " + spadded
  241.                         DebugLog "sskip = " + sskip
  242.                         DebugLog "sentiregroup = " + sentiregroup
  243.                         DebugLog "ssmallgroup = " + ssmallgroup
  244.                         DebugLog "s     rimmedlength = " + s    rimmedlength
  245.                         DebugLog "shalign = " + shalign
  246.                         DebugLog "svalign = " + svalign
  247.                         DebugLog "sselectedyes = " + sselectedyes
  248.                         DebugLog "sselectedno = " + sselectedno
  249.                         DebugLog "syesjumpto = " + syesjumpto
  250.                         DebugLog "s
  251. ojumpto = " + s
  252. ojumpto
  253.                         DebugLog "scompleted = " + scompleted
  254.                         DebugLog "scurrentsection = " + scurrentsection
  255.                         DebugLog "smillisectimer = " + smillisectimer
  256.                         DebugLog "s     heoffsetpos = " + s     heoffsetpos
  257.                         DebugLog "sjumptosection = " + sjumptosection
  258.                         DebugLog "s
  259. awstring$ = " + s
  260. awstring$
  261.                         DebugLog "sdatareference = " + sdatareference$
  262.                         DebugLog "sstoredintdata = " + sstoredintdata
  263.                         DebugLog "sstoredfloatdata# = " + sstoredfloatdata#
  264.                         DebugLog "sstoredstringdata$ = " + sstoredstringdata$
  265.                         DebugLog "sdatatype$ = " + sdatatype$
  266.                         DebugLog "sintdatachanged = " + sintdatachanged
  267.                         DebugLog "sfloatdatachanged = " + sfloatdatachanged
  268.                         DebugLog "sstringdatachanged = " + sstringdatachanged
  269.                         DebugLog "sgroupend = " + sgroupend
  270.                         DebugLog "sstringwihtoutdata$ = " + sstringwithoutdata$
  271.                         DebugLog "s     extboxcolorintensity# = " + s   extboxcolorintensity#
  272.                         DebugLog "s     extboxcolorred = " + s  extboxcolorred
  273.                         DebugLog "s     extboxcolorgreen = " + s        extboxcolorgreen
  274.                         DebugLog "s     extboxcolorblue = " + s extboxcolorblue
  275.                         DebugLog " "
  276.                         DebugLog " "
  277.                 Next
  278.                 DebugLog " "
  279.                 DebugLog " "
  280.                 DebugLog " "
  281.                 DebugLog " "
  282.         EndIf
  283.  
  284.         Flip
  285.        
  286.         ;sinticker = sinticker + 1 ;This is part of being able to use 'sinticker' as opposed to Millisecs() for Sin() values. Uncomment if you prefer this method.
  287.         ;If sinticker >= 360
  288.         ;       sinticker = 0
  289.         ;EndIf
  290.  
  291. Wend
  292.  
  293. End
  294.  

Code :
Code: BlitzBasic
  1. 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:
Code: [Select]
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:
Code: [Select]
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:
Code: [Select]
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:
Code: [Select]
Global dialogue = CreateScript("Testing 2D Graphics!",1,1)
Should instead be this:
Code: [Select]
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... :/
Code: [Select]
Graphics3D 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

CreateScript("Testing 2D Graphics!",1,1)

While Not KeyDown(1)

   Cls
   DrawScrollingText(1)
   Flip

Wend

End
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:
Code: [Select]
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:
Code: [Select]
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.
Code: [Select]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;Map API (ME) for Game and Edit Example
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;Coded By: mk2y10 (Dragon)
;;;Version V 0.0.0.8
;;;
;;;Reference Map API Functions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Include "ME_LevelEditor_Lib.bb"

;First, set the graphics.
Graphics 800,600,32,2
SetBuffer BackBuffer()

;This you do not need unless you do the hide window at start Hack.
;http://projectoutcast.forumup.com/viewtopic.php?t=7&mforum=projectoutcast#7
;(This makes every program you run/compile start with a hidden window)
;Win=SystemProperty("AppHWND")
;api_ShowWindow(Win,1)
;////

;Now we create a map
Map = ME_CreateMap ( 128, 128 )

;We now must load a tile image!
;This function is a SMART function for square tiles.
;That means you can have an image up to 16x16 tiles (256 Tile MAX)
;It reads the tiles from Top to Bottom and Left to Right!
;All we need to provide is the image handel and the square size of one tile (32 here)
Tile=LoadImage("gfxTileset.bmp")
ME_LoadTiles ( Tile , 32 )

;Before loading the player's image, we count the total number of frames in the playersheet

;Player

Global Player_Tiles_Wide% = 32

Global Player_Tiles_High% = 48

Global Player_Frame_Count% = ME_GetTotalFrames%("gfxloodelf_male3.png", Player_Tiles_Wide%, Player_Tiles_High%)

;Now we load the player image
;I will be using one stationary image, but you can load an animation
;   via the LoadAnimImage()

Global Play=LoadAnimImage("gfxloodelf_male3.png", Player_Tiles_Wide%, Player_Tiles_High%, 0, Player_Frame_Count%)
ME_SetPlayerImage(Play)

;Set the player's background color to invisible
ME_SetBackgroundInvisible(Play, 255, 255, 255)

;Enemy

Global Enemy_Tiles_Wide% = 32

Global Enemy_Tiles_High% = 32

Global Enemy_Frame_Count% = ME_GetTotalFrames%("gfxChu-chu.bmp", Enemy_Tiles_Wide%, Enemy_Tiles_High%)

;Now we load the enemy image
;I will be using one stationary image, but you can load an animation
;   via the LoadAnimImage()

Global Enemy=LoadAnimImage("gfxChu-chu.bmp", Enemy_Tiles_Wide%, Enemy_Tiles_High%, 0, Enemy_Frame_Count%)
ME_SetEnemyImage(Enemy)

;Set the enemy's background color to invisible
ME_SetBackgroundInvisible(Enemy, 255, 0, 255)

;Now we set the Map mode and Player mods. Here are the modes:
;0 - Do not restrict
;1 - Restrict only X axis
;2 - Restrict only Y axis
;3 - Restrict both X and Y
;
;~When used in ME_SetMapMode(), it prevents the camera from going of
;   the grid, no matter where the player/point-of-intrest is (POI)
;~When used in ME_SetPOIMode(), it prevents the player (POI) from moving of the map.
;
;Here we want to use Mode 3 for both:
ME_SetMapMode(3)
ME_SetPOIMode(3)

;Now that the restrictions are in place, we need to place the player (POI) on the map!
ME_SetPOI(32,32) ;This is in pixels, not grid units!

;You must set the map as the map to be drawn
ME_SetMap(Map)

;The last thing before the loop (optional) is to turn a grid overlay ON/OFF
;It starts out off.
ME_ShowGrid(1)

Global plxspeed#
Global plyspeed#

Global plx#
Global ply#

;Now the loop
While Not KeyHit(1)
Cls


;If your not holding down a key, then reset the player movement so the player doesn't fly off the screen
If Not GetKey() Then plx# = 0 : ply# = 0



;If your NOT holding down the run button (Shift)
If Not KeyDown(42) Or KeyDown(54)



plxspeed# = 1.0
plyspeed# = 1.0


;Otherwise
Else



plxspeed# = 2.0
plyspeed# = 2.0



EndIf



playeranimspeed# = .09



If KeyDown(200) Or KeyDown(17) Then ply# = -plyspeed# : playerdir% = 2
If KeyDown(208) Or KeyDown(31) Then ply# = +plyspeed# : playerdir% = 8
If KeyDown(203) Or KeyDown(30) Then plx# = -plxspeed# : playerdir% = 4
If KeyDown(205) Or KeyDown(32) Then plx# = +plxspeed# : playerdir% = 6



If playerdir% = 2 Then



defaultstartframe# = 13.0
defaultendframe#   = 16.0



ElseIf playerdir% = 4 Then



defaultstartframe# = 5.0
defaultendframe#   = 8.0



ElseIf playerdir% = 6 Then



defaulstartframe# = 9.0
defaultendframe#  = 12.0



ElseIf playerdir% = 8 Then



defaultstartframe# = 1.0
defaultendframe#   = 4.0



EndIf



startframe# = startframe# + 1 * playeranimspeed#
If startframe# > endframe# Then startframe# = defaultstartframe#
If startframe# < 1 Then startframe# = defaultstartframe#



ME_SetPlayerImage(Play, startframe#)
ME_SetEnemyImage(Enemy, 1)



;Movement is simple
;To move the player (POI,) do the following:
ME_MovePOI(plx#,ply#)

;This lets you move the player any of the four directions!

;We update the map
ME_UpdateMap()
;Now we set the color of the grid outlines (if you turned them on)
Color 100,100,100
;And then we draw it!
ME_DrawMap()
;And then we reset the color of the text!
Color 255, 255, 255



enemywidth# = ImageWidth(Enemy)/2 ;Use /2 if the enemy graphic's width is twice as small as the frame
enemyheight# = ImageHeight(Enemy)/2 ;Use /2 if the enemy graphic's height is twice as small as the frame



If enx# < enemywidth# Then enx# = enemywidth#
If enx# > GraphicsWidth()-enemywidth# Then enx# = GraphicsWidth()-enemywidth#
If eny# < enemyheight# Then eny# = enemyheight#
If eny# > GraphicsHeight()-enemyheight# Then eny# = GraphicsHeight()-enemyheight#



DrawImage Enemy, enx#, eny#, 1



Text GraphicsWidth()/2, GraphicsHeight()/2, "startframe#: "+startframe#, 1, 1
Text GraphicsWidth()/2, GraphicsHeight()/2+20, "endframe#: "+endframe#, 1, 1
Text GraphicsWidth()/2, GraphicsHeight()/2+40, "playerdir%: "+playerdir%, 1, 1



Flip


Wend



End
ME_LevelEditor_Lib.bb (Credit: mk2y10):
Code: [Select]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;Map API for Game and Editor
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;Coded By: mk2y10 (Dragon)
;;;Version: V 0.0.0.8
;;;
;;;
;;;
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;Functions:
;;;ME_AtPoint ( LocationX, LocationY )
;;;ME_CreateMap ( Width, Height, [DefaultTile])
;;;ME_DrawMap ( )
;;;ME_GetTile ( LocationX, LocationY )
;;;ME_LoadTiles ( Image, Size )
;;;ME_MovePOI ( XChange, YChange )
;;;ME_PickedX ( )
;;;ME_PickedY ( )
;;;ME_SetMap ( Map )
;;;ME_SetMapMode ( Mode )
;;;ME_SetPlayerImage ( Image, [Frame])
;;;ME_SetEnemyImage ( Image, [Frame])
;;;ME_SetPOI ( LocationX, LocationY )
;;;ME_SetPOIMode ( Mode )
;;;ME_SetTile ( LocationX, LocationY, Tile )
;;;ME_ShowGrid ( Bool )
;;;ME_UpdateMap ( )
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;Globals
Global ME_ofx      ;Map Offset X
Global ME_ofy      ;Map Offset Y
Global ME_msx      ;Map Width
Global ME_msy      ;Map Height
Global ME_poix      ;Point of Interest X (Player) (Camera's Center)
Global ME_poiy      ;Point of Interest Y (Player) (Camera's Center)
Global ME_map      ;Current map handle
Global ME_maps      ;Stores all maps loaded in memory
Global ME_tiles      ;Stores all tiles in a list
Global ME_tilesize   ;Srores the tile size (as a square)
Global ME_grid      ;Used to show the grid
Global ME_player      ;Used to hold the player's image
Global ME_playerstartfm   ;This holds the start frame / default start frame number to draw.
Global ME_playerendfm   ;This holds the end frame / default end frame number to draw.
Global ME_playermd   ;The mode of restictions placed on the POI (player)
Global ME_mode      ;This puts movement restrictions on the camera.
Global ME_pickx      ;The last picked X location
Global ME_picky      ;The last picked Y location

;Gets the grid location at a specified point
Function ME_AtPoint(LX,LY)
X=(LX-ME_ofx)/ME_tilesize
Y=(LY-ME_ofy)/ME_tilesize
If X<0 Then X=0
If Y<0 Then Y=0
ME_pickx=X
ME_picky=Y
End Function

;Creates a new map
Function ME_CreateMap(SX,SY,Dft=0)
Re=CreateBank(((SX)*(SY))+4)
PokeByte(Re,0,SX)
PokeByte(Re,1,SY)
If Dft<>0
For A=2 To (SX*SY)+2
PokeByte(Re,A,Dft)
Next
EndIf
Return Re
End Function

;This draws the map
Function ME_DrawMap()
If ME_map=0 Then Return 0
SX=PeekByte(ME_map,0)
SY=PeekByte(ME_map,1)
For X=0 To SX-1
For Y=0 To SY-1
LX=(X*ME_tilesize)-ME_ofx
LY=(Y*ME_tilesize)-ME_ofy
If LX>0-ME_tilesize And LX<=GraphicsWidth()
If LY>0-ME_tilesize And LY<=GraphicsHeight()
Lc=((X*SX)+Y)+2
Tp=PeekByte(ME_map,Lc)
Im=PeekInt(ME_tiles,Tp*4)
If Im<>0
DrawImage(Im,LX,LY)
EndIf
If ME_grid=1
Rect LX,LY,ME_tilesize,ME_tilesize,0
EndIf
EndIf
EndIf
Next
Next
If ME_player<>0
DrawImage(ME_player,ME_poix-ME_ofx,ME_poiy-ME_ofy,ME_playerstartfm)
EndIf
End Function

;This gets the tile number as a location
Function ME_GetTile(X,Y)
If ME_map=0 Then Return
Lc=((X*SX)+Y)+2
Re=PeekByte(ME_map,Lc)
Return Re
End Function

;Loads an Image as a set of tiles
Function ME_LoadTiles(Im,Sz)
If Im=0 Then Return
SX=ImageWidth(Im)
SY=ImageHeight(Im)
IX=Floor(SX/Sz)
IY=Floor(SY/Sz)
If ME_tiles<>0
For A=0 To BankSize(ME_tiles)/4
Lc=A*4
R=PeekInt(ME_tiles,Lc)
If R<>0
FreeImage(R)
EndIf
Next
FreeBank(ME_tiles)
EndIf
ME_tiles=CreateBank(256*4)
For X=0 To IX-1
For Y=0 To IY-1
I=0
I=CreateImage(Sz,Sz)
CopyRect(X*Sz,Y*Sz,Sz,Sz,0,0,ImageBuffer(Im),ImageBuffer(I))
PokeInt(ME_tiles,Lc,I)
Re=Re+1
If Re>255 Then Goto Done
Lc=Lc+4
Next
Next
.Done
ME_tilesize=Sz
Return Re
End Function

;This moves the player by an amount
Function ME_MovePOI(X,Y)
ME_poix=ME_poix+X
ME_poiy=ME_poiy+Y
End Function

;Returns the last Picked X value
Function ME_PickedX()
Return ME_pickx
End Function

;Returns the last Picked Y value
Function ME_PickedY()
Return ME_picky
End Function

;This sets a map as the current drawing map
Function ME_SetMap(Map)
ME_map=Map
End Function

;This sets the way the program acts when the end of a map is reached.
Function ME_SetMapMode(Md)
ME_mode=Md
End Function

;This sets the player's Image / Animation
Function ME_SetPlayerImage(Im,StartFm=0,EndFm=0)
SX=ImageWidth(Im)
SY=ImageHeight(Im)
HandleImage(Im,SX/2,SY/2)
ME_player=Im
ME_playerstartfm=StartFm
ME_playerendfm=EndFm
End Function

;This sets the enemy's Image / Animation
Function ME_SetEnemyImage(Im,StartFm=0,EndFm=0)
SX=ImageWidth(Im)
SY=ImageHeight(Im)
HandleImage(Im,SX/2,SY/2)
ME_enemy=Im
ME_enemystartfm=StartFm
ME_enemyendfm=EndFm
End Function

;This sets the Point of Intrest of the Map (The Center of the Player!)
Function ME_SetPOI(LX,LY)
ME_poix=LX
ME_poiy=LY
End Function

;This sets the Enemy's Point of Intrest of the Map (The Center of the Enemy!)
Function ME_SetEPOI(LX,LY)
ME_eoix=LX
ME_eoiy=LY
End Function

;This sets the mode for limits on the POI (player)
Function ME_SetPOIMode(Md)
ME_playermd=Md
End Function

;This sets the tile as the designed number
Function ME_SetTile(X,Y,Tl)
If ME_map=0 Then Return
SX=PeekByte(ME_map,0)
Lc=((X*SX)+Y)+2
PokeByte(ME_map,Lc,Tl)
End Function

;This toggles the grid on and off
Function ME_ShowGrid(Bool)
ME_grid=Bool
End Function

;This updates the map
Function ME_UpdateMap()
If ME_map<>0
SX=PeekByte(ME_map,0)
SY=PeekByte(ME_map,1)
EndIf
ME_msx=SX*ME_tilesize
ME_msy=SY*ME_tilesize
ME_ofx=(ME_poix-GraphicsWidth()/2)
ME_ofy=(ME_poiy-GraphicsHeight()/2)
Md=ME_mode
SCX=GraphicsWidth()
SCY=GraphicsHeight()
If Md=1 Or Md=3
If ME_ofx<0 Then ME_ofx=0
If ME_ofx>ME_msx-scx Then ME_ofx=ME_msx-scx
EndIf
If Md=2 Or Md=3
If ME_ofy<0 Then ME_ofy=0
If ME_ofy>ME_msy-scy Then ME_ofy=ME_msy-scy
EndIf
If ME_player<>0
Md=ME_playermd
SX=ImageWidth(ME_player)/2
SY=ImageHeight(ME_player)/2
If Md=1 Or Md=3
If ME_poix<SX Then ME_poix=SX
If ME_poix>ME_msx-sx Then ME_poix=ME_msx-sx
EndIf
If Md=2 Or Md=3
If ME_poiy<Sy Then ME_poiy=Sy
If ME_poiy>ME_msy-sy Then ME_poiy=ME_msy-sy
EndIf
EndIf
End Function



Function ME_GetTotalFrames%(filename$, tileswide%, tileshigh%)



ME_Tilesheet%  = LoadImage(filename$)
ME_Frameswide% = ImageWidth(ME_Tilesheet) / tileswide%
ME_frameshigh% = ImageHeight(ME_Tilesheet) / tileshigh%
ME_Totalframes = ME_Frameswide% * ME_Frameshigh%
FreeImage ME_Tilesheet%



Return ME_Totalframes%



End Function



Function ME_SetBackgroundInvisible(img, R=0, G=0, B=0)



MaskImage img, R, G, B



End Function
The graphics go in the gfx folder: <a href="http://www.mediafire.com/?8p58d6km7tparmh" target="_blank">http://www.mediafire.com/?8p58d6km7tparmh[/url]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:
Code: [Select]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;Map API (ME) for Game and Edit Example
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;Coded By: mk2y10 (Dragon)
;;;Version V 0.0.0.8
;;;
;;;Reference Map API Functions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;First, set the graphics.
Graphics3D 800,600,32,2
InitDraw()
SetBuffer BackBuffer()

Include "ME_LevelEditor_Lib.bb"
Include "Text ScrollingFastImage.bb"
Include "Text Scrollingelda-Text Setup.bb"
Include "Text Scrollingelda-Text Functions.bb"
;Include "Text Scrollingelda-Text Scripts.bb" You should place all CreateScripts() in a seperate Include file.
;I recommend that you keep all of your scripts in a separate Include file so it doesn't make your IDE look ugly.
CreateScript("You're more than likely going to want to change the default key values, so the easiest way to do this is to use Blitz's Find and Replace ",1,1)
CreateScript("to look for all KeyDown() and KeyHit() values, and change the scancodes accordingly. Note that you can control the player ",1,1)
CreateScript("with the arrow keys like you normally would WHILE the text is scrolling. Press the left Alt button to continue.",1,1)
CreateScript("This is part two of the test. {Color 255,0,0}This is Red.{Color 0,255,0}This is Green.{Color 0,0,255}This is Blue.",1,2)
CreateScript("This is part three of the test. Pause for 1 second now{Pause 1000} before continuing on.",1,3)
CreateScript("This is part four of the test. Press Enter to skip to the end.{Skip}",1,4)
CreateScript("Blahadfadsfaew;rlkajv;dlkfjaio;fja;lkvn;zdklfjaweoirj;zxlkvjnz;ldkjvhaz;dsfj",1,5)
CreateScript("asdfkujhresjnd;vkjsdfhg;aerufj;sdfjnv;sdfkjghs;dfkjghs;dfgjs;dflg",1,6)
CreateScript("You get the idea of what's going on.",1,7)

;This you do not need unless you do the hide window at start Hack.
;http://projectoutcast.forumup.com/viewtopic.php?t=7&mforum=projectoutcast#7
;(This makes every program you run/compile start with a hidden window)
;Win=SystemProperty("AppHWND")
;api_ShowWindow(Win,1)
;////

;Now we create a map
Map = ME_CreateMap ( 128, 128 )

;We now must load a tile image!
;This function is a SMART function for square tiles.
;That means you can have an image up to 16x16 tiles (256 Tile MAX)
;It reads the tiles from Top to Bottom and Left to Right!
;All we need to provide is the image handel and the square size of one tile (32 here)
Tile=LoadImage("gfxTileset.bmp")
ME_LoadTiles ( Tile , 32 )

;Before loading the player's image, we count the total number of frames in the playersheet

;Player

Global Player_Tiles_Wide% = 32

Global Player_Tiles_High% = 48

Global Player_Frame_Count% = ME_GetTotalFrames%("gfxloodelf_male3.png", Player_Tiles_Wide%, Player_Tiles_High%)

;Now we load the player image
;I will be using one stationary image, but you can load an animation
;   via the LoadAnimImage()

Global Play=LoadAnimImage("gfxloodelf_male3.png", Player_Tiles_Wide%, Player_Tiles_High%, 0, Player_Frame_Count%)
ME_SetPlayerImage(Play)

;Set the player's background color to invisible
ME_SetBackgroundInvisible(Play, 255, 255, 255)

;Enemy

Global Enemy_Tiles_Wide% = 32

Global Enemy_Tiles_High% = 32

Global Enemy_Frame_Count% = ME_GetTotalFrames%("gfxChu-chu.bmp", Enemy_Tiles_Wide%, Enemy_Tiles_High%)

;Now we load the enemy image
;I will be using one stationary image, but you can load an animation
;   via the LoadAnimImage()

Global Enemy=LoadAnimImage("gfxChu-chu.bmp", Enemy_Tiles_Wide%, Enemy_Tiles_High%, 0, Enemy_Frame_Count%)
ME_SetEnemyImage(Enemy)

;Set the enemy's background color to invisible
ME_SetBackgroundInvisible(Enemy, 255, 0, 255)

;Now we set the Map mode and Player mods. Here are the modes:
;0 - Do not restrict
;1 - Restrict only X axis
;2 - Restrict only Y axis
;3 - Restrict both X and Y
;
;~When used in ME_SetMapMode(), it prevents the camera from going of
;   the grid, no matter where the player/point-of-intrest is (POI)
;~When used in ME_SetPOIMode(), it prevents the player (POI) from moving of the map.
;
;Here we want to use Mode 3 for both:
ME_SetMapMode(3)
ME_SetPOIMode(3)

;Now that the restrictions are in place, we need to place the player (POI) on the map!
ME_SetPOI(32,32) ;This is in pixels, not grid units!

;You must set the map as the map to be drawn
ME_SetMap(Map)

;The last thing before the loop (optional) is to turn a grid overlay ON/OFF
;It starts out off.
ME_ShowGrid(1)

Global plxspeed#
Global plyspeed#

Global plx#
Global ply#

;Now the loop
While Not KeyHit(1)
Cls


;If your not holding down a key, then reset the player movement so the player doesn't fly off the screen
If Not GetKey() Then plx# = 0 : ply# = 0



;If your NOT holding down the run button (Shift)
If Not KeyDown(42) Or KeyDown(54)



plxspeed# = 1.0
plyspeed# = 1.0


;Otherwise
Else



plxspeed# = 2.0
plyspeed# = 2.0



EndIf



playeranimspeed# = .09



If KeyDown(200) Or KeyDown(17) Then ply# = -plyspeed# : playerdir% = 2
If KeyDown(208) Or KeyDown(31) Then ply# = +plyspeed# : playerdir% = 8
If KeyDown(203) Or KeyDown(30) Then plx# = -plxspeed# : playerdir% = 4
If KeyDown(205) Or KeyDown(32) Then plx# = +plxspeed# : playerdir% = 6



If playerdir% = 2 Then



defaultstartframe# = 13.0
defaultendframe#   = 16.0



ElseIf playerdir% = 4 Then



defaultstartframe# = 5.0
defaultendframe#   = 8.0



ElseIf playerdir% = 6 Then



defaulstartframe# = 9.0
defaultendframe#  = 12.0



ElseIf playerdir% = 8 Then



defaultstartframe# = 1.0
defaultendframe#   = 4.0



EndIf



startframe# = startframe# + 1 * playeranimspeed#
If startframe# > endframe# Then startframe# = defaultstartframe#
If startframe# < 1 Then startframe# = defaultstartframe#



ME_SetPlayerImage(Play, startframe#)
ME_SetEnemyImage(Enemy, 1)



;Movement is simple
;To move the player (POI,) do the following:
ME_MovePOI(plx#,ply#)

;This lets you move the player any of the four directions!

;We update the map
ME_UpdateMap()
;Now we set the color of the grid outlines (if you turned them on)
Color 100,100,100
;And then we draw it!
ME_DrawMap()
;And then we reset the color of the text!
Color 255, 255, 255



enemywidth# = ImageWidth(Enemy)/2 ;Use /2 if the enemy graphic's width is twice as small as the frame
enemyheight# = ImageHeight(Enemy)/2 ;Use /2 if the enemy graphic's height is twice as small as the frame



If enx# < enemywidth# Then enx# = enemywidth#
If enx# > GraphicsWidth()-enemywidth# Then enx# = GraphicsWidth()-enemywidth#
If eny# < enemyheight# Then eny# = enemyheight#
If eny# > GraphicsHeight()-enemyheight# Then eny# = GraphicsHeight()-enemyheight#



DrawImage Enemy, enx#, eny#, 1



Text GraphicsWidth()/2, GraphicsHeight()/2, "startframe#: "+startframe#, 1, 1
Text GraphicsWidth()/2, GraphicsHeight()/2+20, "endframe#: "+endframe#, 1, 1
Text GraphicsWidth()/2, GraphicsHeight()/2+40, "playerdir%: "+playerdir%, 1, 1

DrawScrollingText(1) ;And, here's the command to scroll text. Read up on the Help Files for more information.



Flip


Wend



End
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! =DIs 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:
Code: [Select]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;Map API (ME) for Game and Edit Example
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;Coded By: mk2y10 (Dragon)
;;;Version V 0.0.0.8
;;;
;;;Reference Map API Functions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;First, set the graphics.
Graphics3D 800,600,32,2
InitDraw()
SetBuffer BackBuffer()

Include "ME_LevelEditor_Lib.bb"
Include "Text ScrollingFastImage.bb"
Include "Text Scrollingelda-Text Setup.bb"
Include "Text Scrollingelda-Text Functions.bb"
;Include "Text Scrollingelda-Text Scripts.bb" You should place all CreateScripts() in a seperate Include file.
;I recommend that you keep all of your scripts in a separate Include file so it doesn't make your IDE look ugly.
CreateScript("You've found {Color 0,255,0}Green Chu Chu Jelly{Color 255,255,255}!",1,1)
CreateScript("This jelly has unique properties that everyone in ",1,2)
CreateScript("Hyrule is absolutely c{Pause 100}r{Pause 100}a{Pause 100}z{Pause 100}y{Pause 100} about. You'd better put it in your pack for later.",1,2)

;This you do not need unless you do the hide window at start Hack.
;http://projectoutcast.forumup.com/viewtopic.php?t=7&mforum=projectoutcast#7
;(This makes every program you run/compile start with a hidden window)
;Win=SystemProperty("AppHWND")
;api_ShowWindow(Win,1)
;////

;Now we create a map
Map = ME_CreateMap ( 128, 128 )

;We now must load a tile image!
;This function is a SMART function for square tiles.
;That means you can have an image up to 16x16 tiles (256 Tile MAX)
;It reads the tiles from Top to Bottom and Left to Right!
;All we need to provide is the image handel and the square size of one tile (32 here)
Tile=LoadImage("gfxTileset.bmp")
ME_LoadTiles ( Tile , 32 )

;Before loading the player's image, we count the total number of frames in the playersheet

;Player

Global Player_Tiles_Wide% = 32

Global Player_Tiles_High% = 48

Global Player_Frame_Count% = ME_GetTotalFrames%("gfxloodelf_male3.png", Player_Tiles_Wide%, Player_Tiles_High%)

;Now we load the player image
;I will be using one stationary image, but you can load an animation
;   via the LoadAnimImage()

Global Play=LoadAnimImage("gfxloodelf_male3.png", Player_Tiles_Wide%, Player_Tiles_High%, 0, Player_Frame_Count%)
ME_SetPlayerImage(Play)

;Set the player's background color to invisible
ME_SetBackgroundInvisible(Play, 255, 255, 255)

;Enemy

Global Enemy_Tiles_Wide% = 32

Global Enemy_Tiles_High% = 32

Global Enemy_Frame_Count% = ME_GetTotalFrames%("gfxChu-chu.bmp", Enemy_Tiles_Wide%, Enemy_Tiles_High%)

;Now we load the enemy image
;I will be using one stationary image, but you can load an animation
;   via the LoadAnimImage()

Global Enemy=LoadAnimImage("gfxChu-chu.bmp", Enemy_Tiles_Wide%, Enemy_Tiles_High%, 0, Enemy_Frame_Count%)
ME_SetEnemyImage(Enemy)

;Set the enemy's background color to invisible
ME_SetBackgroundInvisible(Enemy, 255, 0, 255)

;Now we set the Map mode and Player mods. Here are the modes:
;0 - Do not restrict
;1 - Restrict only X axis
;2 - Restrict only Y axis
;3 - Restrict both X and Y
;
;~When used in ME_SetMapMode(), it prevents the camera from going of
;   the grid, no matter where the player/point-of-intrest is (POI)
;~When used in ME_SetPOIMode(), it prevents the player (POI) from moving of the map.
;
;Here we want to use Mode 3 for both:
ME_SetMapMode(3)
ME_SetPOIMode(3)

;Now that the restrictions are in place, we need to place the player (POI) on the map!
ME_SetPOI(32,32) ;This is in pixels, not grid units!

;You must set the map as the map to be drawn
ME_SetMap(Map)

;The last thing before the loop (optional) is to turn a grid overlay ON/OFF
;It starts out off.
ME_ShowGrid(1)

Global plxspeed#
Global plyspeed#

Global plx#
Global ply#

;Now the loop
While Not KeyHit(1)
Cls


;If your not holding down a key, then reset the player movement so the player doesn't fly off the screen
If Not GetKey() Then plx# = 0 : ply# = 0



;If your NOT holding down the run button (Shift)
If Not KeyDown(42) Or KeyDown(54)



plxspeed# = 1.0
plyspeed# = 1.0


;Otherwise
Else



plxspeed# = 2.0
plyspeed# = 2.0



EndIf



playeranimspeed# = .09



If KeyDown(200) Or KeyDown(17) Then ply# = -plyspeed# : playerdir% = 2
If KeyDown(208) Or KeyDown(31) Then ply# = +plyspeed# : playerdir% = 8
If KeyDown(203) Or KeyDown(30) Then plx# = -plxspeed# : playerdir% = 4
If KeyDown(205) Or KeyDown(32) Then plx# = +plxspeed# : playerdir% = 6



If playerdir% = 2 Then



defaultstartframe# = 13.0
defaultendframe#   = 16.0



ElseIf playerdir% = 4 Then



defaultstartframe# = 5.0
defaultendframe#   = 8.0



ElseIf playerdir% = 6 Then



defaulstartframe# = 9.0
defaultendframe#  = 12.0



ElseIf playerdir% = 8 Then



defaultstartframe# = 1.0
defaultendframe#   = 4.0



EndIf



startframe# = startframe# + 1 * playeranimspeed#
If startframe# > endframe# Then startframe# = defaultstartframe#
If startframe# < 1 Then startframe# = defaultstartframe#



ME_SetPlayerImage(Play, startframe#)
ME_SetEnemyImage(Enemy, 1)



;Movement is simple
;To move the player (POI,) do the following:
ME_MovePOI(plx#,ply#)

;This lets you move the player any of the four directions!

;We update the map
ME_UpdateMap()
;Now we set the color of the grid outlines (if you turned them on)
Color 100,100,100
;And then we draw it!
ME_DrawMap()
;And then we reset the color of the text!
Color 255, 255, 255



enemywidth# = ImageWidth(Enemy)/2 ;Use /2 if the enemy graphic's width is twice as small as the frame
enemyheight# = ImageHeight(Enemy)/2 ;Use /2 if the enemy graphic's height is twice as small as the frame



If enx# < enemywidth# Then enx# = enemywidth#
If enx# > GraphicsWidth()-enemywidth# Then enx# = GraphicsWidth()-enemywidth#
If eny# < enemyheight# Then eny# = enemyheight#
If eny# > GraphicsHeight()-enemyheight# Then eny# = GraphicsHeight()-enemyheight#



DrawImage Enemy, enx#, eny#, 1



Text GraphicsWidth()/2, GraphicsHeight()/2, "startframe#: "+startframe#, 1, 1
Text GraphicsWidth()/2, GraphicsHeight()/2+20, "endframe#: "+endframe#, 1, 1
Text GraphicsWidth()/2, GraphicsHeight()/2+40, "playerdir%: "+playerdir%, 1, 1

If ImagesCollide(Play,plx#,ply#,startframe#,Enemy,enx#,eny#,1)
DrawScrollingText(1) ;And, here's the command to scroll text. Read up on the Help Files for more information.
Else
DrawScriptAgain(1) ;DON'T GET CONFUSED. THIS JUST MEANS WE WANT TO ENABLE THE TEXT TO DRAW AGAIN IF THEY COLLIDE, OTHERWISE IT WILl NEVER DRAW AGAIN
EndIf



Flip


Wend



End
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? :DThanks, 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:
Code: [Select]
;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:
Code: [Select]
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:
Code: [Select]
If drawdialoguebutton = 1 And scrollingtextcanskip <= 0 And tempdrawyesarrow = 0 And tempdrawnoarrow = 0 ;Draw the next section button
Local tempalphavalue# = (Sin#((MilliSecs() Mod 720)/2.0) + 1.0)/2.0 ;just a simple way to make it blink on and off. I picked this method to avoid
;extra Globals, but note that this is inacurate if Delay is used or if there is
;too big of a jump from the time taken to get back to this point. Hold 'Backspace'
;when at the end of a section to see what I mean. For a more accurate method,
;uncomment all lines regarding the global variable "sinticker", and also coment
;out this line to replace it with the one below. "sinticker" is just a number
;that increases by 1 every loop, and it's variable I use all the time for a much
;more acurate Sin() value as opposed to Millisecs().
;Local tempalphavalue# = (Sin#(sinticker*9) + 1.0)/2.0 ;Uncomment to use sinticker rather than Millisecs() (more accurate).
SetAlpha(tempalphavalue#)
DrawImageEx(scriptnextimg,512,710)
SetAlpha(1.0)
EndIf
If drawdialoguebutton = 2 ;Draw the end of dialogue button
tempalphavalue# = (Sin#((MilliSecs() Mod 720)/2.0) + 1.0)/2.0 ;just a simple way to make it blink on and off. Read comments above for more info.
;tempalphavalue# = (Sin#(sinticker*9) + 1.0)/2.0 ;Uncomment to use sinticker rather than Millisecs() (more accurate over long render-periods).
SetAlpha(tempalphavalue#)
DrawImageEx(scriptdoneimg,512,710)
SetAlpha(1.0)
EndIf
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)

 <div class="quote"> 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. </div> - 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)

 <div class="quote"> What is modular programming? </div>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?[code]Graphics3D 800,600,32,2
InitDraw()
SetBuffer BackBuffer()

Include "FastImage.bb"
Include "Zelda-Text Setup.bb"
Include "Zelda-Text Functions.bb"
;Include "Text Scrollingelda-Text Scripts.bb" You should place all CreateScripts() in a seperate Include file.
;I recommend that you keep all of your scripts in a separate Include file so it doesn't make your IDE look ugly.
CreateScript("You've found {Color 0,255,0}Green Chu Chu Jelly{Color 255,255,255}!",1,1)
CreateScript("This jelly has unique properties that everyone in ",1,2)
CreateScript("Hyrule is absolutely c{Pause 100}r{Pause 100}a{Pause 100