The Daily Click ::. Forums ::. Klik Coding Help ::. How to display a text char by char?
 

Post Reply  Post Oekaki 
 

Posted By Message

]Alpha[



Registered
  19/09/2003
Points
  245
29th January, 2009 at 11:27:32 -

Hi everyone!

I work on MMF1.5 and I need to display text char by char but I don't really know how to do it!
Thank you in advance!


P.S. I know it can be done with MMF2 (lua extension) but I don't know if something similar exist also for MMF1.5

 
All that I see is the years...

Dr. James MD

Addict

Registered
  08/12/2003
Points
  11941

First GOTW AwardSecond GOTW AwardThird GOTW AwardPicture Me This -Round 26- Winner!
29th January, 2009 at 12:56:08 -

If you use something like the Text Blitter you can append to a string, not sure if you can append as easily using the regular string object (never tried!). You just set the source string and append a character from it one at a time.

Edited by Dr. James MD

 
Image
http://uk.youtube.com/watch?v=j--8iXVv2_U
On the sixth day God created Manchester
"You gotta get that sand out your vaj!" x13
www.bossbaddie.com

Pkeod

Oontz Oontz Oontz

Registered
  19/11/2002
Points
  93

VIP Member
29th January, 2009 at 13:21:28 -

http://www.clickteam.com/mbfiles2/15641-TYPE_WRITER.ZIP

Tada :V

This is an example from 04, if you need more MMF 1.5 stuff you can search the old Clickteam forums at clickteam.com/CTforum

 
Faerie Solitaire - Get it now:

http://www.create-games.com/download.asp?id=7792

]Alpha[



Registered
  19/09/2003
Points
  245
29th January, 2009 at 15:33:15 -

Thanks Pkeod!
This is what I was searching for!

P.S. Thanks to Dr. James too

Edited by ]Alpha[

 
All that I see is the years...

]Alpha[



Registered
  19/09/2003
Points
  245
29th January, 2009 at 16:32:56 -

Just one more thing...
How can I change the font of the displayed text?

I don't understand why it display the text in a standard font, no matter which font you assigned to the object ;(

 
All that I see is the years...

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
29th January, 2009 at 17:34:11 -

Appending to a string like that is extremely slow.


Strings are immutable data types. That means that every time you want to edit a string, you have to create an entirely NEW string, and delete the old one. That means that to create a string of length N via appending each char, you use up a little over (N^2)/2 memory instead of N.

So if you have a game that writes a text like this that is fairly large, your game will experience dramatic slowdown when you try to append piece by piece.



Instead its safe to use the Binary object; binarys are mutable, meaning you can actually just add a character to the end of the same object, instead of creating a new one. So just create an empty binary, and append 1 character byte at a time to it, and you can retrieve the current string from it.

 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456

]Alpha[



Registered
  19/09/2003
Points
  245
30th January, 2009 at 19:09:33 -

Pixel, I'm interested.
Do you have an example?
I absolutely don't know how binary object works

Thank you!


 
All that I see is the years...

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
30th January, 2009 at 19:35:59 -

Nope. But it took me about 60 seconds to make one!
http://claniraq.googlepages.com/textexample.mfa


 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456

Cecilectomy

noPE

Registered
  19/03/2005
Points
  305

Has Donated, Thank You!VIP MemberWeekly Picture Me This Winner!Cardboard BoxGhostbuster!Pokemon Ball!ComputerBox RedSanta HatSnowman
I am an April Fool
30th January, 2009 at 19:50:34 -

there needs to be a static char[] array object.

the reason that strings use so much memory is that theyre dynamic. when you append to a string it has to make an entirely new entry in memory to accomodate the new length of chars and delete the old memory locations. amirite?

but the process of appending to a string char by char shouldnt even be noticeable on any newish computer pixel.

 
n/a

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
30th January, 2009 at 20:48:08 -

Depends on what you're using it for. In my text-based FPS game, I used strings along the Y vertical that pulled from the main text to create the effect, which meant I had around 32 strings of up to length 24 each. And so instead of having to create 32 string objects per frame, it was creating 9600 strings per frame, which made it run at about 1 FPS instead of 50 FPS.

So if you're going to be building anything inside a fast loop its especially important, or having more than one object, etc etc.

Edited by Pixelthief

 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456

]Alpha[



Registered
  19/09/2003
Points
  245
31st January, 2009 at 09:52:59 -

Thank you Pixel, but I don't have MMF2.
As I said before, I only work on MMF1.5 T_T

 
All that I see is the years...

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
31st January, 2009 at 10:39:13 -

grr missed that

Three objects:
Binary Object
String Object (Default paragraph is your text)
String Object (Blank)

Image

 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456

Klikmaster

Master of all things Klik

Registered
  08/07/2002
Points
  2599

Has Donated, Thank You!You've Been Circy'd!VIP MemberPS3 Owner
31st January, 2009 at 12:02:23 -

When you set the assign the string to the string object from the binary, doesn't that still have to delete and recreate the memory for the string object??

 
n/a

Cecilectomy

noPE

Registered
  19/03/2005
Points
  305

Has Donated, Thank You!VIP MemberWeekly Picture Me This Winner!Cardboard BoxGhostbuster!Pokemon Ball!ComputerBox RedSanta HatSnowman
I am an April Fool
31st January, 2009 at 18:25:18 -

thats exactly what i was thinking as soon as i saw that code snippet.

as long as you stay away from something like pixeltheifs text based fps where the entire raycasted world is rendered as ascii characters, you'll be fine.

 
n/a

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
31st January, 2009 at 19:26:05 -


Originally Posted by Klikmaster
When you set the assign the string to the string object from the binary, doesn't that still have to delete and recreate the memory for the string object??



Yes, but in terms of overhead, its much faster on an order of magnitude. This is specifically for dealing with when you want to create a string out of chopped up chars, and display the end result. If you display every single substring along the way, you are creating exactly as many string objects. But you are only using 2 per frame, so it will never be system intensive.

Instead, if you are doing something that creates a 'large' text out of smaller chunks, and then displays the end result, like my Text Based FPS, it is impossible without doing something like this.


Imagine for a second that you added a function where if you hit the "Enter" button while someones char-by-char text was writing to the screen, it would jump one line ahead by running your "Append 1 char" function inside a fast loop 30 times or something. If you did it this way, it would still only be creating 1 string of weight 32 instead of 32 strings of combined weight 528

 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456
   

Post Reply



 



Advertisement

Worth A Click