Tu problema es que no sabes en que codigo estas. Iostream es una libreria de C++ y stdlib y stdio de C, por tu code parece que estas en C porque pones printf .... asi que crea un archivo y ponle el code en C que te he puesto y lo guardas como fichero.c y lo compilas.
Prueba este codigo si estas en C :
#include <stdio.h>
#include <stdlib.h>
#include <allegro.h>
int iniciar();
void realizar_juego();
void terminar();
int iniciar(){
allegro_init();
install_keyboard();
set_color_depth(16);
if (set_gfx_mode(GFX_AUTODETECT,640,480,0,0)<0){
printf("error al iniciar el modo grafico\n"); allegro_exit();
}
}
void terminar(){
allegro_exit();
}
int main(){
iniciar();
realizar_juego();
terminar();
}
END_OF_MAIN();
void realizar_juego(){
BITMAP *nave;
PALETTE paleta;
int x,y, x_anterior, y_anterior;
BITMAP * buffer;
nave=load_bitmap("C:/Users/DANIEL/Desktop/Programación/C++/Allegro/Naves/recursos/nave.pcx", paleta);
set_palette(paleta);
if (nave==NULL) terminar();
buffer=create_bitmap(nave->w,nave->h);
clear (buffer);
if (buffer==NULL) terminar();
x=SCREEN_W/2;
y=SCREEN_H/2;
while (!key[KEY_ESC]){
if (key[KEY_UP,KEY_W])
y--;
if (key[KEY_DOWN,KEY_S])
y++;
if (key[KEY_LEFT,KEY_A])
x--;
if (key[KEY_RIGHT,KEY_D])
x++;
if (x<0) x=x_anterior;
if (x>SCREEN_W-nave->w) x=x_anterior;
if (y<0) y=y_anterior;
if (y>SCREEN_H-nave->h) y=y_anterior;
if ((x_anterior!=x) || (y_anterior!=y)){
blit (buffer,screen, 0, 0, x_anterior, y_anterior,buffer->w,buffer->h);
blit (screen,buffer,x,y,0,0,buffer->w,buffer->h);
draw_sprite(screen,nave, x, y);
}
x_anterior=x;
y_anterior=y;
}
}
Y este otro si estas en C++
#include <cstdio.h>
#include <cstdlib.h>
#include <allegro.h>
#include <iostream>
using namespace std;
int iniciar();
void realizar_juego();
void terminar();
int iniciar(){
allegro_init();
install_keyboard();
set_color_depth(16);
if (set_gfx_mode(GFX_AUTODETECT,640,480,0,0)<0){
cout << "Error al iniciar el modo grafico" << endl;
allegro_exit();
exit(-1);
}
}
void terminar(){
allegro_exit();
}
int main(){
iniciar();
realizar_juego();
terminar();
}
END_OF_MAIN();
void realizar_juego(){
BITMAP *nave;
PALETTE paleta;
int x,y, x_anterior, y_anterior;
BITMAP * buffer;
nave=load_bitmap("C:/Users/DANIEL/Desktop/Programación/C++/Allegro/Naves/recursos/nave.pcx", paleta);
set_palette(paleta);
if (nave==NULL) terminar();
buffer=create_bitmap(nave->w,nave->h);
clear (buffer);
if (buffer==NULL) terminar();
x=SCREEN_W/2;
y=SCREEN_H/2;
while (!key[KEY_ESC]){
if (key[KEY_UP,KEY_W])
y--;
if (key[KEY_DOWN,KEY_S])
y++;
if (key[KEY_LEFT,KEY_A])
x--;
if (key[KEY_RIGHT,KEY_D])
x++;
if (x<0) x=x_anterior;
if (x>SCREEN_W-nave->w) x=x_anterior;
if (y<0) y=y_anterior;
if (y>SCREEN_H-nave->h) y=y_anterior;
if ((x_anterior!=x) || (y_anterior!=y)){
blit (buffer,screen, 0, 0, x_anterior, y_anterior,buffer->w,buffer->h);
blit (screen,buffer,x,y,0,0,buffer->w,buffer->h);
draw_sprite(screen,nave, x, y);
}
x_anterior=x;
y_anterior=y;
}
}