Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411430 Posts in 69363 Topics- by 58416 Members - Latest Member: JamesAGreen

April 19, 2024, 09:16:04 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Game Maker For Beginners: Part IV
Pages: 1 [2] 3 4 ... 6
Print
Author Topic: Game Maker For Beginners: Part IV  (Read 111005 times)
ஒழுக்கின்மை (Paul Eres)
Level 10
*****


Also known as रिंकू.


View Profile WWW
« Reply #20 on: October 01, 2009, 06:40:15 PM »

you can, but we're talking about bitmapped fonts rather than true-typed fonts -- there are several advantages of bitmapped fonts:

- you can add textures and shadows to them, rather than just a plain color
- ttf's actually cause gm to go significantly slower due to rendering time per frame

on the other hand, ttf's have these advantages:

- ttf's are simpler to use and set up
- ttf's can be easily resized for different uses (whereas you'd have to make a completely new bitmap font if you want several sizes of text)

my own games use ttf, but it's not really optimal: i actually use several fonts drawn over each other at once to simulate shadow and lighting, but it causes a lot of slowdown. here's a simple script for shadows:

Quote
// print_shine(x, y, string);

if (argument3 == 0)
   then aalpha = 1;
   else aalpha = argument3;

draw_set_blend_mode(bm_normal);
   draw_text_color(round(argument0) + 1*(obj_special_main.editor_zoom+1), round(argument1) + 2*(obj_special_main.editor_zoom+1),
      argument2, c_black, c_black, c_black, c_black, aalpha);
   draw_text_color(round(argument0) + 2*(obj_special_main.editor_zoom+1), round(argument1) + 1*(obj_special_main.editor_zoom+1),
      argument2, c_black, c_black, c_black, c_black, aalpha);

draw_set_blend_mode(bm_add);
   draw_text_color(round(argument0), round(argument1), argument2, c_white, c_white, c_black, c_black, aalpha);
   draw_text_color(round(argument0), round(argument1), argument2, c_black, c_black, c_gray, c_gray, aalpha);

draw_set_blend_mode(bm_normal);

the arguments are x, y, and the string. alpha is optional as the fourth argument.

that turns out ttf text that looks something like in this screenshot: http://pics.livejournal.com/rinku/pic/000z8dyh

which i like better than just using draw_text_color (which does a solid color with no shadows)
« Last Edit: October 01, 2009, 06:46:39 PM by Paul Eres » Logged

pgil
Guest
« Reply #21 on: October 01, 2009, 07:02:34 PM »

- ttf's actually cause gm to go significantly slower due to rendering time per frame

Are you sure about that? I thought that when you import a Truetype font, gamemaker converts each character to a bitmap..
Logged
ஒழுக்கின்மை (Paul Eres)
Level 10
*****


Also known as रिंकू.


View Profile WWW
« Reply #22 on: October 01, 2009, 07:12:12 PM »

pretty sure. try it yourself. a good comparison is to draw a paragraph of text every step, and then to draw a paragraph of text to a surface once, and then just display the surface every step. you'll notice a big difference.
Logged

moonmagic
Level 4
****



View Profile WWW
« Reply #23 on: October 01, 2009, 07:24:58 PM »

I was JUST saying to myself that I wanted to replace my truetype text with bitmap fonts, and now I have a good reference. Glad you continue to work on these.
Logged

|
Xion
Pixelhead
Level 10
******



View Profile WWW
« Reply #24 on: October 01, 2009, 07:25:22 PM »

pretty sure. try it yourself. a good comparison is to draw a paragraph of text every step, and then to draw a paragraph of text to a surface once, and then just display the surface every step. you'll notice a big difference.

yeah but that's not comparing ttf to bitmap it's comparing ttf to surfaces, right?
Logged

ஒழுக்கின்மை (Paul Eres)
Level 10
*****


Also known as रिंकू.


View Profile WWW
« Reply #25 on: October 01, 2009, 07:30:17 PM »

true, but they work similarly; surfaces and bitmapped fonts are just images, whereas ttf is a set of instructions for generating an image. so i'd expect that the performance would be similar between bitmapped fonts and surfaces (since either way you're just drawing an image). if the actual overhead is from conversion of the string into a sequence of characters, then maybe bitmapped fonts would be slower than surfaces though -- it'd be good to test that too. but from what i have gathered in the gmc forums, one of the reasons often cited for using bitmapped fonts is a speed increase. could always be wrong though, best to test it.
Logged

Soulliard
Level 10
*****


The artist formerly known as Nightshade


View Profile WWW
« Reply #26 on: October 02, 2009, 11:39:00 AM »

hmm -- just a guess, but you could try creating a *really light* line that is almost the background color but not quite, so that it's virtually invisible, but still detected as a character
Problem is, that doesn't work when you have colorful moving backgrounds. What I've been doing is this:
Since there is no space between the letters of the font, I put two dots along the edges of the space. It overlaps the edges of the other letters, so it's not normally visible. The problem arises with letters like T and L, which don't have solid edges along both sides of the letter.

Yes, there is a simple trick although you might consider it sloppy. You need two sprites of your font, one for color, one for alpha. The important difference is that the color sprite has a visible block for the space, and the alpha sprite has an empty frame for the space. Define the font with the color sprite. Then apply the other sprite as an alpha channel to the first.
Yes, this would work, although it's kind of ridiculous to have to go through all that. Thank you.  Gentleman
Logged

Entity
Level 0
**


View Profile
« Reply #27 on: October 02, 2009, 02:38:53 PM »

I didn't know that GM supported bitmap fonts! This'll prove quite useful in my game. Smiley
Logged
ChevyRay
Guest
« Reply #28 on: October 02, 2009, 02:46:54 PM »

hmm -- just a guess, but you could try creating a *really light* line that is almost the background color but not quite, so that it's virtually invisible, but still detected as a character
Problem is, that doesn't work when you have colorful moving backgrounds.

What? Make it like 99% invisible. You can't even see it anyways, if the alpha channel is so insignificantly small.
Logged
MaloEspada
Guest
« Reply #29 on: October 02, 2009, 03:29:30 PM »

Quick question, how do you make game maker display other symbols, after the first 127?
I don't understand much about hexes and so on, but let's say, considering Derek's table:

After the "~" symbol, I make another sprite, an arrow for example. How do I display it in form of text? If I type a "~", it will display a "~". If I type ??, it will display the arrow sprite.

I hope I made it understandable..
Logged
xot
Level 0
**



View Profile WWW
« Reply #30 on: October 02, 2009, 04:09:12 PM »

- ttf's actually cause gm to go significantly slower due to rendering time per frame

Are you sure about that? I thought that when you import a Truetype font, gamemaker converts each character to a bitmap..

GM generates textures based on your font resources when the executable is created. The exception is the default font which is made into a texture when the executable is run. You can confirm this by altering your font antialiasing/cleartype settings when you create an executable and observing the results when run under different settings. The fonts will always match whatever your settings were when the executable was created (the exception is the default font, see above).

Further more, you can actually see one of these font textures by drawing a primitive with texture id 0 (at least if you haven't defined any other textures). That alone is not proof but it is a very strong indication that GM treats TTF fonts exactly like bitmap fonts. Another indication is that when you draw a font at a different scale, it is obviously a bitmap being scaled rather than a perfectly smooth vector font being drawn at a larger size. Also, notice how much memory your game uses up with a lot of large fonts, far more than the fonts actually require. I've got a 44KB TTF font that requires ~22MB memory when set to a point size of 99. Consider why GM would even ask for a point size or character ranges if not to prerender the font.

There are also legal reasons for not wanting to include a TTF font in the executable. Most fonts require a special license for redistribution. Expecting the user to have/find/install your uber font is out of the question. Prerendering is the only reasonable option.
Logged

ChevyRay
Guest
« Reply #31 on: October 02, 2009, 04:50:49 PM »

Holy moley this guy knows his stuff.

GM users, now that you've gotten the hang of using scripts Wink should check out the GMLscripts site in xot's signature. It's got lots of handy stuff.
Logged
soundofsatellites
Level 2
**


no way baby, let's go!


View Profile
« Reply #32 on: October 02, 2009, 06:49:22 PM »

GM users, now that you've gotten the hang of using scripts Wink should check out the GMLscripts site in xot's signature. It's got lots of handy stuff.

yes indeed he has... I barely browsed a few, but I can already see me looking in there when there's something I can't crack! great work xot!
Beer!
Logged

and the glitter is gone
ஒழுக்கின்மை (Paul Eres)
Level 10
*****


Also known as रिंकू.


View Profile WWW
« Reply #33 on: October 02, 2009, 07:10:57 PM »

Quick question, how do you make game maker display other symbols, after the first 127?
I don't understand much about hexes and so on, but let's say, considering Derek's table:

After the "~" symbol, I make another sprite, an arrow for example. How do I display it in form of text? If I type a "~", it will display a "~". If I type ??, it will display the arrow sprite.

I hope I made it understandable..

go to the font properties -- it has options for that. you can go from 0 to 255.

@xot - good to know, still, i wonder why displaying fonts is so slow if it's just displaying bitmaps? i can't imagine why i'd slow it down as much as it does, unless it's just bad implementation.

also, seems bitmapped fonts are the better choice if you want shadows (since using another black font behind it works but doubles the time it takes to draw the text).
Logged

PKBT
Level 1
*

cool


View Profile WWW
« Reply #34 on: October 02, 2009, 07:27:19 PM »

Awesome. This makes life so much simpler now.
Guess I'll scoop up something over the weekend. Fun times.
Logged
MaloEspada
Guest
« Reply #35 on: October 03, 2009, 08:56:33 AM »

Quick question, how do you make game maker display other symbols, after the first 127?
I don't understand much about hexes and so on, but let's say, considering Derek's table:

After the "~" symbol, I make another sprite, an arrow for example. How do I display it in form of text? If I type a "~", it will display a "~". If I type ??, it will display the arrow sprite.

I hope I made it understandable..

go to the font properties -- it has options for that. you can go from 0 to 255.


Yeah, but... How can I change it according to Derek's tutorial? Also, for displaying purposes, do I use alt+number to display custom/extra characters?
Logged
ஒழுக்கின்மை (Paul Eres)
Level 10
*****


Also known as रिंकू.


View Profile WWW
« Reply #36 on: October 03, 2009, 08:57:59 AM »

you can do char(number) -- for instance, char(143) would display character 143. you can also just copy and paste letters, for instance, Å would work instead of char(143). i'm still not sure what you're asking, though.
Logged

MaloEspada
Guest
« Reply #37 on: October 03, 2009, 09:09:50 AM »

Yeah, I tried that.
typing char(number) or chr(number) will only display "char(number)" on the screen, while copying and pasting letters will display a blank space.
Logged
ஒழுக்கின்மை (Paul Eres)
Level 10
*****


Also known as रिंकू.


View Profile WWW
« Reply #38 on: October 03, 2009, 09:10:32 AM »

in that case you didn't set the font to 0 to 255 (or more sensibly, 32 to 255), or didn't change to the correct font.
Logged

MaloEspada
Guest
« Reply #39 on: October 03, 2009, 09:14:46 AM »

I set the font using this:

Quote
global.myFont = font_add_sprite(sFont, ord(' '), false, 0);

This code only has a parameter that defines the start of the font, not the end.
Also I looked through GM's document files and didnt find the code to change the font to "0 to 255".

Sorry for the confusion.  Facepalm
Logged
Pages: 1 [2] 3 4 ... 6
Print
Jump to:  

Theme orange-lt created by panic