Allegro fonts
So I have never messed with allegro and fonts. This is very new to me. I wrote a program to surprise my girlfriend with that displays a background image and a poem for her and so far the program works. but i cant stand the font. Anyone able to help me with how to use / find fonts. Ive tried google but for some reason i just cant grasp alot of the terminology with fonts. Anyhelp would be appreciated. Even code blocks.
This isnt an assignment like i said its for my GF. Thanks in advance =)
EDIT
Its been a while since ive coded so my program isnt what i was hoping
I was hoping to have it show the background..
have her hit enter and it will display 4 lines of the text
hit enter
clear the screen and display 4 lines.
and so on until it was done. for some reason this wasnt working so i got it all to display on 1 page for her to read.
Sorry to be a nag but also i want to maybe play some music in the background is there a way i could convert a file from like mp3 to wav or some format allegro supports?
For Allegro fronts start here: http://www.allegro.cc/manual/api/fonts/
More specifically here: http://www.allegro.cc/manual/api/fonts/load_font
So for example:
In textout_ex() you could substitute buffer with screen. It depends on if your using double buffering or not.
For creating your own fonts you could download this free program: http://www.allegro.cc/depot/AllegroFontEditor/
It also comes with a few examples to choose from.
As for your "hit enter, display 4 lines, hit enter, clear text, display 4 more lines" setup. There are a few ways you could do it. Depending on how long the poem is, you could set up a loop counter and a switch statement that depending on the value of the loop counter displays a certain portion of the poem. Each time the user (your girlfriend) hits "enter" the loop counter is incremented by one. If the poem is long I wouldn't recommend using the switch statement.
If the poem is long I would store it in an array. Each line of the poem uses one element of the array. Use the loop counter setup described above, but instead of incrementing the counter by one each time, increment the counter by 4.
Example:
As for sound in your program, I'm unsure about that. I haven't done much work in allegro with sound. I would recommend searching and asking on the allegro.cc forums.
Hope this helps.
Cheers,
Ken
More specifically here: http://www.allegro.cc/manual/api/fonts/load_font
So for example:
FONT* myFont = load_font("my_font.pcx", NULL, NULL);//Print a line of the poem with your chosen fonttextout_ex(buffer, myFont, "Line of Poem", 75, 75, makecol(255, 255, 255), -1);
In textout_ex() you could substitute buffer with screen. It depends on if your using double buffering or not.
For creating your own fonts you could download this free program: http://www.allegro.cc/depot/AllegroFontEditor/
It also comes with a few examples to choose from.
As for your "hit enter, display 4 lines, hit enter, clear text, display 4 more lines" setup. There are a few ways you could do it. Depending on how long the poem is, you could set up a loop counter and a switch statement that depending on the value of the loop counter displays a certain portion of the poem. Each time the user (your girlfriend) hits "enter" the loop counter is incremented by one. If the poem is long I wouldn't recommend using the switch statement.
If the poem is long I would store it in an array. Each line of the poem uses one element of the array. Use the loop counter setup described above, but instead of incrementing the counter by one each time, increment the counter by 4.
Example:
string myPoem[8];myPoem[0] = "Line 1"; myPoem[1] = "Line 2"; myPoem[2] = "Line 3"; myPoem[3] = "Line 4"; myPoem[4] = "Line 5"; myPoem[5] = "Line 6"; myPoem[6] = "Line 7"; myPoem[7] = "Line 8"; int counter = 0;while(counter < 8){ for(int i = counter; counter < (counter + 4); ) { textout_ex(buffer, myFont, myPoem, 75, 75, makecol(255, 255, 255), -1); } //Check if the enter key was hit. //If so increment counter by 4}
As for sound in your program, I'm unsure about that. I haven't done much work in allegro with sound. I would recommend searching and asking on the allegro.cc forums.
Hope this helps.
Cheers,
Ken
As seen in Koolchamps example, you load fonts through pcx-bitmaps - You can use this stuff to convert from ttf to pcx.
ty for the info really informative =)
I do have some other questions i hope can answer...
Lets say i want to make a bigger font .. i noticed alot of stuff is like 8x8 and when i have her read it .. its super small. Is there a way to maybe scale the fonts or simply load a font created with larger parameters?
I do have some other questions i hope can answer...
Lets say i want to make a bigger font .. i noticed alot of stuff is like 8x8 and when i have her read it .. its super small. Is there a way to maybe scale the fonts or simply load a font created with larger parameters?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement