Ok hey, I have this program and i dont understand how Its not wiorking.
Thx for your time. :o
#include <allegro.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void main()
{
int x,y,bx,by,af,al,ar,ab;
allegro_init();
install_keyboard();
install_timer();
set_color_depth(16);
set_gfx_mode(GFX_AUTODETECT,800,600,0,0);
BITMAP *buffer, *back, *a, *b, *c, *d, *e, *f, *g, *h;
back=load_bitmap("back.bmp",0);
a=load_bitmap("gob-front-1.bmp",0);
b=load_bitmap("gob-front-2.bmp",0);
c=load_bitmap("gob-back-1.bmp",0);
d=load_bitmap("gob-back-2.bmp",0);
e=load_bitmap("gob-left-1.bmp",0);
f=load_bitmap("gob-left-2.bmp",0);
g=load_bitmap("gob-right-1.bmp",0);
h=load_bitmap("gob-right-2.bmp",0);
x=300;
y=250;
bx=0;
by=0;
af=1;
al=1;
ar=1;
ab=1;
buffer=create_bitmap(800,600);
while(!key[KEY_ESC])
{
sit();
}
}
END_OF_MAIN()
void sit();
{
if(af == 1)
{
blit(buffer,screen, 0, 0, 0, 0, 800,600);
draw_sprite(buffer,back,bx,by);
draw_sprite(buffer,a,x,y);
delay (100);
af=0; }
if(af == 0)
{
blit(buffer,screen, 0, 0, 0, 0, 800,600);
draw_sprite(buffer,back,bx,by);
draw_sprite(buffer,b,x,y);
delay (100);
af=1;
}
}
}
int left();
{
while(key[KEY_LEFT])
{
if(al == 1)
{
blit(buffer,screen, 0, 0, 0, 0, 800,600);
draw_sprite(buffer,back,bx,by);
draw_sprite(buffer,e,x,y);
bx = bx + 1;
delay (100);
al=0; }
if(al == 0)
{
blit(buffer,screen, 0, 0, 0, 0, 800,600);
draw_sprite(buffer,back,bx,by);
draw_sprite(buffer,f,x,y);
bx = bx + 1;
delay (100);
al=1;
}
}
}
int right();
{
while(key[KEY_RIGHT])
{
if(ar == 1)
{
blit(buffer,screen, 0, 0, 0, 0, 800,600);
draw_sprite(buffer,back,bx,by);
draw_sprite(buffer,g,x,y);
bx = bx - 1;
delay (100);
ar=0; }
if(ar == 0)
{
blit(buffer,screen, 0, 0, 0, 0, 800,600);
draw_sprite(buffer,back,bx,by);
draw_sprite(buffer,h,x,y);
bx = bx - 1;
delay (100);
ar=1;
}
}
}
int back();
{
while(key[KEY_UP])
{
if(ab == 1)
{
blit(buffer,screen, 0, 0, 0, 0, 800,600);
draw_sprite(buffer,back,bx,by);
draw_sprite(buffer,c,x,y);
bx = by + 1;
delay (100);
ab=0; }
if(ab == 0)
{
blit(buffer,screen, 0, 0, 0, 0, 800,600);
draw_sprite(buffer,back,bx,by);
draw_sprite(buffer,d,x,y);
bx = by + 1;
delay (100);
ab=1;
}
}
}
int front();
{
while(key[KEY_DOWN])
{
if(af == 1)
{
blit(buffer,screen, 0, 0, 0, 0, 800,600);
draw_sprite(buffer,back,bx,by);
draw_sprite(buffer,a,x,y);
bx = by - 1;
delay (100);
ab=0; }
if(af == 0)
{
blit(buffer,screen, 0, 0, 0, 0, 800,600);
draw_sprite(buffer,back,bx,by);
draw_sprite(buffer,b,x,y);
bx = by - 1;
delay (100);
ab=1;
}
}
}
void delay(clock_t wt)
{
clock_t t1, t2;
t1 = clock();
t2 = clock();
while (t2 - t1 <= wt)
{
t2 = clock();
}
}