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 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
|
void get_user_input();
int main(){
init(); //all this does is initialize allegro and load the window and the
//board and the title bitmaps and draw them
base_game_entity Simon; //this is the class for the game, not used yet
bool key_pressed_flag = false; //this is my flag
masked_blit(board, screen, 0, 0, 200, 125, 400, 400);
masked_blit(title, screen, 0, 0, 280, 0, 240, 100);
destroy_bitmap(board);
while(!key[KEY_ESC]){
if(key_pressed_flag = false){
get_user_input();
key_pressed_flag = true;
}
if(key_pressed_flag = true){
if(!key[KEY_7_PAD] && !key[KEY_9_PAD] && !key[KEY_3_PAD] &&
!key[KEY_1_PAD]){
key_pressed_flag = false;
}
}
}
allegro_exit();
}
END_OF_MAIN()
void get_user_input(){
poll_keyboard();
if(key[KEY_7_PAD]){
green_selected = load_bitmap("green.bmp", NULL);
if(!green_selected){
allegro_message("ERROR LOADING GREEN");
}
masked_blit(green_selected, screen, 0, 0, 200, 125, 200, 200);
destroy_bitmap(green_selected);
}
else if(key[KEY_9_PAD]){
red_selected = load_bitmap("red.bmp", NULL);
if(!red_selected){
allegro_message("ERROR LOADING RED");
}
masked_blit(red_selected, screen, 0, 0, 400, 125, 200, 200);
destroy_bitmap(red_selected);
}
else if(key[KEY_3_PAD]){
blue_selected = load_bitmap("blue.bmp", NULL);
if(!blue_selected){
allegro_message("ERROR LOADING BLUE");
}
masked_blit(blue_selected, screen, 0, 0, 400, 325, 200, 200);
destroy_bitmap(blue_selected);
}
else if(key[KEY_1_PAD]){
yellow_selected = load_bitmap("yellow.bmp", NULL);
if(!yellow_selected){
allegro_message("ERROR LOADING YELLOW");
}
masked_blit(yellow_selected, screen, 0, 0, 200, 325, 200, 200);
destroy_bitmap(yellow_selected);
}
board = load_bitmap("board.bmp", NULL);
masked_blit(board, screen, 0, 0, 200, 125, 400, 400);
destroy_bitmap(board);
}
|