Tonight I started my first online Allegro tutorial, I haven't written my own source code yet, I'm not that far in. I've got a few functions down and what not, but I've come across a problem.
The program that I'm running, and I have copied from a website is having a problem. (I know, it's a cheap way to get stuff done, but I'm just assesing it to learn, and it's working.) What I'm trying to achieve is the ability to move text around a black screen. The text is red. once I'd copied it directly from the web page it worked well, all I've done is changed the speed / rest(x); of the moving character. The problem I'm having is the character turns bright green and leaves a brown trail behind itself as it moves across the screen.
I had the same problem when I first changed the movable test from "@" to "MOVE ME", when I'd move the text down it would leave a train of red behind, as I retraced my steps up the page it would reverse itself, basically eating the trail it left.
If anyone has any tips, or knows whats wrong that'd be appreciated.
Code for reference:
Code: Select all
#include <allegro.h>
int x = 10;
int y = 10;
int main(){
allegro_init();
install_keyboard();
set_gfx_mode( GFX_AUTODETECT, 640, 480, 0, 0);
while ( !key[KEY_ESC] ){
clear_keybuf();
acquire_screen();
textout_ex( screen, font, " ", x, y, makecol( 0, 0, 0), makecol( 0, 0, 0) );
if (key[KEY_W]) --y;
else if (key[KEY_S]) ++y;
else if (key[KEY_D]) ++x;
else if (key[KEY_A]) --x;
textout_ex( screen, font, "V", x, y, makecol( 255, 0, 0), makecol( 0, 0, 0) );
release_screen();
rest(25);
}
return 0;
}
END_OF_MAIN();