codice:
#include "allegro.h"
BITMAP *buf, *sprite ;
PALETTE colori;
void doppiobuffering(){
class Video{
public:
Video(){
allegro_init();
install_keyboard();
};
~Video(){
destroy_bitmap(buf);
}
void Display(int Disp,int n,int m){
set_color_depth(32);
set_palette(colori);
set_gfx_mode(GFX_AUTODETECT, n, m, 0, 0);
buf = create_bitmap(n, m);
clear(buf);
}
void DB(int n,int m){
vsync();
blit(buf, screen, 0, 0, 0, 0, n, m);
clear(buf);
}
};
class Giocatore{
int x,y;
public:
Giocatore(){
sprite = load_bmp("player.bmp",colori);
x=10; y=30;
}
~Giocatore(){
destroy_bitmap(sprite);
}
void Muovi(){
if (key[KEY_LEFT])x-=2;if(x<=0)x=0;
if (key[KEY_RIGHT])x+=2;if(x>=266)x=266;
if (key[KEY_UP])y-=2;if(y<=0)y=0;
if (key[KEY_DOWN])y+=2;if(y>=138)y=138;
}
int putx(){
return x;
}
int puty(){
return y;
}
void vedi(){
draw_sprite(buf, sprite, putx(), puty());
}
};
}
int main()
{
Video Game;
Giocatore Nave;
set_color_depth(32);
set_palette(colori);
Game.Display(32,320,200);
while (!key[KEY_ESC]) {
Game.DB(320,200);
Nave.Vedi();
}
}
END_OF_MAIN ();
gli errori...
`Video' undeclared (first use this function)
(Each undeclared identifier is reported only once for each function it appears in.)
`Giocatore' undeclared (first use this function)
expected `;' before "Nave"
`Game' undeclared (first use this function)
`Nave' undeclared (first use this function)