C/Visual C - ayuda con devc++ y allegro

 
Vista:

ayuda con devc++ y allegro

Publicado por esteban (1 intervención) el 08/12/2012 23:11:55
hola soy nuevo con dvc++ y allegro intento hacer un juego pro no logro animar los sprites
agradeceria que alguien me dijece como ce hace logro que se muevan por pantalla pero estaticos sin animacion aca dejo el codigo de lo que e echo

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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#include <allegro.h>
 
 
BITMAP *buffer;
 
BITMAP *pacbmp;
BITMAP *pacman;
 
 
int px, py, dir;
 
 
int initialize();
void update_screen();
 
void dibujar_personaje();
 
 
 
int main()
{
    initialize();
 
 
    buffer = create_bitmap(SCREEN_W, SCREEN_H);
 
    pacbmp = load_bitmap("kio3.bmp", NULL);
    pacman = create_bitmap(76, 300);
    clear(pacman);
 
    px = 24;
    py = 52;
dir = 4;
 
    srand(time(NULL));
 
 
    while (!key[KEY_ESC]) {
        if (px % 2 == 0 && py % 2 == 0) {
 
               if (!key[NULL])
             {
                dir = 8;
            }
 
            if (key[KEY_LEFT])
             {
                dir = 0;
            }
            else if (key[KEY_RIGHT]) {
                dir = 4;
            }
            if (key[KEY_UP])
             if (key[ KEY_RIGHT]) {
                dir = 6;
            }
 
           else if (key[KEY_UP])
             if (key[ KEY_LEFT]) {
                dir = 6;
            }
 
            else if (key[KEY_UP]) {
                dir = 6;
            }
 
            if (key[KEY_DOWN]) {
                dir = 2;
            }
 
 
        }
 
 
          clear(buffer);
 
 
         dibujar_personaje();
 
 
        update_screen();
 
        rest(1);
    }
 
    return 0;
}
END_OF_MAIN()
 
Inicializar todo */
int initialize()
{
 
    allegro_init();
    install_keyboard();
    install_mouse();
    install_timer();
 
 
    set_color_depth(32);
    if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0) < 0) {
 
        allegro_message("Failed to initialize GFX");
        exit(-1);
    }
 
    return 0;
}
 
 
void update_screen()
{
    blit(buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
}
 
 
void dibujar_personaje()
{
    blit(pacbmp, pacman, dir*37.9, 0, 0, 0, pacman->w, pacman->h);
    draw_sprite(buffer, pacman, px, py);
 
}
 
int obtx(int _x, int _bs)
{
    return _x / _bs;
}
 
int obty(int _y, int _bs)
{
    return _y / _bs;
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder