/
game_scene.cpp
2632 lines (2374 loc) · 112 KB
/
game_scene.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
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
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//////////////////////////////////////////////////////////////////////////////////////////////////////////
// //
// //
// //
// //
// //
// //
// Knight Owls game by Tom Horwath (Blaise Rascal) //
// //
// This source code is terrible! View at your own risk! //
// //
// LICENSE: //
// Play the game all you want, for free. //
// Put it on your retro console, or your computer, or whatever! Recompile it from source! Go hog wild! //
// Either distribute it (for free) OR modify the source, but please don't distribute a modified version.//
// (Exceptions can be made; please contact me to discuss releasing your proposed modified version.) //
// //
// Source code is shared primarily for education purposes. //
// You can use code snippets in your own projects, but don't use the art, or the music, //
// or rip off huge portions of the game's design without my permission. //
// (Feel free to ask permission! There's a good chance I'll give it to you.) //
// Additionally, all licenses in the licenses folder apply. //
// //
// //
// //
// //
// //
// //
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//NEXT ENEMY:
//15k
//NEXT: 15k
/////////////////
//BRAINSTORMING//
/////////////////
//STORY MODE - A set of short story-driven challenges.
//Chapter 1 (Tutorial)
//ROGUELIKE MODE - A long, randomly generated, difficult journey. For the hardcore players!
//LEVEL 1 - A relatively quick and easy journey, with one boss at the end.
//LEVEL 2 - Introduces the banner mechanic, and features two bosses, with a spellbook reset in the middle.
//LEVEL 3 - A long and arduous journey featuring three bosses and two spellbook resets. Are you up for the challenge?
//TUTORIAL & CREDITS - All info for this game is at ____ since I didn't have time to write it into the game.
//Game by Tom Horwath (Blaise Rascal).
//+4c (25% CHANCE TO DO NOTHING)
//+5k (25% CHANCE FOR DOUBLE)
#include "bn_core.h"
#include "bn_display.h"
#include "bn_sprite_item.h"
#include "bn_sprite_ptr.h"
#include "bn_sprites.h"
#include "bn_vector.h"
#include "bn_regular_bg_ptr.h"
#include "bn_keypad.h"
#include "bn_math.h"
#include "bn_string.h"
#include "bn_array.h"
#include "bn_random.h"
#include "bn_sprite_text_generator.h"
#include "bn_fixed_point.h"
#include "bn_sprite_tiles_ptr.h"
#include "bn_sprite_items_knight_owls.h"
#include "bn_sprite_items_selection_cursor.h"
#include "bn_sprite_items_right_book_arrow.h"
#include "bn_sprite_items_left_book_arrow.h"
#include "bn_sprite_items_banners.h"
#include "bn_sprite_items_enemies.h"
//#include "bn_sprite_items_button.h"
#include "bn_sprite_items_salearrows.h"
#include "bn_regular_bg_items_oceanbackground.h"
#include "bn_regular_bg_items_spellbook.h"
#include "bn_regular_bg_items_rift.h"
#include "game_scene.h"
#include "bn_music_items.h"
#include "bn_music_actions.h"
#include "variable_8x8_sprite_font.h"
//TODO: clean up includes, remove from game those things built extraneously by $make clean $make
namespace{
const int MERCS_FOR_SALE = 6;
const int RUNES_PER_TURN = 4;
//const int MAX_BOAT_WEIGHT = 4;
//const int MAX_HULL = 4;
const int STARTING_MERC_INDEX = 0;
const int NUMBER_SPELLBOOK_COLUMNS = 6;
const int NUMBER_SPELLBOOK_ROWS = 3;
const int ZONE_ONE_BG_Y = 256;
const int ZONE_TWO_BG_Y = 0;
const int ZONE_THREE_BG_Y = -256;
//const int START_OF_ZONE_TWO = 12;
//const int START_OF_ZONE_THREE = 24;
//const int
//const bn::array<3> MERC_POSITIONS
//const bn::string<6> deploy_label_text(" DRAW");
}
//soon to do, better slection cursor, better energy bursts
game_scene::game_scene(bn::sprite_text_generator& text_generator):
my_text_generator(text_generator),
_ocean_bg(bn::regular_bg_items::oceanbackground.create_bg(0,ZONE_ONE_BG_Y)),
//_swamp_bg(bn::regular_bg_items::swampbackground.create_bg(0, 0)),
_spellbook_bg(bn::regular_bg_items::spellbook.create_bg(0, 0)),
_rift_bg(bn::regular_bg_items::rift.create_bg(0, 0)),
_selection_cursor_sprite(bn::sprite_items::selection_cursor.create_sprite(0, 30)),
_right_book_arrow_sprite(bn::sprite_items::right_book_arrow.create_sprite(110, -15)),
_left_book_arrow_sprite(bn::sprite_items::left_book_arrow.create_sprite(-110, -15)),
_enemy_sprite(bn::sprite_items::enemies.create_sprite(70, 10)), //TODO: Push up your stat box & enemy stat box, and enemy sprite
//weight_hud_text("WEIGHT: "),
current_weight(0),
current_power(0),
current_runes(0), // MODIFY THIS VALUE TO SET STARTING RUNES
current_hull(0),
max_hull(4),
max_boat_weight(4),
runes_which_might_disappear(0),
menu_position(0),
state(0),
last_tableau_x_pos(-110),
last_tableau_y_pos(10),
last_merc_tableau_x_pos(-50),
menu_position_max(1),
current_wave(0),
won_wave(false),
total_merc_probs(0),
random_num(0),
player_stat_box_active(false),
enemy_stat_box_active(false),
state_before_spellbook(0),
state_before_summon_start(0),
number_sb_pages(0),
current_sb_page(0),
current_sb_owl(0),
upgrade_option_one(0),
upgrade_option_two(0),
//current_zone(0),
start_of_zone_two(0),
start_of_zone_three(0),
last_banner_tableau_x_pos(-110)
{
current_hull=max_hull;
bn::music_items::voyagemusic.play(0.4);
//WaveInfoVector.push_back({-2,0,0,0});//-2 is miasma
//WaveInfoVector.push_back({-2,0,0,0});//-2 is miasma
//WaveInfoVector.push_back({14,1,1,0});
//WaveInfoVector.push_back({14,1,1,0});
//attack, reward, penalty, enemyinfoindex
BossAttacks = {60,75,90};
ZoneNames = {"STRIGASSO SEA","STORMY PASSAGE","ASTRAL RIVER"};
WaveInfoVector.push_back({14,1,1,0}); //LILYBAD
WaveInfoVector.push_back({17,1,1,1}); //MARAUDING OWLSHIP
WaveInfoVector.push_back({20,1,1,2}); //FLOATING VILESTAR
WaveInfoVector.push_back({23,1,1,3}); //LAMB ON THE LAM
WaveInfoVector.push_back({-1,0,0,0});//-1 is shipwreck
WaveInfoVector.push_back({29,1,2,4}); //DIRE LILYBAD
WaveInfoVector.push_back({35,1,2,5}); //GOBLIN SURF-SHIP
WaveInfoVector.push_back({42,1,2,6}); //CAT HYDRA
WaveInfoVector.push_back({50,1,2,7}); //PRETZELCOATL
WaveInfoVector.push_back({BossAttacks[0], 9999, 9999,12});//-1 is victory, 9999 is death //LILYBANE
WaveInfoVector.push_back({-2,0,0,0});//-2 is miasma
WaveInfoVector.push_back({-1,0,0,0});//-1 is shipwreck
WaveInfoVector.push_back({15,1,1,17}); //HAUNTED OWLSHIP
WaveInfoVector.push_back({18,1,1,13}); // LAMB WITH A LAMBIC
WaveInfoVector.push_back({21,1,1,21}); // SWIMMIN' WOMEN
WaveInfoVector.push_back({26,1,1,19}); // VICIOUS FISHES
WaveInfoVector.push_back({-1,0,0,0});//-1 is shipwreck
WaveInfoVector.push_back({33,1,2,20}); // CORRUPTED SHADOWSTAR
WaveInfoVector.push_back({41,1,2,18}); // BORIS THE GRIMDARK
WaveInfoVector.push_back({50,1,2,23}); //CAT HYDRA WITH SUNGLASSES
WaveInfoVector.push_back({61,1,2,28}); // LILY AND THE GOBLINS
WaveInfoVector.push_back({BossAttacks[1], 9999, 9999,16});// GREAT PACIFIC GARBAGE PATCH
WaveInfoVector.push_back({-2,0,0,0});//-2 is miasma
WaveInfoVector.push_back({-1,0,0,0});//-1 is shipwreck
WaveInfoVector.push_back({15,1,1,26}); //LILYDADJOKE
WaveInfoVector.push_back({19,1,1,14}); // CYCLOPEAN HOVERSTAR
WaveInfoVector.push_back({23,1,1,22});//MIASMOID
WaveInfoVector.push_back({29,1,1,11}); // INVISIBLE NEMESIS
WaveInfoVector.push_back({-1,0,0,0});//-1 is shipwreck
WaveInfoVector.push_back({37,1,2,24}); //MARY
WaveInfoVector.push_back({46,1,2,25}); // GUNGLASSES
WaveInfoVector.push_back({58,1,2,15});// CAT HYDRA WITH PARTY HATS
WaveInfoVector.push_back({72,1,2,27}); // BONES MCJONES
WaveInfoVector.push_back({BossAttacks[2], 9999, 9999,8}); //HERMAN
//TODO: NO SHOP AFTER BOSS!!!!!!!!!!!!!!!!!
for(int i = 0; i < WaveInfoVector.size(); i++)
{
if (WaveInfoVector.at(i).attack==-2)
{
if(start_of_zone_two==0)
{
start_of_zone_two = i+1;
}
else
start_of_zone_three = i+1;
}
}
//
EnemyInfoVector.push_back({0,"LILYBAD"});
EnemyInfoVector.push_back({1,"MARAUDING OWLSHIP"});
EnemyInfoVector.push_back({2,"VILE HOVERSTAR"});
EnemyInfoVector.push_back({3,"LAMB ON THE LAM"});
EnemyInfoVector.push_back({4,"DIRE LILYBAD"});
EnemyInfoVector.push_back({5,"GOBLIN SURF-SHIP"});
EnemyInfoVector.push_back({6,"CAT HYDRA"});
EnemyInfoVector.push_back({7,"PRETZELCOATL"});
EnemyInfoVector.push_back({8,"HERMAN THE MERMAN"});
EnemyInfoVector.push_back({9,"SHIPWRECK"});
EnemyInfoVector.push_back({10,"MIASMA"});
EnemyInfoVector.push_back({11,"INVISIBLE NEMESIS"});
EnemyInfoVector.push_back({12,"LILYBANE"});
EnemyInfoVector.push_back({13,"LAMB WITH A LAMBIC"});
EnemyInfoVector.push_back({14,"CYCLOPEAN HOVERSTAR"});
EnemyInfoVector.push_back({15,"CAT HYDRA WITH PARTY HATS"});
EnemyInfoVector.push_back({16,"GREAT PACIFIC TRASH HEAP"});
EnemyInfoVector.push_back({17,"HAUNTED OWLSHIP"});
EnemyInfoVector.push_back({18,"BORIS THE GRIMDARK"});
EnemyInfoVector.push_back({19,"VICIOUS FISHES"});
EnemyInfoVector.push_back({20,"CORRUPTED SHADOWSTAR"});
EnemyInfoVector.push_back({21,"SWIMMIN' WOMEN"});
EnemyInfoVector.push_back({22,"MIASMOID"});
EnemyInfoVector.push_back({23,"CAT HYDRA WITH SUNGLASSES"});
EnemyInfoVector.push_back({24,"MARY"});
EnemyInfoVector.push_back({25,"GUNGLASSES"});
EnemyInfoVector.push_back({26,"LILYDADJOKE"});
EnemyInfoVector.push_back({27,"BONES MCJONES"});
EnemyInfoVector.push_back({28,"LILY AND THE GOBLINS"});
//8 d20 (5% to do +10k)
//9 courage (+1 max static, -1 max HP)
//10 strength (+2 max HP)
//11 coupon (one owl goes on sale every round)
//12 first aid (after fight, 50% chance for +1hp)
//13 surge (first 3 owls summoned will not be surges)
//14 risk (after loss +2c)
//15 goblin (permanent goblin added to deck)
//16 When you fight, if your +c this round was 8 or higher, gain +5k
NonOwlUpgradeInfoVector.push_back({"D20","WHENEVER YOU SUMMON, ROLL A D20.","IF IT'S A 20, GET +10k."}); //0
NonOwlUpgradeInfoVector.push_back({"COURAGE","+1 MAX iSTATIC, BUT -2 MAX mHP."," "}); //1 //FOR NOW WE NEED A SPACE HERE BECAUSE MY CODE SUCKS! TODO: FIX THIS LATER
NonOwlUpgradeInfoVector.push_back({"STRENGTH","+2 MAX AND CURRENT mHP."," "}); //2
NonOwlUpgradeInfoVector.push_back({"STONKS","EVERY ROUND, 1 RANDOM OWL","COSTS -2c, AND ANOTHER +2c."}); //3
NonOwlUpgradeInfoVector.push_back({"FIRST AID","AFTER FIGHT, 75% CHANCE TO","HEAL 1 mHP."}); //4
NonOwlUpgradeInfoVector.push_back({"PITY","AFTER YOU LOSE A FIGHT,","GAIN +4c."}); //5
NonOwlUpgradeInfoVector.push_back({"GOBLIN","ADD A PERMANENT GOBLIN TO YOUR","SPELLBOOK. (GOBLIN HAS +1D8k.)"}); //6
NonOwlUpgradeInfoVector.push_back({"MONEYBAGS","WHEN YOU FIGHT, IF YOUR +c THIS","ROUND WAS 10 OR HIGHER, GAIN +6k."}); //7
//NonOwlUpgradeInfoVector.push_back({"COUNTDOWN","FIRST 2 SUMMONS WILL NOT BE","SURGES."});
//rare owls (probably listed elsewhere as well)
//bombardier
AmountMercOnSale.fill(0);
//each cardinfovector has an abilities vector, with 2 abilities (for now)
//abilityindex & value
//{0=atk 5=value} {2=static 1=value}
//
//mage = barn owl
//archer = ?
//spear-owl = ?
//mystic = ?
//thug = ?
//energy knight = great horned owl
//alchemist = ?
//merchant = snowy owl
// name, cost, weight, p1,p2,p2% g1,g2,g2% tileindex, rarity
//RARITIES: 0 = special
// 1 = common
// 2 = uncommon money
// 3 = uncommon attack
//CardInfoVector.push_back({"MAGE", 3,0, 0,0,0, 1,0,0, 1,1}); // stuff to add: int attackone int attackonepercentage int attacktwo int attacktwopercentage int
//CardInfoVector.push_back({"ARCHER", 4,0, 3,0,0, 0,0,0, 2,1});
CardInfoVector.push_back({"MAGE", 2,0, 0,0,0, 1,0,0, 1,1}); // stuff to add: int attackone int attackonepercentage int attacktwo int attacktwopercentage int
CardInfoVector.push_back({"ARCHER", 4,0, 3,0,0, 0,0,0, 2,1});
CardInfoVector.push_back({"ENERGY SURGE", 0,1, 5,0,0, 1,0,0, 6,0});
CardInfoVector.push_back({"MEGA ENERGY SURGE", 0,2, 10,0,0, 2,0,0, 7,0});
CardInfoVector.push_back({"SPEAR-OWL", 5,0, 4,12,25, 0,0,0, 4,3}); // WHEN SUMMONED: 50% chance double ATK
CardInfoVector.push_back({"MYSTIC", 4,0, -1,0,0, 3,0,0, 5,2}); // 50% chance for evil? or maybe: AFTER FIGHT: Random owl goes on sale?
CardInfoVector.push_back({"THUG", 7,0, 12,0,0, -2,0,0, 0,3}); // -1money
CardInfoVector.push_back({"ENERGY KNIGHT", 13,1, 30,0,0, 0,0,0, 3,3}); // +1 energy
CardInfoVector.push_back({"ALCHEMIST", 6,0, 0,0,0, 5,0,25, 8,2}); // +3money if your atk is even? or maybe AFTER FIGHT: 3 owls cost 1 less
CardInfoVector.push_back({"MERCHANT", 10,0, 0,0,0, 5,0,0, 9,2}); // AFTER FIGHT: 3 random owls cost 1 less
CardInfoVector.push_back({"GOBLIN", 0,0, 0,0,0, 0,0,0, 10,0}); // 10 uh the gobbo has a unique mechanic. maybe i should put it off til tomorrow.
//todo: well obviously i don't need the repeat info
UpgradedCardInfoVector.push_back({"MAGE", 2,0, 0,0,0, 1,2,50, 1,1}); // stuff to add: int attackone int attackonepercentage int attacktwo int attacktwopercentage int
UpgradedCardInfoVector.push_back({"ARCHER", 4,0, 4,0,0, 0,0,0, 2,1});
UpgradedCardInfoVector.push_back({"ENERGY SURGE", 0,1, 5,0,0, 1,0,0, 6,0});
UpgradedCardInfoVector.push_back({"MEGA ENERGY SURGE", 0,2, 10,0,0, 2,0,0, 7,0});
UpgradedCardInfoVector.push_back({"SPEAR-OWL", 5,0, 4,12,50, 0,0,0, 4,3}); // WHEN SUMMONED: 50% chance double ATK
UpgradedCardInfoVector.push_back({"MYSTIC", 4,0, -2,0,0, 5,0,0, 5,2}); // 50% chance for evil? or maybe: AFTER FIGHT: Random owl goes on sale?
UpgradedCardInfoVector.push_back({"THUG", 7,0, 18,0,0, -3,0,0, 0,3}); // -1money
UpgradedCardInfoVector.push_back({"ENERGY KNIGHT", 13,1, 42,0,0, 0,0,0, 3,3}); // +1 energy
UpgradedCardInfoVector.push_back({"ALCHEMIST", 6,0, 0,0,0, 10,0,35, 8,2}); // +3money if your atk is even? or maybe AFTER FIGHT: 3 owls cost 1 less
UpgradedCardInfoVector.push_back({"MERCHANT", 10,0, 0,0,0, 10,0,0, 9,2}); // AFTER FIGHT: 3 random owls cost 1 less
// name, cost, static, attack, gather, tileindex, rarity
//builder owl
// mage-powered golem If you have at least 4 mages in play, +20ATK
// On purchase: -1HP
//Generate the deck of mercs to draw from.
for(int i =0; i< CardInfoVector.size(); i++)
{
if(CardInfoVector.at(i).rarity == 2)
{
AllUncommonEconomyMercs.push_back(i);
}
else if(CardInfoVector.at(i).rarity == 3)
{
AllUncommonAttackingMercs.push_back(i);
}
/* if(CardInfoVector.at(i).rarity==3 || CardInfoVector.at(i).rarity==2 || CardInfoVector.at(i).rarity==1)
{
AllCommonAndUncommonMercs.push_back(i);
}*/
}
for(int i = 0; i < 8; i++)
{
DeckOfOwlUpgrades.push_back(i);
DeckOfNonOwlUpgrades.push_back(i);
}
//CardInfoTempDeckWithoutReplacement
//make starting deck
player1deck.push_back(2);
player1deck.push_back(2);
player1deck.push_back(3);
player1deck.push_back(3);
player1deck.push_back(0);
player1deck.push_back(0);
player1deck.push_back(1);
player1deck.push_back(1);
player1deck_after_miasma = player1deck;
_selection_cursor_sprite.set_visible(false);
_selection_cursor_sprite.set_z_order(-100);
_selection_cursor_sprite.set_bg_priority(0); //lower z order means it shows up higher. wacky huh?
_right_book_arrow_sprite.set_visible(false);
_right_book_arrow_sprite.set_z_order(-98);
_right_book_arrow_sprite.set_bg_priority(0); //lower z order means it shows up higher. wacky huh?
_left_book_arrow_sprite.set_visible(false);
_left_book_arrow_sprite.set_z_order(-98);
_left_book_arrow_sprite.set_bg_priority(0); //lower z order means it shows up higher. wacky huh?
_enemy_sprite.set_visible(false);
_spellbook_bg.set_z_order(-90);
_spellbook_bg.set_priority(0);
_spellbook_bg.set_visible(false);
_rift_bg.set_z_order(-80);
_rift_bg.set_priority(1);
_rift_bg.set_visible(false);
//_ocean_bg.set_y(20);
// _swamp_bg.set_visible(false);
}
int game_scene::run_scene()
{
bn::random random_generator;
//int random_num;
//total merc probs started as 0, and is calculated here
/*for(int i =0; i<CardInfoVector.size();i++)
{
total_merc_probs += CardInfoVector.at(i).probabilityweight;
}*/
while(true)
{
//This is a deterministic random generator, so it must be spun every frame to not return the same numbers every boot.
//Luckily this is not too slow to affect performance.
//TODO: If I implement a title screen, this should start spinning then for maximum randomness
random_num = random_generator.get(); // Do not alter this value! It continues spinning each frame
switch(state)
{
case 0: // Beginning of game
{
//_display_status(bn::to_string<50>(total_merc_probs));
_display_status("A CHILL WIND BLOWS...","PRESS a TO BEGIN VOYAGE");
//_display_status(_generate_first_upgrade_description_from_upgrade_index(6),_generate_second_upgrade_description_from_upgrade_index(6));
for(int mercstoadd=0; mercstoadd<MERCS_FOR_SALE; mercstoadd++)
{
//int card_to_add=0;
//MercenaryDeck.push_back(0);
bn::sprite_ptr NewTableauImg = bn::sprite_items::knight_owls.create_sprite(last_merc_tableau_x_pos, -35);
NewTableauImg.set_tiles(bn::sprite_items::knight_owls.tiles_item().create_tiles(0));
MercenaryTableau.push_back(NewTableauImg);
MercenaryTableau.at(mercstoadd).set_visible(false);
MercenaryTableau.at(mercstoadd).set_z_order(-75);
MercenaryTableau.at(mercstoadd).set_bg_priority(1); //TODO: Plan out this better
bn::sprite_ptr NewerTableauImg = bn::sprite_items::salearrows.create_sprite(last_merc_tableau_x_pos-1, -27);
NewerTableauImg.set_tiles(bn::sprite_items::salearrows.tiles_item().create_tiles(0));
SaleArrowsTableau.push_back(NewerTableauImg);
SaleArrowsTableau.at(mercstoadd).set_visible(false);
SaleArrowsTableau.at(mercstoadd).set_z_order(-76);
SaleArrowsTableau.at(mercstoadd).set_bg_priority(1);
last_merc_tableau_x_pos+=20;
}
int topleftx = -79;
int toplefty = -50;
//int currentx = topleftx;
//int currenty =
//should probably be an array of vectors, or something. oh well
for(int spellbookrow=0; spellbookrow<NUMBER_SPELLBOOK_ROWS; spellbookrow++)
{
//int card_to_add=0;
//MercenaryDeck.push_back(0);
for(int spellbookcolumn=0; spellbookcolumn<NUMBER_SPELLBOOK_COLUMNS; spellbookcolumn++)
{
bn::sprite_ptr NewTableauImg = bn::sprite_items::knight_owls.create_sprite(topleftx + spellbookcolumn*32, toplefty + spellbookrow*34);
NewTableauImg.set_tiles(bn::sprite_items::knight_owls.tiles_item().create_tiles(0)); //TODO: uh delete
NewTableauImg.set_z_order(-95);
NewTableauImg.set_bg_priority(0);
NewTableauImg.set_visible(false);
SpellbookTableau.push_back(NewTableauImg);
//last_merc_tableau_x_pos+=20;
}
}
IsUpgradeResearched.fill(false);
//THIS IS WHERE YOU ADD NEW UPGRADES FOR TESTING!
/*_research_upgrade(7);
_research_upgrade(8);
_research_upgrade(15);
_research_upgrade(14);
_research_upgrade(10);*/
//_research_upgrade(7);
_update_hud_text();
_update_wave_info_hud_text();
state = 101;
break;
}
//What SHOULD be done: summon 3 random owls at end of combat round (and when purchased show what's underneath)
//Maybe guarantee that an owl in the first round will be a mage? hmm
//summoned energy burst!
//+5 attack, +1 runes, +1 static
//summoned mega energy burst!
//+10 attack, +2 runes, +2 static
//Help Mode is ON.
//While Help Mode is enabled, tips will pop up, explaining how to play.
//You can disable Help Mode at any time in the PAUSE MENU by pressing START.
//HELP MODE TIP
//
//Only your flying units count for flying enemies!... nah... maybe
//SPELLBOOK: strange text at top
//All the owls in your spellbook are displayed here.
//When you summon an owl, it is chosen at random from the ones remaining in your spellbook.
//The ones you have already summoned are marked with an X.
//in owl language: RESTIAI FOLAR <-e umlaut
//The _____ is the elaborate summoning ritual in which talented summoners call on spirits from Owlhalla to aid them in battle.
//Static too high! You lose control.
//The summoning spell explodes!
//BRUISER and THUG
//ADD __ to your spellbook?
//SUMMON, SPELLBOOK, PASS
//TODO: Add "next" text and
case 101: // Loop; wait for a display next status
{
if(bn::keypad::a_pressed())
{
state = 38;
}
bn::core::update();
break;
}
case 38:
{
bn::string<50> first_line_status("WELCOME TO ");
bn::string<50> second_line_status("THE oBOSS WILL HAVE ");
//bn::string<50> third_line_status("");
first_line_status.append(ZoneNames[_get_current_zone()]);
first_line_status.append("!");
second_line_status.append(bn::to_string<5>(BossAttacks[_get_current_zone()]));
second_line_status.append(" kATTACK.");
_display_status(first_line_status, second_line_status, "a:CONTINUE");
state = 39;
break;
}
case 39: // Loop; wait for a press to add new enemy.
{
if(bn::keypad::a_pressed())
{
state = 900;
}
bn::core::update();
break;
}
case 900:
{
if(WaveInfoVector.at(current_wave).attack == -1) //SHIPWRECK
{
_enemy_sprite.set_tiles(bn::sprite_items::enemies.tiles_item().create_tiles(EnemyInfoVector.at(9).tileindex)); //shipwreck is 9, miasma is 10
_enemy_sprite.set_visible(true);
_display_status("SHIPWRECK APPEARS.", "CHOOSE A BANNER TO SALVAGE.", "a:CONTINUE");
state = 26;
}
else if(WaveInfoVector.at(current_wave).attack == -2)
{
_enemy_sprite.set_tiles(bn::sprite_items::enemies.tiles_item().create_tiles(EnemyInfoVector.at(10).tileindex)); //shipwreck is 9, miasma is 10
_enemy_sprite.set_visible(true);
_display_status("A CLOUD OF NOXIOUS MIASMA APPEARS!", "YOU ARE UNABLE TO ESCAPE.", "a:CONTINUE");
state = 33;
}
else //ENEMY & BOSS
{
bn::string<50> display_text_line_one("");
bn::string<50> display_text_line_two("kATTACK = ");
display_text_line_one.append(bn::to_string<27>(EnemyInfoVector.at(WaveInfoVector.at(current_wave).enemy_index).name));
display_text_line_one.append(bn::to_string<27>(" APPEARS!"));
display_text_line_two.append(bn::to_string<5>(WaveInfoVector.at(current_wave).attack));
_display_status(display_text_line_one, display_text_line_two, "a:CONTINUE");
_enemy_sprite.set_tiles(bn::sprite_items::enemies.tiles_item().create_tiles(EnemyInfoVector.at(WaveInfoVector.at(current_wave).enemy_index).tileindex));
//_enemy_sprite.set_visible(true);
state_before_summon_start=900;
enemy_stat_box_active=true;
_update_enemy_stat_box();
state = 1;
}
_update_hud_text();
_update_wave_info_hud_text();
break;
}
case 33: // Loop; wait for A press to loop through miasma
{
if(bn::keypad::a_pressed())
{
current_runes = 0;
player1deck = player1deck_after_miasma;
_display_status("YOUR SPELLBOOK IS DRAINED OF", "POWER, AND YOUR c IS DEPLETED.", "a:CONTINUE");
state = 34;
_update_hud_text();
}
bn::core::update();
break;
}
case 34: // Loop; wait for A press to loop through miasma
{
if(bn::keypad::a_pressed())
{
_display_status("THE MIASMA CLEARS, AND YOU", "NOTICE YOU ARE IN A NEW PLACE.", "a:CONTINUE");
current_wave++;
if(_get_current_zone()==1)
{
//_ocean_bg.delete();
_ocean_bg.set_y(ZONE_TWO_BG_Y);
//bn::core::update();
//_ocean_bg = bn::regular_bg_items::swampbackground.create_bg(0, 0);
//_ocean_bg.set_item(new bn::regular_bg_items::swampbackground.create_bg(0, 0));
//_swamp_bg.set_visible(true);
}
else
{
_ocean_bg.set_y(ZONE_THREE_BG_Y);
//_ocean_bg.set_visible(false);
//_swamp_bg.set_visible(false);
}
_enemy_sprite.set_visible(false);
_update_wave_info_hud_text();
state = 101;
}
bn::core::update();
break;
}
/*case 35: // Loop; wait for A press to loop through miasma
{
if(bn::keypad::a_pressed())
{
// _display_status("YOU FIND A MESSAGE IN A BOTTLE.", "DO YOU WANT TO READ IT?", "a:YES b:NO");
if(_get_current_zone()==1)
{
_display_status("LIGHTS DANCE BETWEEN TREES.", "EYES GLINT IN THE DARK.", "a:CONTINUE");
}
else{ // zone = 2
_display_status("YOU ARE SURROUNDED BY STARS.", "COULD YOUR JOURNEY BE NEAR ITS END?", "a:CONTINUE");
}
state = 900;
}
bn::core::update();
break;
}*/
/*case 36: // Loop; wait for A press to loop through miasma
{
if(bn::keypad::b_pressed())
{
state = 900;
}
else if(bn::keypad::a_pressed())
{
if(_get_current_zone()==1)
{
state = 37;
}
else{
}
}
bn::core::update();
break;
}*/
case 26: // Loop; wait for A press to start shipwreck phase
{
if(bn::keypad::a_pressed())
{
state = 27;
}
bn::core::update();
break;
}
case 27: // intro to shipwreck phase
{
//_display_status("ud:MOVE, a:SELECT");
//0-7 are owl upgrades, 8-15 are nonowl upgrades
int upgrade_option_one_index = bn::abs(random_num) % DeckOfOwlUpgrades.size(); //5
random_num = random_generator.get();
upgrade_option_one = DeckOfOwlUpgrades.at(upgrade_option_one_index);
DeckOfOwlUpgrades.erase(DeckOfOwlUpgrades.begin()+upgrade_option_one_index);
int upgrade_option_two_index = bn::abs(random_num) % DeckOfNonOwlUpgrades.size();
random_num = random_generator.get();
upgrade_option_two = DeckOfNonOwlUpgrades.at(upgrade_option_two_index) + 8;
DeckOfNonOwlUpgrades.erase(DeckOfNonOwlUpgrades.begin() + upgrade_option_two_index);
state = 10027;
break;
}
//TODO: Check that whenever I interface with a vector or array of ints, I am interfacing with the contents of the array/vector, rather than the index
case 10027:
{
//_generate_virt_menu(2, _generate_name_from_upgrade_index(upgrade_option_one), _generate_name_from_upgrade_index(upgrade_option_two),"");
_generate_virt_menu(3, _generate_name_from_upgrade_index(upgrade_option_one), _generate_name_from_upgrade_index(upgrade_option_two),"SPELLBOOK");
//bn::core::update();
state = 28;
break;
}
//todo: check that randomness happens after every random number get
case 28: // SHIPWRECK LOOP!
{
_navigate_through_virt_menu(); // todo : make this its own state
if(menu_position==0)
{
_display_status(_generate_first_upgrade_description_from_upgrade_index(upgrade_option_one), _generate_second_upgrade_description_from_upgrade_index(upgrade_option_one),"ud:MOVE, a:SELECT");
}
else if(menu_position==1)
{
_display_status(_generate_first_upgrade_description_from_upgrade_index(upgrade_option_two), _generate_second_upgrade_description_from_upgrade_index(upgrade_option_two),"ud:MOVE, a:SELECT");
}
else if(menu_position==2) // GO TO SPELLBOOK STATE
{
_display_status("ud:MOVE, a:SELECT");
}
if(bn::keypad::a_pressed())
{
if(menu_position==2)
{//show spellbook!
state_before_spellbook=28;
state=23;
_clear_virt_menu();
}
else
{
_enemy_sprite.set_visible(false);
bn::string<50> display_text_line_one("YOU PICKED ");
//_display_status(_generate_first_upgrade_description_from_upgrade_index(6),_generate_second_upgrade_description_from_upgrade_index(6));
if(menu_position==0)
{
_clear_virt_menu();
_research_upgrade(upgrade_option_one);
display_text_line_one.append(_generate_name_from_upgrade_index(upgrade_option_one));
display_text_line_one.append(".");
_display_status(display_text_line_one, "YOU SAIL ON.", "a:CONTINUE");
state = 29;
}
else if(menu_position==1)
{
_clear_virt_menu();
_research_upgrade(upgrade_option_two);
display_text_line_one.append(_generate_name_from_upgrade_index(upgrade_option_two));
display_text_line_one.append(".");
_display_status(display_text_line_one, "YOU SAIL ON.", "a:CONTINUE");
state = 29;
}
}
}
bn::core::update();
break;
}
case 29:
{
if(bn::keypad::a_pressed())
{
current_wave+=1;
state = 900;
}
bn::core::update();
break;
}
case 1: // Loop; wait for A press to start summon phase
{
if(bn::keypad::a_pressed())
{
state = 10001;
}
bn::core::update();
break;
}
case 10001:
{
//As you remove owls from your tree, you'll modify the player1deck. So save it here BEFORE modifications so we'll have access to it later
player1deck_at_start_of_round = player1deck;
AmountMercOnSale.fill(0);
player_stat_box_active=true;
state = 10002;
break;
}
case 10002:
{
_generate_virt_menu(3, "SUMMON", "SPELLBOOK", "FIGHT!");
if(state_before_summon_start==900) // came from game start or after shopping
{
_display_status("NEW ROUND START! SUMMONING PHASE","ud:MOVE, a:SELECT");
}
else if(state_before_summon_start==22) // came from explosion
{
_display_status("TRY, TRY AGAIN...","ud:MOVE, a:SELECT");
}
else if(state_before_summon_start==23 || state_before_summon_start==37) // came from spellbook
{
_display_status("ud:MOVE, a:SELECT");
}
_update_hud_text();
state = 3;
break;
}
case 3: //Player1 Turn Loop
{
_navigate_through_virt_menu();//TODO: Make into separate state!
if(bn::keypad::a_pressed())
{
if(menu_position==0)
{
if(player1deck.size()>0){
//DRAW A CARD!!!
int index_to_remove = bn::abs(random_num) % player1deck.size();
random_num = random_generator.get();
int weight_to_add = CardInfoVector.at(player1deck.at(index_to_remove)).weight;
int power_to_add = CardInfoVector.at(player1deck.at(index_to_remove)).powerone; //TOMCOMEBACK
int runes_to_add = CardInfoVector.at(player1deck.at(index_to_remove)).gatherone;
bn::string<50> first_line_status("SUMMONED ");
bn::string<50> second_line_status("");
bn::string<50> third_line_status("");
first_line_status.append(bn::to_string<18>(CardInfoVector.at(player1deck.at(index_to_remove)).name));
current_weight=current_weight+weight_to_add;
if(CardInfoVector.at(player1deck.at(index_to_remove)).weight==1)
{
first_line_status.append("!!!");
}
else if(CardInfoVector.at(player1deck.at(index_to_remove)).weight==2)
{
first_line_status.append("!!!!!!");
}
else
{
first_line_status.append(".");
}
if(player1deck.at(index_to_remove)==4)//4 is spear
{
int percentageroll = bn::abs(random_num) % 100; //0-99
random_num = random_generator.get();
if(percentageroll < CardInfoVector.at(player1deck.at(index_to_remove)).powertwopercentage)
{
second_line_status.append("CRITICAL HIT! k+");
second_line_status.append(bn::to_string<4>(CardInfoVector.at(player1deck.at(index_to_remove)).powertwo));
current_power = current_power + CardInfoVector.at(player1deck.at(index_to_remove)).powertwo;
}
else{
second_line_status.append("NO CRITICAL HIT THIS TIME. k+");
second_line_status.append(bn::to_string<4>(CardInfoVector.at(player1deck.at(index_to_remove)).powerone));
current_power = current_power + CardInfoVector.at(player1deck.at(index_to_remove)).powerone;
}
}
else if(player1deck.at(index_to_remove)==0 && IsUpgradeResearched[0]== true) // ugh this is awful. it's the mage, fyi
{
int percentageroll = bn::abs(random_num) % 100; //0-99
random_num = random_generator.get();
if(percentageroll < CardInfoVector.at(player1deck.at(index_to_remove)).gathertwopercentage)
{
second_line_status.append("STROKE OF FORTUNE. c+");
second_line_status.append(bn::to_string<4>(CardInfoVector.at(player1deck.at(index_to_remove)).gathertwo));
runes_which_might_disappear = runes_which_might_disappear + CardInfoVector.at(player1deck.at(index_to_remove)).gathertwo;
}
else{
second_line_status.append("STROKE OF MISFORTUNE. c+");
second_line_status.append(bn::to_string<4>(CardInfoVector.at(player1deck.at(index_to_remove)).gatherone));
runes_which_might_disappear = runes_which_might_disappear + CardInfoVector.at(player1deck.at(index_to_remove)).gatherone;
}
}
else if(player1deck.at(index_to_remove)==8) //8 is alchemist
{
int percentageroll = bn::abs(random_num) % 100; //0-99
random_num = random_generator.get();
if(percentageroll < CardInfoVector.at(player1deck.at(index_to_remove)).gathertwopercentage)
{
second_line_status.append("HER EXPERIMENT FAILS! c+");
second_line_status.append(bn::to_string<4>(CardInfoVector.at(player1deck.at(index_to_remove)).gathertwo));
runes_which_might_disappear = runes_which_might_disappear + CardInfoVector.at(player1deck.at(index_to_remove)).gathertwo;
}
else{
second_line_status.append("HER EXPERIMENT SUCCEEDS. c+");
second_line_status.append(bn::to_string<4>(CardInfoVector.at(player1deck.at(index_to_remove)).gatherone));
runes_which_might_disappear = runes_which_might_disappear + CardInfoVector.at(player1deck.at(index_to_remove)).gatherone;
}
}
else if(player1deck.at(index_to_remove)==9)//9 is merchant
{
//int percentageroll = bn::abs(random_num) % 100; //0-99
//random_num = random_generator.get();
runes_which_might_disappear = runes_which_might_disappear + CardInfoVector.at(player1deck.at(index_to_remove)).gatherone;
second_line_status.append("c+");
second_line_status.append(bn::to_string<4>(CardInfoVector.at(player1deck.at(index_to_remove)).gatherone));
second_line_status.append(". OWLS");
//second_line_status.append(bn::to_string<4>(AmountMercOnSale[0]));
SaleMercDeckToDrawFrom.clear();
for(int i =0; i< MERCS_FOR_SALE; i++)
{
SaleMercDeckToDrawFrom.push_back(i);
}
for(int i =0; i<2; i++)
{
int card_to_draw= bn::abs(random_num) % SaleMercDeckToDrawFrom.size();
random_num = random_generator.get();
second_line_status.append(" #");
second_line_status.append(bn::to_string<4>(1+SaleMercDeckToDrawFrom.at(card_to_draw)));
AmountMercOnSale[SaleMercDeckToDrawFrom.at(card_to_draw)] += 2;
//Delete the drawn card from the deck
SaleMercDeckToDrawFrom.erase(SaleMercDeckToDrawFrom.begin()+card_to_draw);
//spin the random number generator! (TODO: experiment with not spinning it and instead just using the same number but modulating it down a bunch; would be faster)
}
second_line_status.append(" CHEAP THIS ROUND");
}
else if(player1deck.at(index_to_remove)==10)//10 is goblin
{
int goblin_attack = 1 + (bn::abs(random_num) % 8);
random_num = random_generator.get();
current_power = current_power + goblin_attack;
//second_line_status.append("ROLLED ");
//second_line_status.append(bn::to_string<4>(goblin_attack));
//second_line_status.append(" ON THE D8. k+");
second_line_status.append("D8 RESULT: k+");
second_line_status.append(bn::to_string<4>(goblin_attack));
}
else
{
current_power=current_power+power_to_add;
runes_which_might_disappear=runes_which_might_disappear+runes_to_add;
//_display_status(bn::string<40>("You drew a ").append(bn::to_string<2>(weight_to_add)));
//_display_status(bn::string<40>("You drew a ").append(CardInfoVector.at(player1deck.at(index_to_remove)).name);
second_line_status.append(_generate_description_from_owl_index(player1deck.at(index_to_remove),false));
}
if(IsUpgradeResearched[8])
{
bn::string<20> dtwenty_message(" D20=");
//dtwenty_message.append(" D20=");
int dtwentyroll = 1 + (bn::abs(random_num) % 20); //1-20
random_num = random_generator.get();
dtwenty_message.append(bn::to_string<4>(dtwentyroll));
if(dtwentyroll==20)
{
current_power+=10;
dtwenty_message.append("!!!! k+10");
}
if(player1deck.at(index_to_remove)==2 || player1deck.at(index_to_remove)==3 || player1deck.at(index_to_remove)==7) //If it's an energy surge, put it on the second line, since we don't have enough room otherwise.
{
second_line_status.append(dtwenty_message);
}
else
{
first_line_status.append(dtwenty_message);
}
}
_update_hud_text();
if(current_weight>max_boat_weight){
_selection_cursor_sprite.set_visible(false);
third_line_status.append("iSTATIC TOO HIGH! a:CONTINUE");
state = 22;
}
else{
//remain in this state
third_line_status.append("ud:MOVE, a:SELECT");
}
//display status
_display_status(first_line_status,second_line_status,third_line_status);
//Display sprite
//newspriteposition= vector.at(size-1).position + 5
bn::sprite_ptr NewTableauImg = bn::sprite_items::knight_owls.create_sprite(last_tableau_x_pos, last_tableau_y_pos);
NewTableauImg.set_tiles(bn::sprite_items::knight_owls.tiles_item().create_tiles(CardInfoVector.at(player1deck.at(index_to_remove)).tileindex));//player1deck.at(index_to_remove).tileindex));
Player1Tableau.push_back(NewTableauImg);//bn::sprite_items::knight_owls.create_sprite(last_tableau_x_pos, 0));
//Player1Tableau.at().set_tiles(bn::sprite_items::knight_owls.tiles_item().create_tiles(20));
last_tableau_x_pos+=5;
if(Player1Tableau.size()%15==0)
{
last_tableau_x_pos=-110;
last_tableau_y_pos+=4;
}
//Delete the drawn card from the deck
player1deck.erase(player1deck.begin()+index_to_remove);
}
else{
_display_status("ERROR: NO MORE ITEMS","THIS SHOULDN'T HAPPEN");
}
}
else if(menu_position==1)
{//show spellbook!
state_before_spellbook=3;
state=23;
}
else if(menu_position==2) //FIGHT!