View Full Version: Animated Text

C++ Game Dev > C++ Game Creations > Animated Text


Title: Animated Text
Description: Whoo-hoo! Allegro!


gamehawk - December 24, 2005 05:19 PM (GMT)
CODE

#include <allegro.h>

void init();
void deinit();

int main() {
init();
set_color_depth(8);
if (set_gfx_mode(GFX_AUTODETECT,640,480,0,0)!=0)
{
return 0;
}
int l=2;
for (int newy=4;newy!=500;newy+=l)
{
textout_ex(screen,font,"Animated Text!",1,newy-l,0,-1);
textout_ex(screen,font,"Animated Text!",1,newy,4,-1);
rest(10);
if (newy==400)
{
l=-2;
}
if (newy==4)
{
l=2;
}
if (key[KEY_ESC])
{
return 0;
}
}
while (!key[KEY_ESC]) {
 /* put your code here */
}

deinit();
return 0;

}
END_OF_MAIN()

void init() {
int depth, res;
allegro_init();
depth = desktop_color_depth();
if (depth == 0) depth = 32;
set_color_depth(depth);
res = set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
if (res != 0) {
 allegro_message(allegro_error);
 exit(-1);
}

install_timer();
install_keyboard();
install_mouse();
/* add other initializations here */
}

void deinit() {
clear_keybuf();
/* add other deinitializations here */
}

Animated Text, needs allegro installed. If you have Dev-C++ Click Here for it, remember to scan for viruses! I might add an EXE later if I am not too lazy :lol: !

LauriP - December 26, 2005 07:01 PM (GMT)
I cant get this right, i downloaded the pack from the site,
installed it, but when i compile this code it sayes some errors...

gamehawk - December 26, 2005 07:47 PM (GMT)
Click Create a New Project, not a new source code file. A project name it or whatever. Then paste this into the main.cpp and compile.

gml_josea - December 27, 2005 02:12 AM (GMT)
it still gives me some errors

gamehawk - December 27, 2005 02:14 AM (GMT)
File, New Project, Multimedia, Allegro Static. Then open up main.cpp and paste in my code. Compile it, saving it as main.cpp and then run. It should work.

LauriP - December 27, 2005 09:44 AM (GMT)
Oh, now i got it to work !
Its a fine little example ;)

gamehawk - December 27, 2005 02:18 PM (GMT)
Glad somebody could get it working!

Captn'Red - January 26, 2006 08:21 AM (GMT)
Very nice! i had trouble-installing, but i got that working then
-compiling it had one error couldnt figure it out so
-i try again and it worked! animated text going up and down.
So yeah, if u had trouble running it go out of Dev-C++ and go back into it
(it helped me!)

Captn'Red :)

gamehawk - January 26, 2006 09:54 PM (GMT)
Cool! Glad you liked!

BGamed - February 3, 2006 03:56 PM (GMT)
won't use allegro... but nice anyway..




* Hosted for free by InvisionFree