This repository has been archived by the owner on Mar 24, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_intro.cpp
100 lines (82 loc) · 2.71 KB
/
main_intro.cpp
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
#include <allegro5/allegro.h>
#include <allegro5/allegro_native_dialog.h>
#include<allegro5/allegro_ttf.h>
#include<allegro5/allegro_font.h>
#include<allegro5/allegro_primitives.h>
#include <iostream>
#include "introScreen.h"
using namespace std;
#define ScreenWidth 800
#define ScreenHeight 600
int main(void)
{
ALLEGRO_DISPLAY *display;
bool introDone = false;
bool gameOn = true;
bool howScreenOn = false;
bool playGame = false;
if(!al_init()) //If allegro window does not initialize, error
{
al_show_native_message_box(NULL, NULL, NULL, "Could not initialize Allegro 5", NULL, NULL);
return -1; //Program ended with an error
}
al_set_new_display_flags(ALLEGRO_WINDOWED | ALLEGRO_RESIZABLE);
display = al_create_display(ScreenWidth,ScreenHeight); //initializes display
al_set_window_title(display, "Call of Booty - Argh!"); //Sets the name of the game window
if(!display)
{
al_show_native_message_box(display, "Call of Booty", "Display Settings", "Display window cannot be created", NULL, ALLEGRO_MESSAGEBOX_ERROR);
return -1;
}
al_init_font_addon();
al_init_ttf_addon();
al_init_primitives_addon();
al_install_mouse();
al_install_keyboard();
IntroScreen introScreen;
HowToPlay howScreen;
while (gameOn){
while(!introDone){ // introscreen is active
if(introScreen.getExists()){
introScreen.makeIntroScreen(ScreenWidth, ScreenHeight);
if (introScreen.getDone())//introscreen has been told to close(play or exit)
introDone = true; //stops dealing with introScreen
if (introScreen.getPlayGo()){
introDone = true;
playGame = true;
gameOn = false;
}
if(introScreen.getExit())//exit has been clicked
gameOn = false;
if (introScreen.getHowGo()){//HowToPlay has been clicked
introDone = true;
howScreenOn = true;
}
}
if (gameOn == false){ //if exit has been clicked, end the program
break;
}
}
while(howScreenOn){ //loop for howScreen
while(introScreen.getHowGo()){
if (howScreen.getActive()){
howScreen.makeHowToPlayScreen();
if(howScreen.getHowDone()){
introScreen.setHowGo(false);
introDone = false;
howScreenOn = false;
}
}
}
}
//al_draw_filled_rectangle(0, 0,800,600,al_map_rgb(0,0,255)); //TEMPORARY filler for launch game~for now consider BlueScreen as the game
//al_flip_display();
//al_show_native_message_box(display, "MessageBox Title", "Error", "Display window could not be shown", NULL, ALLEGRO_MESSAGEBOX_ERROR);
}
while (playGame){
al_draw_filled_rectangle(0, 0,800,600,al_map_rgb(0,0,255)); //TEMPORARY filler for launch game~for now consider BlueScreen as the game
al_flip_display();
}
al_destroy_display(display);//Destructor
return 0;
}