1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
/*
Name: Widget360
Copyright: 2011
Author: Widget360
Date: 07/04/11 14:09
Description: My First Game
*/
#include <allegro.h>
// main
int main(int argc, char *argv[])
{
allegro_init();
install_keyboard();
set_color_depth(16);
set_gfx_mode(GFX_AUTODETECT, 1280,800,0,0);
// background
BITMAP *Intro_Background = load_bitmap("C:/Users/Widget360/Documents/projects/My First Game/Images/Intro_Background.bmp", NULL);
// sprite
BITMAP *Intro_Sprite = load_bitmap("C:/Users/Widget360/Documents/projects/My First Game/Images/Intro_Sprite.bmp", NULL);
// buffer
BITMAP *Intro_Buffer = create_bitmap(1280,800);
// check
int Intro_Check = 1;
int Intro_Check_Main = 1;
int Intro_Start_Top = 400;
int Intro_Start_Bottom = 300;
int Intro_Start_Right = 1000;
int Intro_Start_Left = 750;
int Intro_Quit_Top = 600;
int Intro_Quit_Bottom = 500;
int Intro_Quit_Left = 750;
int Intro_Quit_Right = 1000;
int Intro_Sprite_X = 0;
int Intro_Sprite_Y = 0;
// main intro loop
while (Intro_Check != 0)
{
while (Intro_Check_Main != 0)
{
if(key[KEY_RIGHT])
{
Intro_Sprite_X ++;
}
if (key[KEY_LEFT])
{
Intro_Sprite_X --;
}
if (key[KEY_UP])
{
Intro_Sprite_Y --;
}
if (key[KEY_DOWN])
{
Intro_Sprite_Y ++;
}
// show buffer
blit(Intro_Background, Intro_Buffer, 0, 0, 0, 0, 1280, 800);
draw_sprite(Intro_Buffer, Intro_Sprite, Intro_Sprite_X, Intro_Sprite_Y);
blit(Intro_Buffer,screen,0,0,0,0, 1280, 800);
// start - boundries
if (Intro_Sprite_X >= Intro_Start_Left && Intro_Sprite_X <= Intro_Start_Right)
{
if (Intro_Sprite_Y >= Intro_Start_Bottom && Intro_Sprite_Y <= Intro_Start_Top)
{
Intro_Check = 0;
Intro_Check_Main = 0;
}
}
// quit - boundries
if (Intro_Sprite_X >= Intro_Quit_Left && Intro_Sprite_X <= Intro_Quit_Right)
{
if (Intro_Sprite_Y >= Intro_Quit_Bottom && Intro_Sprite_Y <= Intro_Quit_Top)
{
allegro_message("Game Quit");
exit(EXIT_FAILURE);
}
}
}
}
// clean up
destroy_bitmap(Intro_Background);
destroy_bitmap(Intro_Buffer);
destroy_bitmap(Intro_Sprite);
}
END_OF_MAIN()
|