Allegro Red Line

closed account (jyU4izwU)
Hi, im working on a allegro game and i have a little problem with this code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <allegro.h>
BITMAP *item;

int x = 10;
int y = 10;

int main(){
 
    allegro_init();
    install_keyboard();
    set_gfx_mode( GFX_AUTODETECT, 640, 480, 0, 0);
    
    item = load_bitmap( "item.bmp", NULL);

    
    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_UP]) y--;        
        else if (key[KEY_DOWN]) y++;    
        else if (key[KEY_RIGHT]) x++;
        else if (key[KEY_LEFT]) x--;

        // textout_ex( screen, font, "X", x, y, makecol( 255, 0, 0), makecol( 0, 0, 0) ); // Player
        circle(screen, x, y, 10, makecol( 255, 0, 0));
        
        release_screen();
        
        rest(50); // Speed of the player
        
        // circle( screen, 13, 13, 10, makecol( 255, 0, 0));
        draw_sprite( screen, item, 400, 300);

    }    
    
    return 0;
    
}   
END_OF_MAIN();

It works perfectly but when i try to make the circle move it leves a line of its copy behind it. Any help?
~ Thanks.
Last edited on
You have to clear screen before every frame. I don't know allegro, but there has to be a function that will do that for you.
closed account (jyU4izwU)
Ye found out how its the....
 
textout_ex( screen, font, " ", x, y, makecol( 0, 0, 0), makecol( 0, 0, 0) );

that clears the screen so i made it bigger and i called the textout_ex a circlefill.
~ Thanks any ways :)
Topic archived. No new replies allowed.