This is a piece of code I copied from a tutorial of allegro.
When I changed the window width and height to 800, the program just crash, what happened?
set_gfx_mode( GFX_AUTODETECT_WINDOWED, 800, 800, 0, 0);
buffer = create_bitmap( 800, 800);
#include <allegro.h>
#include <cstdlib>
#include <time.h>
int x = 100;
int y = 100;
int tempX = 100;
int tempY = 100;
int dir = 1; //This will keep track of the circles direction
//1= up and left, 2 = down and left, 3 = up and right, 4 = down and right
BITMAP *buffer; //This will be our temporary bitmap for double buffering
void setupboard(){
tempX = x;
tempY = y;
if (dir == 1 && x != 20 && y != 20){
--x;
--y;
} else if (dir == 2 && x != 20 && y != 460){
--x;
++y;
} else if (dir == 3 && x != 620 && y != 20){
++x;
--y;
} else if (dir == 4 && x != 620 && y != 460){
++x;
++y;
} else {
dir = rand() % 4 + 1;
}
acquire_screen();
circlefill ( buffer, tempX, tempY, 20, makecol( 0, 0, 0));
circlefill ( buffer, x, y, 20, makecol( 128, 255, 0));
draw_sprite( screen, buffer, 0, 0);
release_screen();
rest(10);
}
int main(){
allegro_init();
install_keyboard();
set_color_depth(16);
set_gfx_mode( GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
buffer = create_bitmap( 640, 480);
while( !key[KEY_ESC]){
setupboard();
}
return 0;
}
END_OF_MAIN();