forked from haleysolin/SlimeFrenzy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgameWindow.cpp
More file actions
760 lines (708 loc) · 26.2 KB
/
gameWindow.cpp
File metadata and controls
760 lines (708 loc) · 26.2 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
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
#include "movingThing.h"
#include <cmath>
//SLIME FRENZY by Haley Solin
//
//MUSIC CREDS:
//
//Exploration | Chiptune RPG Adventure Theme by nickpanek620 on Pixabay
//Tower Defense | 8-Bit Chiptune Game Music by nickpanek620 on Pixabay
// Chiptune grooving by unnamed person on Pixabay
//license: https://pixabay.com/service/license-summary/
int main(){
int screenWidth = 2500;
int screenHeight = 1500;
InitWindow(screenWidth, screenHeight, "Slime Frenzy");
Player player = Player();
ChillPlayer chiller = ChillPlayer();
Magic magic = Magic();
Sword sword = Sword();
Boss boss = Boss();
Enemies enemies = Enemies();
Texture2D grass = LoadTexture("resources/grasss.PNG");
Texture2D bar = LoadTexture("resources/fullBar.PNG");
Texture2D titleScreen = LoadTexture("resources/title.PNG");
Texture2D guildBG = LoadTexture("resources/guild.PNG");
Texture2D textBox = LoadTexture("resources/carolineText.PNG");
Texture2D rightSword = LoadTexture("resources/sword.PNG");
Texture2D leftSword = LoadTexture("resources/leftSword.PNG");
float width = 1600;
Rectangle healthBar = {15009, 10, width, 50};
double lastSpawn = GetTime();
double sinceSpawn = 0.0;
double lastShoot = GetTime();
double sinceShoot = 0.0;
double spawnTime = 2;
int frameCount = 0;
int magicDirection = 0;
int totalSlimesKilled = 0;
int slimesKilled = 0;
int slimeBounty = 0;
int coins = 0;
int storyLine = 0;
bool paused = false;
bool fighting = false;
bool guild = false;
bool story = false;
bool isTalking = false;
bool intro = true;
bool tutorial = false;
bool selectBounty = false;
bool checkStats = false;
bool shopping = false;
bool bought = false;
bool playDie = true;
bool bossing = false;
InitAudioDevice();
Music chillMusic = LoadMusicStream("resources/sounds/chillMusic.mp3");
Music fightingMusic = LoadMusicStream("resources/sounds/chillFighting.mp3");
Music bossMusic = LoadMusicStream("resources/sounds/fighting.mp3");
Sound attackSound = LoadSound("resources/sounds/sword.mp3");
Sound killSound = LoadSound("resources/sounds/kill.mp3");
Sound magicSound = LoadSound("resources/sounds/magic.mp3");
Sound hurtSound = LoadSound("resources/sounds/hit.mp3");
Sound levelUpSound = LoadSound("resources/sounds/levelUp.mp3");
Sound deathSound = LoadSound("resources/sounds/death.mp3");
Sound buttonSound = LoadSound("resources/sounds/button.mp3");
Sound winSound = LoadSound("resources/sounds/winner.mp3");
Sound gameStart = LoadSound("resources/sounds/gameStart.mp3");
PlayMusicStream(chillMusic);
PlayMusicStream(fightingMusic);
PlayMusicStream(bossMusic);
SetTargetFPS(60);
while(!WindowShouldClose()){
BeginDrawing();
ClearBackground(WHITE);
if(!fighting&&!bossing){
PauseMusicStream(fightingMusic);
PauseMusicStream(bossMusic);
UpdateMusicStream(chillMusic);
ResumeMusicStream(chillMusic);
}
else if(bossing){
PauseMusicStream(chillMusic);
PauseMusicStream(fightingMusic);
UpdateMusicStream(bossMusic);
ResumeMusicStream(bossMusic);
}
else{
PauseMusicStream(chillMusic);
PauseMusicStream(bossMusic);
UpdateMusicStream(fightingMusic);
ResumeMusicStream(fightingMusic);
}
if(!fighting&&!guild&&!story&&!bossing){
DrawTexture(titleScreen, 0, 0, WHITE);
if(IsKeyPressed(KEY_S)){
story = true;
PlaySound(gameStart);
}
}
if(story){
ClearBackground(BLACK);
DrawText("-- Press SPACE to continue --", 850, 1300, 50, LIGHTGRAY);
if(storyLine>=0){
DrawText("Once upon a time, there lived a girl with an unremarkable life.", 350, 300, 50, WHITE);
}
if(storyLine>=1){
DrawText("That is, until she woke up one day in a completely unfamiliar place: \na fantasy world!", 350, 520, 50, WHITE);
}
if(storyLine>=2){
DrawText("She was approached by a girl named Caroline who offered her a job as \na slime hunter at the adventurer's guild.", 350, 770, 50, WHITE);
}
if(storyLine>=3){
DrawText("Being both broke and homeless, she gladly accepted the offer.\nNow, it is your job to help her complete bounties and get rich!", 350, 1020, 50, WHITE);
}
if(storyLine>=4){
story = false;
guild = true;
}
if(IsKeyPressed(KEY_SPACE)){
storyLine++;
PlaySound(buttonSound);
}
}
if(guild){
ClearBackground(BROWN);
DrawTexture(guildBG, 0, 0, WHITE);
chiller.draw();
if(chiller.x>1000&&!isTalking){
DrawText("Press 'X' to talk", 1500, 550, 50, BLACK);
}
if (IsKeyPressed(KEY_X)&&chiller.x>1000){
PlaySound(buttonSound);
if (isTalking){
isTalking = false;
intro = true;
selectBounty = false;
tutorial = false;
checkStats = false;
shopping = false;
bought = false;
}
else
isTalking = true;
}
if(!isTalking){
if(IsKeyDown(KEY_D)&&((chiller.x)<=1170)){
chiller.move(1);
chiller.moveBox();
}
else if (IsKeyDown(KEY_A)){
chiller.move(2);
chiller.moveBox();
}
else if (IsKeyDown(KEY_S)&&chiller.y<=924){
chiller.move(3);
chiller.moveBox();
}
else if (IsKeyDown(KEY_W)&&chiller.y>165){
chiller.move(4);
chiller.moveBox();
}
}
if (isTalking){
DrawTexture(textBox, 0, 0, WHITE);
if(intro){
DrawText("Welcome to the Adventurer's Guild! How can I help you?\n\n1-Tutorial\n\n2-Start Bounty\n\n3-Check Stats\n\n4-Open Shop\n\n5-Exit Game", 752, 778, 50, DARKBROWN);
DrawText("'X' to go close", 1285, 1330, 50, BROWN);
if(IsKeyPressed(KEY_ONE)){
PlaySound(buttonSound);
tutorial = true;
intro = false;
}
else if(IsKeyPressed(KEY_TWO)){
PlaySound(buttonSound);
selectBounty = true;
intro = false;
}
else if(IsKeyPressed(KEY_THREE)){
PlaySound(buttonSound);
checkStats = true;
intro = false;
}
else if(IsKeyPressed(KEY_FOUR)){
PlaySound(buttonSound);
shopping = true;
intro = false;
}
else if(IsKeyPressed(KEY_FIVE)){
break;
}
}
if(tutorial){
if(IsKeyPressed(KEY_B)){
PlaySound(buttonSound);
intro = true;
tutorial = false;
}
DrawText("Before entering battle mode, you will select how many \nslimes to kill to end battle mode.\n\nIn battle mode, press WASD to move, space to hit with\nyour sword, and arrow keys in the direction you want to \nshoot magic. Use your magic wisely, because there is a\n4 second cooldown!\n\nSlimes will spawn and shoot balls at you which can kill you!\nAlso, you can press P at any time to pause.", 752, 778, 50, DARKBROWN);
DrawText("'B' to go back", 1275, 1330, 50, BROWN);
}
if(selectBounty){
if(IsKeyPressed(KEY_B)){
PlaySound(buttonSound);
intro = true;
selectBounty = false;
}
DrawText("Select the bounty level with 3, 4, 5, or 6.\n\n3- 10 slime bounty - Reward: 100 coins\n\n4- 20 slime bounty - Reward: 250 coins\n\n5- 30 slime bounty - Reward: 400 coins\n\n6- Boss fight - Reward: 1000 coins", 752, 788, 50, DARKBROWN);
DrawText("'B' to go back", 1275, 1330, 50, BROWN);
if(IsKeyPressed(KEY_THREE)){
PlaySound(buttonSound);
fighting = true;
guild = false;
slimeBounty = 10;
isTalking = false;
selectBounty = false;
intro = true;
chiller.reset();
StopMusicStream(chillMusic);
PlayMusicStream(chillMusic);
}
else if(IsKeyPressed(KEY_FOUR)){
PlaySound(buttonSound);
fighting = true;
guild = false;
slimeBounty = 20;
isTalking = false;
selectBounty = false;
intro = true;
chiller.reset();
StopMusicStream(chillMusic);
PlayMusicStream(chillMusic);
}
else if(IsKeyPressed(KEY_FIVE)){
PlaySound(buttonSound);
fighting = true;
guild = false;
slimeBounty = 30;
isTalking = false;
selectBounty = false;
intro = true;
chiller.reset();
StopMusicStream(chillMusic);
PlayMusicStream(chillMusic);
}
else if(IsKeyPressed(KEY_SIX)){
PlaySound(buttonSound);
bossing = true;
guild = false;
slimeBounty = 30;
isTalking = false;
selectBounty = false;
intro = true;
chiller.reset();
StopMusicStream(chillMusic);
PlayMusicStream(chillMusic);
}
}
if(checkStats){
if(IsKeyPressed(KEY_B)){
PlaySound(buttonSound);
intro = true;
checkStats = false;
}
DrawText(TextFormat("You have killed a grand total of %i slimes. \n\nYou are on level %i.\n\nTo level up, kill %i more slimes.\n\nYou currently have %i coins.",totalSlimesKilled, player.level, (int)(10*(1.0/1.8*std::pow(player.level,2)))-totalSlimesKilled, coins), 752, 788, 50, DARKBROWN);
DrawText("'B' to go back", 1275, 1330, 50, BROWN);
}
if(shopping){
if(IsKeyPressed(KEY_B)){
PlaySound(buttonSound);
intro = true;
shopping = false;
bought = false;
}
if(coins>=300){
DrawText(TextFormat("OK! You currently have %i coins.\n\nFor 300 coins, you can increase your damage \nby 2.\n\nFor reference, slimes have 25 health.\n\nWould you like to upgrade? Press 'Y' or 'N'", coins), 752, 788, 50, DARKBROWN);
DrawText("'B' to go back", 1275, 1330, 50, BROWN);
if (IsKeyPressed(KEY_Y)){
PlaySound(buttonSound);
bought = true;
shopping = false;
coins-=300;
sword.increaseDamage();
magic.increaseDamage();
}
if (IsKeyPressed(KEY_N)){
PlaySound(buttonSound);
shopping = false;
intro = true;
}
}
else{
DrawText(TextFormat("OK! You currently have %i coins.\n\nYou need %i more coins for an upgrade.", coins, 300-coins), 752, 788, 50, DARKBROWN);
DrawText("'B' to go back", 1275, 1330, 50, BROWN);
}
}
if(bought){
if(IsKeyPressed(KEY_B)){
PlaySound(buttonSound);
intro = true;
bought = false;
}
DrawText(TextFormat("OK! You now have %i coins.\n\nYour sword now does %i damage,\nand your magic now does %i damage.", coins, sword.damage, magic.damage), 752, 788, 50, DARKBROWN);
DrawText("'B' to go back", 1275, 1330, 50, BROWN);
}
}
}
if(fighting){
if(!paused&&!player.isDead()){
sinceSpawn = GetTime() - lastSpawn;
sinceShoot = GetTime() - lastShoot;
frameCount++;
}
if(std::floor(sinceShoot)==0){
bar = LoadTexture("resources/emptyBar.PNG");
}
else if(std::floor(sinceShoot)==1){
bar = LoadTexture("resources/emptyishBar.PNG");
}
else if(std::floor(sinceShoot)==2){
bar = LoadTexture("resources/halfBar.PNG");
}
else if(std::floor(sinceShoot)==3){
bar = LoadTexture("resources/fullishBar.PNG");
}
else if(std::floor(sinceShoot)==4){
bar = LoadTexture("resources/fullBar.PNG");
}
DrawTexture(grass, 0, 0, WHITE);
if (!player.isDead()){
player.draw(); //draw player
sword.draw();
}
if(IsKeyPressed(KEY_P)){
if(paused)
paused = false;
else
paused = true;
}
if(!paused){
if(IsKeyDown(KEY_D)){
//sword.changeSprite("resources/sword.PNG");
if(player.move(1)){
sword.flip(1, player, rightSword, leftSword);
//sword.move(1);
}
player.moveBox();
}
else if (IsKeyDown(KEY_A)){
//sword.changeSprite("resources/leftSword.PNG");
if(player.move(2)){
sword.flip(2, player, rightSword, leftSword);
//sword.move(2);
}
player.moveBox();
}
else if (IsKeyDown(KEY_S)){
if(player.move(3)){
sword.move(3);
sword.moveBox();
}
player.moveBox();
}
else if (IsKeyDown(KEY_W)){
if(player.move(4)){
sword.move(4);
sword.moveBox();
}
player.moveBox();
}//move player
if(IsKeyDown(KEY_SPACE)){
sword.hitting();
PlaySound(attackSound);
}
else{
sword.stopHitting();
}
if(IsKeyPressed(KEY_SPACE)){
if(enemies.swordDamage(sword)){
slimesKilled++;
totalSlimesKilled++;
PlaySound(killSound);
}
}
}
if (sinceShoot>4 && !player.isDead() && !paused){
if(IsKeyPressed(KEY_RIGHT)){
magic.spawn(1, player);
magicDirection = 1;
lastShoot = GetTime();
PlaySound(magicSound);
}
else if (IsKeyPressed(KEY_LEFT)){
magic.spawn(2, player);
magicDirection = 2;
lastShoot = GetTime();
PlaySound(magicSound);
}
else if (IsKeyPressed(KEY_DOWN)){
magic.spawn(3, player);
magicDirection = 3;
lastShoot = GetTime();
PlaySound(magicSound);
}
else if (IsKeyPressed(KEY_UP)){
magic.spawn(4, player);
magicDirection = 4;
lastShoot = GetTime();
PlaySound(magicSound);
}
} //spawn magic
magic.draw();
magic.moveBox();
if (enemies.magicDamage(magic)){
slimesKilled++;
totalSlimesKilled++;
PlaySound(killSound);
}//up slime kill count
if(!player.isDead()&&!paused){
magic.move(magicDirection);
}
if(sinceSpawn>=spawnTime && !player.isDead() &&!paused){
enemies.spawn();
lastSpawn = GetTime();
}//spawn slimes
enemies.drawAll();
enemies.drawBalls();
if (!player.isDead() && !paused){
enemies.moveAll();
enemies.addBalls(frameCount);//spawns a ball sometimes
enemies.moveBalls();
if(enemies.ballDamage(player)){
PlaySound(hurtSound);
}
}
if(totalSlimesKilled==(int)(10*(1.0/1.8*std::pow(player.level,2))) && slimesKilled!=0){
player.levelUp();
sword.levelUp();
PlaySound(levelUpSound);
}
DrawText(TextFormat("HEALTH: %i\tSlimes Killed: %i\tLevel: %i", player.health, slimesKilled, player.level), 10, 10, 50, WHITE);
DrawTexture(bar, 10, 1350, WHITE);
if(paused){
DrawText("PAUSED", 1000, 700, 100, WHITE);
}
if(player.isDead()){
DrawText("you're dead lol", 850, 700, 100, WHITE);
DrawText("'R' to return to the guild", 750, 800, 75, WHITE);
if(playDie){
StopMusicStream(fightingMusic);
PlaySound(deathSound);
playDie=false;
}
if(IsKeyPressed(KEY_R)){
guild = true;
fighting = false;
playDie = true;
slimesKilled = 0;
player.reset();
enemies.reset();
magic.setCoords(2500, 1500);
sword.reset();
PlayMusicStream(fightingMusic);
bar = LoadTexture("resources/fullBar.PNG");
}
}
if(slimeBounty==slimesKilled){
paused = true;
DrawRectangleRounded({500, 500, 1500, 500}, 0.3f, 15, PURPLE);
DrawText("Bounty Complete!", 825, 650, 100, WHITE);
DrawText("'R' to return to the guild", 750, 750, 75, WHITE);
if(playDie){
StopMusicStream(fightingMusic);
PlaySound(winSound);
playDie=false;
}
if(IsKeyPressed(KEY_R)){
playDie = true;
guild = true;
fighting = false;
paused = false;
slimesKilled = 0;
player.reset();
enemies.reset();
magic.setCoords(2500, 1500);
sword.reset();
coins+=(slimeBounty*10+((slimeBounty/10-1)*50));
StopMusicStream(fightingMusic);
PlayMusicStream(fightingMusic);
bar = LoadTexture("resources/fullBar.PNG");
}
}
}
if(bossing){
width = boss.health*2.7;
healthBar = {1000, 10, width, 50};
if(!paused&&!player.isDead()){
sinceSpawn = GetTime() - lastSpawn;
sinceShoot = GetTime() - lastShoot;
frameCount++;
}
if(std::floor(sinceShoot)==0){
bar = LoadTexture("resources/emptyBar.PNG");
}
else if(std::floor(sinceShoot)==1){
bar = LoadTexture("resources/emptyishBar.PNG");
}
else if(std::floor(sinceShoot)==2){
bar = LoadTexture("resources/halfBar.PNG");
}
else if(std::floor(sinceShoot)==3){
bar = LoadTexture("resources/fullishBar.PNG");
}
else if(std::floor(sinceShoot)==4){
bar = LoadTexture("resources/fullBar.PNG");
}
DrawTexture(grass, 0, 0, WHITE);
if(IsKeyPressed(KEY_P)){
if(paused)
paused = false;
else
paused = true;
}
if(!paused){
if(IsKeyDown(KEY_D)&&!CheckCollisionRecs(player.hitbox, boss.hitbox)){
if(player.move(1)){
sword.flip(1, player, rightSword, leftSword);
}
player.moveBox();
}
else if (IsKeyDown(KEY_A)){
if(player.move(2)){
sword.flip(2, player, rightSword, leftSword);
}
player.moveBox();
}
else if (IsKeyDown(KEY_S)&&!(player.x>1456&&(270<player.y&&player.y<1210))){
if(player.move(3)){
sword.move(3);
sword.moveBox();
}
player.moveBox();
}
else if (IsKeyDown(KEY_W)&&!(player.x>1456&&(290<player.y&&player.y<1232))){
if(player.move(4)){
sword.move(4);
sword.moveBox();
}
player.moveBox();
}//move player
if(IsKeyDown(KEY_SPACE)&&!player.isDead()&&!paused){
sword.hitting();
PlaySound(attackSound);
}
else{
sword.stopHitting();
}
if(IsKeyPressed(KEY_SPACE)&&!player.isDead()&&!paused){
if(enemies.swordDamage(sword)){
slimesKilled+=1;
totalSlimesKilled+=1;
PlaySound(killSound);
}
if(boss.swordDamage(sword)){
PlaySound(killSound);
}
}
}
if (sinceShoot>4 && !player.isDead() && !paused){
if(IsKeyPressed(KEY_RIGHT)){
magic.spawn(1, player);
magicDirection = 1;
lastShoot = GetTime();
PlaySound(magicSound);
}
else if (IsKeyPressed(KEY_LEFT)){
magic.spawn(2, player);
magicDirection = 2;
lastShoot = GetTime();
PlaySound(magicSound);
}
else if (IsKeyPressed(KEY_DOWN)){
magic.spawn(3, player);
magicDirection = 3;
lastShoot = GetTime();
PlaySound(magicSound);
}
else if (IsKeyPressed(KEY_UP)){
magic.spawn(4, player);
magicDirection = 4;
lastShoot = GetTime();
PlaySound(magicSound);
}
} //spawn magic
enemies.drawAll();
enemies.drawBalls();
if(!boss.isDead())
boss.draw();
boss.drawBalls();
if (!player.isDead()){
player.draw(); //draw player
sword.draw();
}
magic.draw();
magic.moveBox();
if (enemies.magicDamage(magic)){
slimesKilled++;
totalSlimesKilled++;
PlaySound(killSound);
}//up slime kill count
if (boss.magicDamage(magic)){
magic.setCoords(2500,1500);
}
if(!player.isDead()&&!paused){
magic.move(magicDirection);
}
if(sinceSpawn>=12 && !player.isDead() &&!paused){
enemies.spawn();
lastSpawn = GetTime();
}//spawn slimes
if (!player.isDead() && !paused){
enemies.moveAll();
enemies.addBalls(frameCount);//spawns a ball sometimes
enemies.moveBalls();
if(enemies.ballDamage(player)){
PlaySound(hurtSound);
}
if(boss.checkMyBalls(player)){
PlaySound(hurtSound);
}
boss.addBall(frameCount, player);
boss.moveBalls();
}
if(totalSlimesKilled>=(int)(10*(1.0/1.8*std::pow(player.level,2))) && slimesKilled!=0){
player.levelUp();
sword.levelUp();
PlaySound(levelUpSound);
}
DrawText(TextFormat("HEALTH: %i\tSlimes Killed: %i\tLevel: %i", player.health, slimesKilled, player.level), 10, 10, 50, WHITE);
DrawTexture(bar, 10, 1350, WHITE);
DrawRectangleRounded(healthBar, 0.2f, 10, RED);
if(paused){
DrawText("PAUSED", 1000, 700, 100, WHITE);
}
if(player.isDead()){
DrawText("you're dead lol", 850, 700, 100, WHITE);
DrawText("'R' to return to the guild", 750, 800, 75, WHITE);
if(playDie){
StopMusicStream(bossMusic);
PlaySound(deathSound);
playDie=false;
}
if(IsKeyPressed(KEY_R)){
guild = true;
bossing = false;
playDie = true;
slimesKilled = 0;
player.reset();
enemies.reset();
boss.reset();
magic.setCoords(2500, 1500);
sword.reset();
chiller.reset();
PlayMusicStream(bossMusic);
bar = LoadTexture("resources/fullBar.PNG");
}
}
if(boss.isDead()){
paused = true;
DrawRectangleRounded({500, 500, 1500, 500}, 0.3f, 15, PURPLE);
DrawText("Bounty Complete!", 825, 650, 100, WHITE);
DrawText("'R' to return to the guild", 750, 750, 75, WHITE);
if(playDie){
StopMusicStream(bossMusic);
PlaySound(winSound);
playDie=false;
}
if(IsKeyPressed(KEY_R)){
slimesKilled+=10;
totalSlimesKilled+=10;
if(totalSlimesKilled>=(int)(10*(1.0/1.8*std::pow(player.level,2))) && slimesKilled!=0){
player.levelUp();
sword.levelUp();
}
playDie = true;
paused = false;
guild = true;
bossing = false;
slimesKilled = 0;
player.reset();
enemies.reset();
boss.reset();
magic.setCoords(2500, 1500);
sword.reset();
coins+=1000;
StopMusicStream(bossMusic);
PlayMusicStream(bossMusic);
}
}
}
EndDrawing();
}
UnloadMusicStream(chillMusic);
UnloadMusicStream(fightingMusic);
UnloadMusicStream(bossMusic);
CloseAudioDevice();
CloseWindow();
return 0;
}