-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPokemon.txt
More file actions
221 lines (188 loc) · 7.17 KB
/
Pokemon.txt
File metadata and controls
221 lines (188 loc) · 7.17 KB
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
/*****************************************************************************
* Name: Mr. Creelman *
* Date: August 2017 *
* *
* Purpose: Example 2 - Display an image on the screen *
* *
* Usage: displaysa single bitmap, then waits for a few seconds. *
* *
* Revision History: *
* *
* Known Issues: *
* *
*****************************************************************************/
// You must include the allegro header files
#include <allegro5/allegro.h>
#include <allegro5/allegro_image.h>
#include <allegro5/allegro_native_dialog.h>
#include <allegro5/allegro_font.h>
#include <allegro5/allegro_ttf.h>
#include <stdio.h>
#include <string.h>
const int SCREEN_W = 960; // screen width
const int SCREEN_H = 560; // screen height
#define RED al_map_rgb(230, 25, 75)
#define GREEN al_map_rgb(60, 180, 75)
#define YELLOW al_map_rgb(255, 225, 25)
#define BLUE al_map_rgb(0, 130, 200)
#define ORANGE al_map_rgb(245, 130, 48)
#define PURPLE al_map_rgb(145, 30, 180)
#define CYAN al_map_rgb(70, 240, 240)
#define MAGENTA al_map_rgb(240, 50, 230)
#define LIME al_map_rgb(210, 245, 60)
#define PINK al_map_rgb(250, 190, 190)
#define TEAL al_map_rgb(0, 128, 128)
#define LAVENDER al_map_rgb(230, 190, 255)
#define BROWN al_map_rgb(170, 110, 40)
#define BEIGE al_map_rgb(255, 250, 200)
#define MAROON al_map_rgb(128, 0, 0)
#define MINT al_map_rgb(170, 255, 195)
#define OLIVE al_map_rgb(128, 128, 0)
#define CORAL al_map_rgb(255, 215, 180)
#define NAVY al_map_rgb(0, 0, 128)
#define GREY al_map_rgb(128, 128, 128)
#define WHITE al_map_rgb(255, 255, 255)
#define BLACK al_map_rgb(0, 0, 0)
int initializeAllegro(ALLEGRO_DISPLAY *display, ALLEGRO_EVENT_QUEUE *event_queue, ALLEGRO_BITMAP *image, ALLEGRO_FONT *font);
int main(int argc, char *argv[]) {
ALLEGRO_DISPLAY *display = nullptr;
// add event queue object
ALLEGRO_EVENT_QUEUE *event_queue = nullptr;
// Declare a BITMAP called image, setting it's initial value to nullptr
ALLEGRO_BITMAP *image = nullptr;
ALLEGRO_FONT *font = nullptr;
// Initialize Allegro
al_init();
// Initialize display
display = al_create_display(SCREEN_W, SCREEN_H);
//Initialize Event
event_queue = al_create_event_queue();
// Initialize image
image = al_load_bitmap("PickingScene.jpg");
// load the specific font you want
font = al_load_ttf_font("Pokemon GB.ttf", 18, 0);
initializeAllegro(display, event_queue, image, font);
// Display picture started at top left corner
al_draw_bitmap(image, 0, 0, 0);
// write display to screen
al_flip_display();
// Wait 5 seconds
al_rest(1);
char player1Name[10];
char player2Name[10];
char player1Input[100] = "adfsd";
char player2Input[100] = "asdfsd";
bool player1Gender;
bool player2Gender;
int junk = 1;
bool game = true;
printf("Player1, what is your name? ");
al_draw_text(font, BLACK, 80, 510, ALLEGRO_ALIGN_LEFT, "Player1, what is your name?");
al_flip_display();
al_register_event_source(event_queue, al_get_display_event_source(display));
al_register_event_source(event_queue, al_get_keyboard_event_source());
while(game == true){
ALLEGRO_EVENT ev;
al_wait_for_event(event_queue, &ev);
printf("test");
if (ev.type == ALLEGRO_EVENT_KEY_DOWN) {
switch(ev.keyboard.keycode){
case ALLEGRO_KEY_DOWN:
game = false;
al_draw_bitmap(image, 0, 0, 0);
al_flip_display();
al_rest(1);
break;
}
}
}
//fflush(stdin);
scanf("%s", &player1Name);
/* if (ev.type==ALLEGRO_EVENT_KEY_UP){
if (ev.keyboard.keycode==ALLEGRO_KEY_SPACE){
edittext[caret] = 32;
caret++;
}
else
if (ev.keyboard.keycode==ALLEGRO_KEY_BACKSPACE){
if (caret > 0) caret--;
edittext[caret] = '\0';
}
else
if (ev.keyboard.keycode==ALLEGRO_KEY_ENTER){
exit=1;
}
else{
sprintf (letter,"%c",ev.keyboard.keycode+64);
strcat (edittext,letter);
caret++;
}
}*/
printf(" what is your gender?(boy/girl) ");
while(junk != 0){
fflush(stdin);
scanf("%s", &player1Input);
if (strcmp(player1Input, "boy") == 0){
player1Gender = true;
junk = 0;
}
if (strcmp(player1Input, "girl") == 0){
player1Gender = false;
junk = 0;
};
}
junk = 1;
printf("Player2, what is your name? ");
fflush(stdin);
scanf("%s", &player2Name);
printf(" what is your gender?(boy/girl) ");
while(junk != 0){
fflush(stdin);
scanf("%s", &player2Input);
if (strcmp(player2Input, "boy") == 0){
player2Gender = true;
junk = 0;
}
if (strcmp(player2Input, "girl") == 0){
player2Gender = false;
junk = 0;
};
}
// Free memory and return with successful return code..
al_destroy_display(display);
al_destroy_bitmap(image);
return 0;
}
int initializeAllegro(ALLEGRO_DISPLAY *display, ALLEGRO_EVENT_QUEUE *event_queue, ALLEGRO_BITMAP *image, ALLEGRO_FONT *font){
if (!display) {
al_show_native_message_box(display, "Error", "Error", "Failed to initialize display!", nullptr, ALLEGRO_MESSAGEBOX_ERROR);
return -1;
}
al_set_window_title(display, "Pokemon Game");
// Initialize image add on
if (!al_init_image_addon()) {
al_show_native_message_box(display, "Error", "Error", "Failed to initialize image addon!", nullptr, ALLEGRO_MESSAGEBOX_ERROR);
return -1;
}
// Initialize keyboard routines
if (!al_install_keyboard()) {
al_show_native_message_box(display, "Error", "Error", "failed to initialize the keyboard!", nullptr, ALLEGRO_MESSAGEBOX_ERROR);
return -1;
}
if (!event_queue) {
al_show_native_message_box(display, "Error", "Error", "Failed to create event_queue!", nullptr, ALLEGRO_MESSAGEBOX_ERROR);
al_destroy_display(display);
return -1;
}
if (!image) {
al_show_native_message_box(display, "Error", "Error", "Failed to load image!", nullptr, ALLEGRO_MESSAGEBOX_ERROR);
al_destroy_display(display);
return -1;
}
al_init_font_addon(); // initialize the font addon
al_init_ttf_addon();// initialize the ttf (True Type Font) addon
if (!font){
al_show_native_message_box(display, "Error", "Error", "Could not load Pokemon GB.ttf", nullptr, ALLEGRO_MESSAGEBOX_ERROR);
return -1;
}
}