-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproject4.pde
1389 lines (1313 loc) · 44.3 KB
/
project4.pde
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
//<>//
//Collin Dutter
//Brandon Kelley
//Allison Lee
/* Hi there— this is Allison!
> Transformation: Our Pikachu evolves from a Pikachu to a Raichu!
> Two different animated characters: All the pokemon, the player sprite
> Animated components: Lots of the backgrounds, sequences, sprites themselves, attacks, etc. (there are
a lot of classes so it'll probably bebetter not to name it all
> Coherent background: The forest and grass are drawn with a loop. The bubbles at the beginning are also
drawn with a loop. The evolution sequence also uses loops.
> Beginning: lost in the forest
Middle: battle
End: get out!
> Interesting: Hopefully, it was fun to play?
We all sort of edited each other's code, but for the most part the work is split up like this:
> Brandon did the overworld sprites and walking logic (like keypressed), as well as the steps counting to the encounter.
> Collin did the battle logic (making the moves work and displaying attack names on the
screen, number values for hit points etc (and there sure was a lot and lot of code for this)
> I dealt with all the visual components and animations of the sprites (attack moves when the attacks are chosen
and title and evolution sequences since drawing is fun for me
*/
Screen currentScreen;
boolean playopening = false;
boolean openingdone = false;
void setup() {
size(600, 400);
currentScreen = new OpeningScreen();
}
void draw() {
currentScreen.drawScreen();
}
abstract class Screen {
//declare universal game font
private PFont gameFont;
public Screen() {
//create and load font into game
gameFont = createFont("res/sapphirefont.ttf", 32);
textFont(gameFont);
}
public abstract void drawScreen();
}
class CreditsScreen extends Screen {
public void drawScreen() {
background(0);
textAlign(CENTER);
textSize(32);
text("Thank you for playing!", width/2, height/2-64);
text("An interactive story by: ", width/2, height/2);
text("Collin Dutter ", width/2, height/2+32);
text("Brandon Kelley", width/2, height/2+64);
text("Allison Lee", width/2, height/2+96);
textAlign(LEFT);
}
}
void keyPressed() {
//if current screen is the titlescreen, change to world screen when pressing enter
if (currentScreen instanceof OpeningScreen) {
if (keyCode == ENTER) {
playopening = true;
if (playopening && openingdone) {
currentScreen = new WorldScreen(true);
}
} else if (keyCode == TAB)
currentScreen = new WorldScreen(true);
}
if (currentScreen instanceof BattleScreen) {
final BattleScreen bs = ((BattleScreen)currentScreen);
if (keyCode == ENTER) {
//if current menu is an infobar
if (bs.currentMenu instanceof InfoBar) {
//if next infobar is nothing, skip it, and switch to decision bar
if (bs.infoBarQueue.get(bs.menuIndex+1) == null) {
bs.menuIndex+=2;
bs.currentMenu = new DecisionBar(bs.ash.moves, bs.ash.pikachu.name);
//otherwise go to the next infobar
} else {
if (bs.infoBarQueue.get(bs.menuIndex).message == "")
return;
bs.menuIndex++;
bs.currentMenu = bs.infoBarQueue.get(bs.menuIndex);
// bs.currentMenu.doAction();
}
}
//if current menu is a decision bar, display appropriate message, or change it to attack bar
else if (bs.currentMenu instanceof DecisionBar) {
int row = ((DecisionBar)bs.currentMenu).selectorRow;
int col = ((DecisionBar)bs.currentMenu).selectorCol;
if (row == 0 && col == 0) {
bs.currentMenu = new AttackBar(bs.ash.pikachu.attacks);
return;
} else if (row == 0 && col == 1)
bs.infoBarQueue.add(new InfoBar("Items not allowed!"));
else if (row == 1 && col == 1)
bs.infoBarQueue.add(new InfoBar("You cannot run!"));
else if (row == 1 && col == 0)
bs.infoBarQueue.add(new InfoBar("You have no other Pokemon!"));
bs.infoBarQueue.add(null);
bs.currentMenu = bs.infoBarQueue.get(bs.menuIndex);
}
//if current menu is an attack bar, deal appropriate damage to enemy, and recieve damage
else if (bs.currentMenu instanceof AttackBar) {
//player attacking
final Pokemon.Attack attack = bs.ash.pikachu.attacks[((AttackBar)bs.currentMenu).selectorRow][((AttackBar)bs.currentMenu).selectorCol];
if (attack.pp > 0) {
bs.infoBarQueue.add(new InfoBar("Pikachu used " + attack.name + "!") {
public void doAction() {
//bs.enemies[bs.enemyIndex].health-=attack.damage;
attack.pp--;
bs.drawAttack = true;
bs.playerAttackStart = millis();
bs.playerAttackToDraw = attack;
bs.ash.pikachu.xp+=5;
}
}
);
bs.infoBarQueue.add(new InfoBar("It was super effective!"));
} else {
bs.infoBarQueue.add(new InfoBar("Out of PP!"));
}
bs.enemies[bs.enemyIndex].health-=attack.damage;
if (bs.ash.pikachu.xp >= bs.ash.pikachu.maxXP) {
bs.ash.pikachu.xp = 0;
bs.ash.pikachu.level++;
bs.ash.pikachu.maxXP+=25;
bs.ash.pikachu.health = bs.ash.pikachu.MAX_HEALTH;
bs.infoBarQueue.add(new InfoBar(bs.ash.pikachu.name + " has leveled up!"));
}
//enemy attacking
final Pokemon.Attack enemyAttack = bs.enemies[bs.enemyIndex].attacks[(int)random(0, 2)] [(int)random(0, 2)];
if (bs.enemies[bs.enemyIndex].health > 0) {
bs.infoBarQueue.add(new InfoBar(bs.enemies[bs.enemyIndex].name + " used " + enemyAttack.name + "!") {
public void doAction() {
bs.ash.pikachu.health -= enemyAttack.damage;
enemyAttack.pp--;
bs.drawEnemyAttack = true;
bs.enemyAttackStart = millis();
bs.enemyAttackToDraw = enemyAttack;
}
}
);
}
//if the enemy is dead
else if (bs.enemies[bs.enemyIndex].health <= 0) {
//create a message indicating it has died--potentially end game
if (bs.enemyIndex == 0)
bs.infoBarQueue.add(new InfoBar(bs.enemies[bs.enemyIndex].name + " has fainted!") {
public void doAction() {
bs.drawEnemyExit = true;
frameCount = 0;
}
}
);
else if (bs.enemyIndex == 1) {
bs.infoBarQueue.add(new InfoBar(bs.enemies[bs.enemyIndex].name + " has fainted!")
{
public void doAction() {
bs.drawEnemyExit = true;
frameCount = 0;
}
}
);
bs.infoBarQueue.add(new InfoBar(" ") {
public void doAction() {
bs.fadingOut = true;
}
}
);
}
bs.infoBarQueue.add(new InfoBar("Wild " + bs.enemies[bs.enemyIndex+(bs.enemyIndex < 1? 1 :0)].name + " has appeared!") {
public void doAction() {
//change out the pokemon
if (bs.enemyIndex < 1)
bs.enemyIndex++;
bs.drawEnemyEntrance = true;
frameCount = 0;
}
}
);
}
bs.infoBarQueue.add(null);
bs.currentMenu = bs.infoBarQueue.get(bs.menuIndex);
}
//do the current info screena action
bs.currentMenu.doAction();
}
//handles menu navigation on attack and decision bar menus
if (bs.currentMenu instanceof AttackBar) {
AttackBar ab = ((AttackBar)bs.currentMenu);
if (keyCode == LEFT && ab.selectorCol > 0)
ab.selectorCol--;
if (keyCode == RIGHT && ab.selectorCol < 1 )
ab.selectorCol++;
if (keyCode == UP && ab.selectorRow > 0 )
ab.selectorRow--;
if (keyCode == DOWN && ab.selectorRow < 1)
ab.selectorRow++;
} else if (bs.currentMenu instanceof DecisionBar) {
DecisionBar db = ((DecisionBar)bs.currentMenu);
if (keyCode == LEFT && db.selectorCol > 0)
db.selectorCol--;
if (keyCode == RIGHT && db.selectorCol < 1 )
db.selectorCol++;
if (keyCode == UP && db.selectorRow > 0 )
db.selectorRow--;
if (keyCode == DOWN && db.selectorRow < 1)
db.selectorRow++;
}
}
//allow key press for worldscreen
if (currentScreen instanceof WorldScreen)
worldKeyPress = true;
}
class BattleScreen extends Screen {
public boolean drawIntroText;
public boolean drawAttack, drawEnemyAttack;
public boolean drawPlayerEntrance = true, drawEnemyEntrance = true, drawEnemyExit;
public float playerAttackStart, enemyAttackStart;
public Pokemon.Attack enemyAttackToDraw, playerAttackToDraw;
private Pokemon[] enemies;
public Player ash;
private PImage playerHealthUI, enemyHealthUI;
private PImage whiteScreen;
public float opacity, opacity2 = 255;
public boolean fadingOut;
private UIComponent currentMenu;
public int menuIndex = 0;
public ArrayList<InfoBar> infoBarQueue;
public int enemyIndex = 0;
public BattleScreen() {
//bottomBarUI = loadImage("bottombar.png");
playerHealthUI = loadImage("res/UI/playerhealth.png");
enemyHealthUI = loadImage("res/UI/enemyhealth.png");
whiteScreen = loadImage("res/op/12_white.png");
ash = new Player();
drawIntroText = true;
enemies = new Pokemon[2];
enemies[enemyIndex] = new Squirtle();
enemies[1] = new Bulbasaur();
infoBarQueue = new ArrayList<InfoBar>(50);
infoBarQueue.add(new InfoBar("Wild " + enemies[enemyIndex].name + " appeared!") {
void doAction() {
drawEnemyEntrance = true;
}
}
);
infoBarQueue.add(null);
currentMenu = infoBarQueue.get(0);
frameCount = 0;
}
public void drawScreen() {
frameRate(25);
drawBackground();
ash.pikachu.drawPokemon();
enemies[enemyIndex].drawPokemon();
drawHealthIndicators();
//draws pokemon attacks
if (drawAttack) {
ash.pikachu.pikachubounce = true;
if (ash.pikachu.drawAttack(playerAttackToDraw, playerAttackStart) == false) {
drawAttack = false;
ash.pikachu.pikachubounce = false;
}
}
if (drawEnemyAttack) {
enemies[enemyIndex].enemybounce = true;
if (enemies[enemyIndex].drawAttack(enemyAttackToDraw, enemyAttackStart) == false) {
drawEnemyAttack = false;
enemies[enemyIndex].enemybounce = false;
}
}
currentMenu.drawUIComponent();
if (drawPlayerEntrance) {
ash.pikachu.x+=ash.dx*.1;
if (frameCount >= 20)
drawPlayerEntrance = false;
}
if (drawEnemyEntrance) {
enemies[enemyIndex].x-=enemies[enemyIndex].dx*.1;
if (frameCount >= 21)
drawEnemyEntrance = false;
} else if (drawEnemyExit) {
enemies[enemyIndex].x+=enemies[enemyIndex].dx*.1;
if (frameCount >=21)
drawEnemyExit = false;
}
if (fadingOut && opacity <= 270) {
tint(255, opacity);
image(whiteScreen, 0, 0);
opacity+=20;
} else if (opacity >=270) {
image(whiteScreen, 0, 0);
currentScreen = new WorldScreen(false);
}
tint(255, 255);
}
//draws health indicators
private void drawHealthIndicators() {
//health bars
fill(243, 212, 65);
noStroke();
rect(437, 225, ash.pikachu.health*111/ash.pikachu.MAX_HEALTH, 15);
rect(134, 70, enemies[enemyIndex].health*111/enemies[enemyIndex].MAX_HEALTH, 15);
//xp bar
fill(18, 208, 241);
rect(396, 262, ash.pikachu.xp*165/ash.pikachu.maxXP, 12);
image(playerHealthUI, 0, 0);
image(enemyHealthUI, 0, 0);
//names and levels
textSize(33);
fill(88, 79, 57);
text(enemies[enemyIndex].name, 48, 60);
text(ash.pikachu.name, 355, 220);
text(ash.pikachu.level, 530, height/2+17);
text(enemies[enemyIndex].level, 230, height/11+23);
}
//draws greenish background
private void drawBackground() {
background(#D4F2D0);
strokeWeight(4);
stroke(#D9F7D5);
for (int i = 0; i < 25; i++)
line(0, i*height/25, width, i*height/25);
strokeWeight(1);
noStroke();
fill(#A3F273);
ellipse(width*3/4-10, height*3/8+10, width/2, height/5);
ellipse(width/4+10, height*6/8-10, width/2, height/5);
fill(#79D081);
ellipse(width*3/4-10, height*3/8+10, width/2-20, height/5-20);
ellipse(width/4+10, height*6/8-10, width/2-20, height/5-20);
stroke(0);
}
}
public class UIComponent {
public PImage sprite;
public UIComponent(String fileName) {
sprite = loadImage(fileName);
}
public void drawUIComponent() {
image(sprite, 0, 0);
}
void doAction() {
}
}
public class InfoBar extends UIComponent {
String message;
public InfoBar(String message) {
super("res/UI/infobar.png");
this.message = message;
}
public void drawUIComponent() {
if (message == "")
return;
super.drawUIComponent();
fill(255);
textSize(33);
text(message, 40, 330);
}
public void doAction() {
}
}
public class AttackBar extends UIComponent {
public int selectorCol, selectorRow;
public Pokemon.Attack[][] attacks;
public AttackBar(Pokemon.Attack[][] attacks) {
super("res/UI/attackbar.png");
this.attacks = attacks;
}
public void drawUIComponent() {
super.drawUIComponent();
fill(0);
textSize(33);
for (int row = 0; row < 2; row++)
for (int col = 0; col < 2; col++)
text(attacks[row][col].name, 30 + col*210, 330 + row*40);
noFill();
strokeWeight(2);
stroke(255, 0, 0);
rect(30 + selectorCol*210, 300 + selectorRow*40, textWidth(attacks[selectorRow][selectorCol].name), 30);
noFill();
text("PP", 460, 335);
textSize(32);
text(attacks[selectorRow][selectorCol].pp + "/" + attacks[selectorRow][selectorCol].maxPP, 500, 335);
textSize(33);
text("Normal", 460, 375);
}
public void doAction() {
}
}
public class DecisionBar extends UIComponent {
public int selectorCol, selectorRow;
public String[][] moves;
public String name;
public DecisionBar(String[][] moves, String name) {
super("res/UI/decisionbar.png");
this.moves = moves;
this.name = name;
}
void drawUIComponent() {
super.drawUIComponent();
fill(0);
textSize(35);
for (int row = 0; row < 2; row++) {
for (int col = 0; col < 2; col++) {
text(moves[row][col], 375 + col*130, 330 + row*40);
}
}
fill(255);
text("What should \n"+ name + " do?", 40, 330);
noFill();
strokeWeight(2);
stroke(255, 0, 0);
rect(375 + selectorCol * 130, 300 + selectorRow*40, textWidth(moves[selectorRow][selectorCol]), 30);
}
}
class Player {
private PImage sprite;
public float x, y;
public float dx;
public Pikachu pikachu;
//list of available moves for player
public final String[][] moves = {
{
"FIGHT", "ITEM"
}
,
{
"POKeMON", "RUN"
}
};
public Player() {
sprite = loadImage("res/ash/ash.png");
x = -50;
y = 150;
dx = 100;
pikachu = new Pikachu();
}
public void drawPlayer() {
image(sprite, x, y, 16*5, 32*7);
}
}
abstract class Pokemon {
public boolean enemybounce;
public int health;
public int MAX_HEALTH;
protected PImage sprite;
protected float x, y;
protected float dx, dy;
public String name;
public Attack[][] attacks;
public int level;
public Pokemon() {
dx = 100;
}
public class Attack {
public String name;
public int damage;
public int maxPP;
public int pp;
public Attack(String name, int damage, int maxPP) {
this.name = name;
this.damage = damage;
this.maxPP = maxPP;
pp = maxPP;
}
}
public boolean drawAttack(Attack at, float start) {
return false;
}
public void drawPokemon() {
//image(sprite, x, y, 16*5, 32*5);
}
}
class Pikachu extends Pokemon {
public boolean pikachubounce;
public int maxXP;
public int xp;
private int radius;
private int delta = 1;
private float lineX = 230;
private float lineY = 210;
private float dx1 = 30;
private float dy1 = -1.5;
private float dx2 = -0.75;
private float dy2 = -15;
private float theta;
private float electroX, electroY;
private int attackindex = 14;
private int idleindex = 34;
private int thunderboltindex = 8;
private int growlindex = 5;
private int thundershockindex = 6;
private int electroballindex = 10;
private PImage[] pikachuidle = new PImage[idleindex];
private PImage[] pikachuattack = new PImage[attackindex];
private PImage[] thunderbolt = new PImage[thunderboltindex];
private PImage[] thundershock = new PImage[thundershockindex];
private PImage[] growl = new PImage[growlindex];
private PImage[] electroball = new PImage[electroballindex];
public Pikachu() {
for (int i = 0; i<pikachuidle.length; i++) {
pikachuidle[i] = loadImage("res/pokemon/pikachu/pikachuidle" + i + ".png");
}
for (int j = 0; j<pikachuattack.length; j++) {
pikachuattack[j] = loadImage("res/pokemon/pikachu/pikachu" + j + ".png");
}
for (int a = 0; a<thunderbolt.length; a++) {
thunderbolt[a] = loadImage("res/attack/thunderbolt/thunderbolt_" + a + ".png");
}
for (int b = 0; b<growl.length; b++) {
growl[b] = loadImage("res/attack/growl/growl_" + b + ".png");
}
for (int c = 0; c<thundershock.length; c++) {
thundershock[c] = loadImage("res/attack/thundershock/thundershock_" + c + ".png");
}
for (int d = 0; d<electroball.length; d++) {
electroball[d] = loadImage("res/attack/electroball/electroball_" + d + ".png");
}
x = -110;
y = 160;
dx = 100;
level = 4;
name = new String("PIKACHU");
maxXP = 100;
xp = 80;
MAX_HEALTH = 100;
health = MAX_HEALTH;
attacks = new Attack[][] {
{
new Attack("ELECTRO BALL", 15, 25), new Attack("THUNDERBOLT", 15, 25)
}
,
{
new Attack("THUNDER SHOCK", 15, 25), new Attack("QUICK ATTACK", 15, 25)
}
};
}
public void drawPokemon() {
if (pikachubounce) {
bounce();
} else {
idle();
}
}
public void idle() {
idleindex = (idleindex < 34 ? idleindex+1 : idleindex)%pikachuidle.length;
image(pikachuidle[idleindex], x, y);
}
public void bounce() {
attackindex = (attackindex < 14 ? attackindex+1 : attackindex)%pikachuattack.length;
image(pikachuattack[attackindex], x, y);
}
public boolean drawAttack(Attack at, float start) {
fill(color(random(0, 255), random(0, 255), random(0, 255)));
if (at.name == "THUNDERBOLT") {
frameRate(30);
if (millis () - start < 500) {
thunderboltindex = (thunderboltindex < 8 ? thunderboltindex+1 : thunderboltindex)%thunderbolt.length;
image(thunderbolt[thunderboltindex], 350, 20);
return true;
}
} else if (at.name == "QUICK ATTACK") {
if (millis () - start < 500) {
growlindex = (growlindex < 5 ? growlindex+1 : growlindex)%growl.length;
imageMode(CENTER);
image(growl[growlindex], 430, 120);
imageMode(CORNER);
return true;
}
} else if (at.name == "THUNDER SHOCK") {
if (millis () - start < 500) {
thundershockindex = (thundershockindex < 6 ? thundershockindex+1 : thundershockindex)%thundershock.length;
imageMode(CENTER);
image(thundershock[thundershockindex], 430, 120);
imageMode(CORNER);
return true;
}
} else if (at.name == "ELECTRO BALL") {
if (millis() - start < 1500) {
if (millis () - start < 400) {
electroX = 230;
electroY = 210;
} else if (millis() - start < 1000) {
//this mumbo jumbo makes figures out velocities to make it get to destination in exactly 600 ms.
electroX += (430-230)/(frameRate*3/5.0);
electroY += (100-210)/(frameRate*3/5.0);
} else {
electroX = 430;
electroY = 100;
}
electroballindex = (electroballindex < 10 ? electroballindex+1 : electroballindex)%electroball.length;
imageMode(CENTER);
image(electroball[electroballindex], electroX, electroY);
imageMode(CORNER);
return true;
}
}
return false;
}
}
class Bulbasaur extends Pokemon {
private float theta;
private float leafX, leafY;
private float radius;
private int attackindex = 20;
private int idleindex = 20;
private int seedindex = 14;
private int growlindex = 5;
private int leafindex = 7;
private int vineindex = 19;
private PImage[] bulbasauridle = new PImage[idleindex];
private PImage[] bulbasaurattack = new PImage[attackindex];
private PImage[] seed = new PImage[seedindex];
private PImage[] growl = new PImage[growlindex];
private PImage[] leaf = new PImage[leafindex];
private PImage[] vine = new PImage[vineindex];
public Bulbasaur() {
name = new String("BULBASAUR");
MAX_HEALTH = 90;
health = MAX_HEALTH;
level = 5;
x = 605;
y = 70;
attacks = new Attack[][] {
{//tackle vine whip leech seed razor leaf
new Attack("TACKLE", 15, 25), new Attack("VINE WHIP", 15, 25)
}
,
{
new Attack("LEECH SEED", 15, 25), new Attack("RAZOR LEAF", 15, 25)
}
};
for (int i = 0; i<bulbasauridle.length; i++) {
bulbasauridle[i] = loadImage("res/pokemon/bulbasaur/bulbasauridle" + i + ".png");
}
for (int j = 0; j<bulbasaurattack.length; j++) {
bulbasaurattack[j] = loadImage("res/pokemon/bulbasaur/bulbasaur" + j + ".png");
}
for (int a = 0; a < seed.length; a++) {
seed[a] = loadImage("res/attack/seed/seed_" + a + ".png");
}
for (int b = 0; b < growl.length; b++) {
growl[b] = loadImage("res/attack/growl/growl_" + b + ".png");
}
for (int c = 0; c < leaf.length; c++) {
leaf[c] = loadImage("res/attack/leaf/leaf_" + c + ".png");
}
for (int d = 0; d < vine.length; d++) {
vine[d] = loadImage("res/attack/vine/vine_" + d + ".png");
}
}
public void bounce() {
attackindex = (attackindex < 20 ? attackindex+1 : attackindex)%bulbasaurattack.length;
image(bulbasaurattack[attackindex], x, y);
}
public void idle() {
idleindex = (idleindex < 20 ? idleindex+1 : idleindex)%bulbasauridle.length;
image(bulbasauridle[idleindex], x, y);
}
public void drawPokemon() {
if (enemybounce) {
bounce();
} else {
idle();
}
}
public boolean drawAttack(Attack at, float start) {
fill(color(random(0, 255), random(0, 255), random(0, 255)));
if (at.name == "TACKLE") {
if (millis () - start < 500) {
growlindex = (growlindex < 5 ? growlindex+1 : growlindex)%growl.length;
imageMode(CENTER);
image(growl[growlindex], 180, 230);
imageMode(CORNER);
return true;
}
} else if (at.name == "VINE WHIP") {
if (millis () - start < 1300) {
vineindex = (vineindex < 19 ? vineindex+1 : vineindex)%vine.length;
image(vine[vineindex], 60, 100);
return true;
}
} else if (at.name == "LEECH SEED") {
if (millis () - start < 1000) {
seedindex = (seedindex < 14 ? seedindex+1 : seedindex)%seed.length;
image(seed[seedindex], 50, 200);
image(seed[seedindex], 130, 190);
return true;
}
} else if (at.name == "RAZOR LEAF") {
if (millis() - start < 900) {
if (millis () - start < 300) {
leafX = 430;
leafY = 100;
} else if (millis() - start < 900) {
//this mumbo jumbo makes figures out velocities to make it get to destination in exactly 600 ms.
leafX += (230-430)/(frameRate*3/5.0);
leafY += (210-100)/(frameRate*3/5.0);
} else {
leafX = 230;
leafY = 210;
}
leafindex = (leafindex < 7 ? leafindex+1 : leafindex)%leaf.length;
imageMode(CENTER);
image(leaf[leafindex], leafX, leafY);
imageMode(CORNER);
return true;
}
}
return false;
}
}
class Squirtle extends Pokemon {
private float radius;
private float theta;
private int waterX, waterY;
private int attackindex = 22;
private int idleindex = 32;
private int biteindex = 15;
private int growlindex = 5;
private int waterindex = 5;
private int bubbleindex = 10;
private PImage[] squirtleidle = new PImage[idleindex];
private PImage[] squirtleattack = new PImage[attackindex];
private PImage[] bite = new PImage[biteindex];
private PImage[] growl = new PImage[growlindex];
private PImage[] water = new PImage[waterindex];
private PImage[] bubble = new PImage[bubbleindex];
public Squirtle() {
name = new String("SQUIRTLE");
MAX_HEALTH = 90;
level = 4;
health = MAX_HEALTH;
x = 600;
y = 50;
attacks = new Attack[][] {
{//tackle bite
new Attack("TACKLE", 15, 25), new Attack("BITE", 15, 25)
}
,
{
new Attack("WATER GUN", 15, 25), new Attack("BUBBLE", 15, 25)
}
};
for (int i = 0; i<squirtleidle.length; i++) {
squirtleidle[i] = loadImage("res/pokemon/squirtle/squirtleidle" + i + ".png");
}
for (int j = 0; j<squirtleattack.length; j++) {
squirtleattack[j] = loadImage("res/pokemon/squirtle/squirtle" + j + ".png");
}
for (int a = 0; a < bite.length; a++) {
bite[a] = loadImage("res/attack/bite/bite_" + a + ".png");
}
for (int b = 0; b < growl.length; b++) {
growl[b] = loadImage("res/attack/growl/growl_" + b + ".png");
}
for (int c = 0; c < water.length; c++) {
water[c] = loadImage("res/attack/water/water_" + c + ".png");
}
for (int d = 0; d < bubble.length; d++) {
bubble[d] = loadImage("res/attack/bubble/bubble_" + d + ".png");
}
}
public void idle() {
idleindex = (idleindex < 32 ? idleindex+1 : idleindex)%squirtleidle.length;
image(squirtleidle[idleindex], x, y);
}
public void bounce() {
attackindex = (attackindex<22?attackindex+1 : attackindex)%squirtleattack.length;
image(squirtleattack[attackindex], x, y);
}
public void drawPokemon() {
if (enemybounce) {
bounce();
} else {
idle();
}
}
public boolean drawAttack(Attack at, float start) {
fill(color(random(0, 255), random(0, 255), random(0, 255)));
if (at.name == "TACKLE") {
if (millis () - start < 500) {
growlindex = (growlindex < 5 ? growlindex+1 : growlindex)%growl.length;
imageMode(CENTER);
image(growl[growlindex], 180, 230);
imageMode(CORNER);
return true;
}
} else if (at.name == "BITE") {
if (millis () - start < 1000) {
biteindex = (biteindex < 15 ? biteindex+1 : biteindex)%bite.length;
imageMode(CENTER);
image(bite[biteindex], 150, 230);
imageMode(CORNER);
return true;
}
} else if (at.name == "WATER GUN") {
if (millis() - start < 900) {
if (millis () - start < 300) {
waterX = 430;
waterY = 100;
} else if (millis() - start < 900) {
//this mumbo jumbo makes figures out velocities to make it get to destination in exactly 600 ms.
waterX += (230-430)/(frameRate*3/5.0);
waterY += (210-100)/(frameRate*3/5.0);
} else {
waterX = 230;
waterY = 210;
}
waterindex = (waterindex < 5 ? waterindex+1 : waterindex)%water.length;
imageMode(CENTER);
image(water[waterindex], waterX, waterY);
imageMode(CORNER);
return true;
}
} else if (at.name == "BUBBLE") {
if (millis() - start < 900) {
if (millis () - start < 200) {
waterX = 430;
waterY = 100;
} else if (millis() - start < 900) {
//this mumbo jumbo makes figures out velocities to make it get to destination in exactly 600 ms.
waterX += (230-430)/(frameRate*3/5.0);
waterY += (210-100)/(frameRate*3/5.0);
} else {
waterX = 230;
waterY = 210;
}
bubbleindex = (bubbleindex < 10 ? bubbleindex+1 : bubbleindex)%bubble.length;
imageMode(CENTER);
image(bubble[bubbleindex], waterX, waterY);
imageMode(CORNER);
return true;
}
}
return false;
}
}
//booleans to check keyPressed()
boolean titleKeyPress = false;
boolean worldKeyPress = false;
boolean worldKeyRelease = false;
class WorldPlayer {
//image, position and steps to encounter for sprite in the worldscreen
public PImage sprite;
public float posX;
public float posY;
public WorldPlayer() {
sprite = loadImage("res/ash/sprite.png");
posX = width/2 - sprite.width/2 + 7.5;
posY = height/2 - sprite.height/2;
}
}
class WorldScreen extends Screen { //WorldScreen
public boolean intro;
private int pindex = 16;
private int rindex = 38;
private int evolvecount = 0;
private PImage[] pikachuidle = new PImage[pindex];
private PImage[] godhelpme = new PImage[rindex];
//creates playa instance of the WorldPlayer variety
WorldPlayer playa = new WorldPlayer();
private PImage tree, grass, field, whiteScreen, blackScreen, evolveScreen, glow, sparkle, sparkle2, sparkle3;
private PImage pikachu, raichu;
private float opacity = 0;
private int glowsize = 0;
private float opacity2 = 255;
private float opacity3 = 255;
private ArrayList<InfoBar> messages;
private int messageIndex;
private boolean introEvolve, exitEvolve, fadeToCredits;
private int stepsTilEncounter;
private int sparklesn = 10;
private float [] sparklesx = new float[sparklesn];
private float [] sparklesy = new float[sparklesn];
private float [] sparkles2x = new float[sparklesn];
private float [] sparkles2y = new float[sparklesn];
private float [] sparkles3x = new float[sparklesn];
private float [] sparkles3y = new float[sparklesn];
private float [] sparklesv = new float[sparklesn];
public WorldScreen(boolean intro) {
tree = loadImage("res/world/tree.png");
grass = loadImage("res/world/grass.png");
field = loadImage("res/world/field.png");
whiteScreen = loadImage("res/op/12_white.png");
evolveScreen = loadImage("res/world/evolve.png");
glow = loadImage("res/world/glow.png");
sparkle = loadImage("res/world/sparkle.png");
sparkle2 = loadImage("res/world/sparkle2.png");
sparkle3 = loadImage("res/world/sparkle3.png");
blackScreen = createImage(whiteScreen.width, whiteScreen.height, RGB);
for (int p = 0; p<pikachuidle.length; p++) {
pikachuidle[p] = loadImage("res/pokemon/pikachu2/pikachu2_" + p + ".png");
}
for (int r = 0; r<godhelpme.length; r++) {
godhelpme[r] = loadImage("res/pokemon/raichu/raichu_" + r + ".png");
}
for (int s = 0; s<sparklesn; s++) {
sparklesx[s]=random(-100, 700);
sparklesy[s]=random(400, 500);
sparkles2x[s]=random(-100, 700);
sparkles2y[s]=random(400, 500);
sparkles3x[s]=random(-100, 700);
sparkles3y[s]=random(400, 500);
sparklesv[s]=random(5, 10);
}
whiteScreen.loadPixels();
tree.loadPixels();
grass.loadPixels();
field.loadPixels();
this.intro = intro;
messages = new ArrayList<InfoBar>();
if (intro) {
messages.add(new InfoBar("Oh no! Where are you?"));
messages.add(new InfoBar("This definitely isn't Littleroot Town!"));
messages.add(new InfoBar("You faintly recall Team Rocket having \nsomething to do with this!"));
messages.add(new InfoBar("There is a note in the grass!"));
messages.add(new InfoBar("It reads: \"We have kidnapped you,\nremoved all your possessions except\nPikachu, and sealed the exit!..."));
messages.add(new InfoBar("...You must defeat the pokemon of this\narea to escape!\"\n-Team Rocket"));
stepsTilEncounter = messages.size() + int(random(1, 3));
} else {
messages.add(new InfoBar("A note dropped!"));
messages.add(new InfoBar("It reads: \"Good work this time Ash, we'll\nget you next time!\n-Team Rocket"));
messages.add(new InfoBar("Your Pikachu is evolving!"));
messages.add(new InfoBar(""));
messages.add(new InfoBar("Your Pikachu evolved into Raichu!"));
messages.add(new InfoBar("You are now free to leave to the right!"));
stepsTilEncounter = 10000000;
}
}
public void drawScreen() {
//draws field