Jump to content


Photo

Which One Goes First?


  • Please log in to reply
2 replies to this topic

#1 hellfire911

hellfire911

    GMC Member

  • New Member
  • 844 posts

Posted 09 July 2007 - 02:51 AM

Hi GMC,
This is a quick question, so I'm just asking for font_add_sprite, could someone show me the letter order of the sub-images?

Thanks, Hellfire-911 :ph34r:

Edited by hellfire911, 09 July 2007 - 02:52 AM.

  • 0

#2 Nodus

Nodus

    GMC Member

  • New Member
  • 4 posts

Posted 09 July 2007 - 04:14 AM

Ok here are my thoughts. Forgive me if this isn't what you're wanting...

So, the font_add_sprite from the manual states:

font_add_sprite(spr,first,prop,sep) Adds a new font and returns its index. The font is created from a sprite. The sprite should contain a subimage for each character. first indicate the index of the first character in the sprite. For example, use ord('0') if your sprite only contains the digits.


There is a typo or mistake in this I think. It would make more sense to me if it said:

"The sprite should contain a subimage for each character. first indicates the ascii code of the first character in the sprite."


So ord(0) will give you the ascii code 48. ord(A) = 65. ord(z) = 122. You cna find all these codes:

http://www.asciitable.com/

Anyway so the order of your sprite subimages need to be in order of the ascii table starting from the ascii code # you specify using 'first'.

At first I didn't understand how this worked so I wrote a little script to play around with it. Try it out if it helps (just put it in a draw event, run, and start pressing keys to see the new font and corresponding ascii codes).


{
font_index=font_add_sprite(sprite0,48,0,0);
draw_set_font(font_index);
draw_text(10,50,keyboard_lastchar);
draw_set_font(-1);
draw_text(10,100,string(ord(keyboard_lastchar)));
}

sprite0 = sprite containing your multiple font subimages.

Cheers,

Nodus
  • 0

#3 Alex

Alex

    3lite Member

  • New Member
  • 3098 posts

Posted 15 August 2007 - 05:47 AM

I think you need to string those letters.

So ord('A')
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users