-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNPCNarrative.cpp
More file actions
461 lines (408 loc) · 27.8 KB
/
Copy pathNPCNarrative.cpp
File metadata and controls
461 lines (408 loc) · 27.8 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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
#include <iostream>
// #include "Button.cpp"
using namespace sf;
using namespace std;
class NarrativeNPC{
public:
Text instruction[10];
Button choice[3];
Font font;
Time time;
NarrativeNPC(){
time = seconds(4);
if (!font.loadFromFile("arial.ttf")){}
for(int i = 0; i < 10; i++ ){
instruction[i].setFont(font);
instruction[i].setFillColor(sf::Color::White);
}
}
void talkToWoodsCharacter(RenderWindow &window){
while (1){
window.clear();
instruction[0].setPosition(Vector2f(10,50));
instruction[0].setString("You have decided to interact with the stranger in the forest.");
instruction[1].setPosition(Vector2f(10,100));
instruction[1].setString("Stranger: 'Greetings! What brings you here?'");
choice[0] = Button(Vector2f(50, 200), 400, 50, font, "I'm seeking adventure");
choice[1] = Button(Vector2f(50, 300), 900, 50, font, "I'm looking for my way to the castle...I want to speak to the King");
choice[2] = Button(Vector2f(50, 400), 400, 50, font, "Why are you here?");
window.draw(instruction[0]);
window.draw(instruction[1]);
choice[0].drawButton(window);
choice[1].drawButton(window);
choice[2].drawButton(window);
window.display();
Event event;
while (window.pollEvent(event)) {
switch (event.type) {
case Event::Closed:
window.close();
break;
case Event::MouseButtonPressed:
if(event.mouseButton.button == Mouse::Left) {
Vector2f mousePos = window.mapPixelToCoords(Mouse::getPosition(window));
if(choice[0].isClicked(mousePos)){
window.clear();
instruction[2].setPosition(Vector2f(10,50));
instruction[2].setString("Stranger: 'Adventure, you say? Well... I may have a favor to ask of you.\nYou see, there's been a horrific dragon terrorizing our villages\nfor nearly a decade.\nThe King chooses not to do anything about it! But you, you seem brave...'");
Button conv[2];
conv[0] = Button(Vector2f(50, 300), 450, 50, font, "Tell me more about this dragon");
conv[1] = Button(Vector2f(50, 400), 650, 50, font, "Leave the conversation to look for the dragon");
window.draw(instruction[2]);
conv[0].drawButton(window);
conv[1].drawButton(window);
window.display();
while(1){
Event event2;
while (window.pollEvent(event2)){
switch(event2.type) {
case Event::Closed:
window.close();
break;
case Event::MouseButtonPressed:
if(event2.mouseButton.button == Mouse::Left) {
Vector2f mousePos = window.mapPixelToCoords(Mouse::getPosition(window));
if(conv[0].isClicked(mousePos)){
window.clear();
instruction[3].setPosition(Vector2f(10, 200));
instruction[3].setString("Stranger: 'The dragon is violent. Merciless.\nIt has no regard for mere human beings.\nI'm not sure what kind of adventure you are seeking,\nbut be careful of this creature.\nRemain aggressive, and you just may take it down once and for all...");
window.draw(instruction[3]);
window.display();
sleep(time);
return;
}else if(conv[1].isClicked(mousePos)){
return;
}
}
break;
default:
break;
}
}
}
}else if(choice[1].isClicked(mousePos)){
window.clear();
instruction[4].setPosition(Vector2f(10,50));
instruction[4].setString("Stranger: 'That wretched King...\nHe has never been of any help for our villages.\nA dragon has been terrorizing our villages\nfor nearly a decade. And the King has been silent.'");
Button conv[2];
conv[0] = Button(Vector2f(50, 300), 500, 50, font, "Why hasn't the King done anything?");
conv[1] = Button(Vector2f(50, 400), 650, 50, font, "Leave the conversation to look for the dragon");
window.draw(instruction[4]);
conv[0].drawButton(window);
conv[1].drawButton(window);
window.display();
while(1){
Event event2;
while (window.pollEvent(event2)){
switch(event2.type) {
case Event::Closed:
window.close();
break;
case Event::MouseButtonPressed:
if(event2.mouseButton.button == Mouse::Left) {
Vector2f mousePos = window.mapPixelToCoords(Mouse::getPosition(window));
if(conv[0].isClicked(mousePos)){
window.clear();
instruction[5].setPosition(Vector2f(10, 100));
instruction[5].setString("Stranger: 'The King only looks after himself and those close to him.\nHe has no regards for us poor individuals in these villages.\nHe's been the worst King I've ever seen in my lifetime,\nand I've lived a very long life so far...'");
instruction[6].setPosition(Vector2f(10,400));
instruction[6].setString("You leave to help these villages.");
window.draw(instruction[5]);
window.draw(instruction[6]);
window.display();
sleep(time);
return;
}else if(conv[1].isClicked(mousePos)){
return;
}
}
break;
default:
break;
}
}
}
}else if(choice[2].isClicked(mousePos)){
window.clear();
instruction[7].setPosition(Vector2f(10,50));
instruction[7].setString("Stranger: 'I prefer to hide out in these trees from the violent dragon\njust further down this path.\nIt is the only way I feel safe.'");
Button conv[2];
conv[0] = Button(Vector2f(50, 300), 500, 50, font, "Tell me more about this dragon.");
conv[1] = Button(Vector2f(50, 400), 650, 50, font, "Leave the conversation to look for the dragon");
window.draw(instruction[7]);
conv[0].drawButton(window);
conv[1].drawButton(window);
window.display();
while(1){
Event event2;
while (window.pollEvent(event2)){
switch(event2.type) {
case Event::Closed:
window.close();
break;
case Event::MouseButtonPressed:
if(event2.mouseButton.button == Mouse::Left) {
Vector2f mousePos = window.mapPixelToCoords(Mouse::getPosition(window));
if(conv[0].isClicked(mousePos)){
window.clear();
instruction[8].setPosition(Vector2f(10, 200));
instruction[8].setString("Stranger: 'The dragon is violent. It only knows terror and violence.\nHowever, it seems if you are able to defeat it...\nYou do receive a reward in the end.'");
instruction[9].setPosition(Vector2f(10,400));
instruction[9].setString("You leave to look for the dragon.");
window.draw(instruction[8]);
window.draw(instruction[9]);
window.display();
sleep(time);
return;
}else if(conv[1].isClicked(mousePos)){
return;
}
}
break;
default:
break;
}
}
}
}
}
break;
default:
break;
}
}
}
}
void talkToLakeCharacter(RenderWindow &window){
while (1){
window.clear();
instruction[0].setPosition(Vector2f(10,50));
instruction[0].setString("You have decided to speak to the fisherman.");
instruction[1].setPosition(Vector2f(10,100));
instruction[1].setString("Fisherman: 'Hello, there! Come here to fish?'");
choice[0] = Button(Vector2f(50, 200), 400, 50, font, "I'm just passing through.");
choice[1] = Button(Vector2f(50, 300), 400, 50, font, "Tell me about the lake.");
window.draw(instruction[0]);
window.draw(instruction[1]);
choice[0].drawButton(window);
choice[1].drawButton(window);
window.display();
Event event;
while (window.pollEvent(event)) {
switch (event.type) {
case Event::Closed:
window.close();
break;
case Event::MouseButtonPressed:
if(event.mouseButton.button == Mouse::Left) {
Vector2f mousePos = window.mapPixelToCoords(Mouse::getPosition(window));
if(choice[0].isClicked(mousePos)){
window.clear();
instruction[2].setPosition(Vector2f(10,50));
instruction[2].setString("Fisherman: 'I see. Well, be careful!\nThere's been sightings of a huge lake monster, right along these paths.'");
Button conv[2];
conv[0] = Button(Vector2f(50, 300), 450, 50, font, " Why are you here, then?");
conv[1] = Button(Vector2f(50, 400), 750, 50, font, "Leave the conversation to look for the lake monster");
window.draw(instruction[2]);
conv[0].drawButton(window);
conv[1].drawButton(window);
window.display();
while(1){
Event event2;
while (window.pollEvent(event2)){
switch(event2.type) {
case Event::Closed:
window.close();
break;
case Event::MouseButtonPressed:
if(event2.mouseButton.button == Mouse::Left) {
Vector2f mousePos = window.mapPixelToCoords(Mouse::getPosition(window));
if(conv[0].isClicked(mousePos)){
window.clear();
instruction[3].setPosition(Vector2f(10, 200));
instruction[3].setString("Fisherman: 'I need to feed myself and my family somehow.\nThe King has clearly shown he is nothing but\nuseless when it comes to our safety and basic needs.'\n\nYou feel sorry for the fisherman.");
window.draw(instruction[3]);
window.display();
sleep(time);
return;
}else if(conv[1].isClicked(mousePos)){
return;
}
}
break;
default:
break;
}
}
}
}else if(choice[1].isClicked(mousePos)){
window.clear();
instruction[4].setPosition(Vector2f(10,50));
instruction[4].setString("Fisherman: 'It used to be a peaceful place...\nUnfortunately, it's been overrun by a giant lake monster,\njust further down this path.\nIt's affected people's nearby homes, and food supplies!\nThe monster eats all the fish before we get to it!\nSadly, the King doesn't seem to care.'");
Button conv[2];
conv[0] = Button(Vector2f(50, 300), 600, 50, font, "Why do you think the King doesn't care?");
conv[1] = Button(Vector2f(50, 400), 750, 50, font, "Leave the conversation and look for the lake monster");
window.draw(instruction[4]);
conv[0].drawButton(window);
conv[1].drawButton(window);
window.display();
while(1){
Event event2;
while (window.pollEvent(event2)){
switch(event2.type) {
case Event::Closed:
window.close();
break;
case Event::MouseButtonPressed:
if(event2.mouseButton.button == Mouse::Left) {
Vector2f mousePos = window.mapPixelToCoords(Mouse::getPosition(window));
if(conv[0].isClicked(mousePos)){
window.clear();
instruction[5].setPosition(Vector2f(10, 100));
instruction[5].setString("Fisherman: 'He is simply downright selfish.\nBut, it's alright, we make it work...\nI do hope you are brave enough to confront this creature.\nProvide us some peace.'");
instruction[6].setPosition(Vector2f(10,400));
instruction[6].setString("You feel sorry for the fisherman");
window.draw(instruction[5]);
window.draw(instruction[6]);
window.display();
sleep(time);
return;
}else if(conv[1].isClicked(mousePos)){
return;
}
}
break;
default:
break;
}
}
}
}
}
break;
default:
break;
}
}
}
}
void talkToCastleCharacter(RenderWindow &window){
while (1){
window.clear();
instruction[0].setPosition(Vector2f(10,50));
instruction[0].setString("You have decided to talk to the former night and see what he has to say.");
instruction[1].setPosition(Vector2f(10,100));
instruction[1].setString("Knight: 'Why are you here?'");
choice[0] = Button(Vector2f(50, 200), 600, 50, font, "I'm here to fight the King once and for all");
choice[1] = Button(Vector2f(50, 300), 500, 50, font, "I should ask you the same question.");
window.draw(instruction[0]);
window.draw(instruction[1]);
choice[0].drawButton(window);
choice[1].drawButton(window);
window.display();
Event event;
while (window.pollEvent(event)) {
switch (event.type) {
case Event::Closed:
window.close();
break;
case Event::MouseButtonPressed:
if(event.mouseButton.button == Mouse::Left) {
Vector2f mousePos = window.mapPixelToCoords(Mouse::getPosition(window));
if(choice[0].isClicked(mousePos)){
window.clear();
instruction[2].setPosition(Vector2f(10,50));
instruction[2].setString("Knight: 'You're here to defeat the King!?\nFinally! Someone is brave enough to do so.\nLet me offer you some advice...'");
Button conv[2];
conv[0] = Button(Vector2f(50, 300), 800, 50, font, " I do not need advice. I will fight the King head-on");
conv[1] = Button(Vector2f(50, 400), 350, 50, font, "Tell me more.");
window.draw(instruction[2]);
conv[0].drawButton(window);
conv[1].drawButton(window);
window.display();
while(1){
Event event2;
while (window.pollEvent(event2)){
switch(event2.type) {
case Event::Closed:
window.close();
break;
case Event::MouseButtonPressed:
if(event2.mouseButton.button == Mouse::Left) {
Vector2f mousePos = window.mapPixelToCoords(Mouse::getPosition(window));
if(conv[0].isClicked(mousePos)){
window.clear();
instruction[3].setPosition(Vector2f(10, 200));
instruction[3].setString("You leave before the former knight could say anything else");
window.draw(instruction[3]);
window.display();
sleep(time);
return;
}else if(conv[1].isClicked(mousePos)){
window.clear();
instruction[3].setPosition(Vector2f(10, 100));
instruction[3].setString("Knight: 'The King can be aggressive...\nYou must match that energy.\nWhatever you do, do not try and run away.\nThe King is too quick, he will get you.\n\nYou leave more confident.");
window.draw(instruction[3]);
window.display();
sleep(time);
return;
}
}
break;
default:
break;
}
}
}
}else if(choice[1].isClicked(mousePos)){
window.clear();
instruction[4].setPosition(Vector2f(10,50));
instruction[4].setString("Knight: 'Clever.\nTruly, I have nowhere to go since the King banished me from my role as a\nKnight.\nHe's a horrible King, the worst these villages have ever had.\nHe shows no mercy to the civilians that reside here.'");
Button conv[2];
conv[0] = Button(Vector2f(50, 300), 750, 50, font, "Do you have any advice for when I confront him?");
conv[1] = Button(Vector2f(50, 400), 600, 50, font, "Leave and look for the King.");
window.draw(instruction[4]);
conv[0].drawButton(window);
conv[1].drawButton(window);
window.display();
while(1){
Event event2;
while (window.pollEvent(event2)){
switch(event2.type) {
case Event::Closed:
window.close();
break;
case Event::MouseButtonPressed:
if(event2.mouseButton.button == Mouse::Left) {
Vector2f mousePos = window.mapPixelToCoords(Mouse::getPosition(window));
if(conv[0].isClicked(mousePos)){
window.clear();
instruction[5].setPosition(Vector2f(10, 100));
instruction[5].setString("Knight: 'The King can be aggressive.\nWhatever you do, do not try and run away.\nHe is quick, and he will get you.'");
instruction[6].setPosition(Vector2f(10,400));
instruction[6].setString("You leave more confident.");
window.draw(instruction[5]);
window.draw(instruction[6]);
window.display();
sleep(time);
return;
}else if(conv[1].isClicked(mousePos)){
return;
}
}
break;
default:
break;
}
}
}
}
}
break;
default:
break;
}
}
}
}
};