Site hosted by Angelfire.com: Build your free website today!

 

 

 

 

 

 

 

 

Basic Drawing to Screen

DOWNLOAD CPP FILE

#include <allegro.h>

#define x 320 //defining the x coord for where the character bmp is going to be drawn

#define y 240 //same as above except for the y coord

void setup();

void shutdown();

BITMAP *character;

BITMAP *buffer;

int main()

{

setup();

draw_sprite(buffer, character, x, y); //drawing the character bmp to the buffer

blit(buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H); //blitting the buffer to the screen so you can see everything

while(!key[KEY_ESC]); //while Esc key isn't pressed

;

shutdown();

return 0;

}

END_OF_MAIN();

void setup()

{

allegro_init(); //initializes allegro

install_keyboard(); //installs the keyboard routines

set_color_depth(32); //this is setting the color depth to a true color mode

set_gfx_mode(GFX_AUTODETECT_FULLSCREEN, 640, 480, 0, 0); //setting the screen to 640, 480 resolution in fullscreen

buffer = create_bitmap(SCREEN_W, SCREEN_H); //creating the buffer as the same size as the screen

character = load_bitmap("name_of_bitmap.bmp", NULL); //loading the character bitmap

}

void shutdown()

{

clear_keybuf();

destroy_bitmap(buffer);

destroy_bitmap(character);

}