Skip to content

Commit e40cee1

Browse files
authored
Add files via upload
1 parent 881fa07 commit e40cee1

File tree

2 files changed

+58
-22
lines changed

2 files changed

+58
-22
lines changed

MAINGAME.py

Lines changed: 57 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
import random
44
import csv
55
import button
6+
import pyautogui
67

78
pygame.init()
89

9-
1010
SCREEN_WIDTH = 1080
1111
SCREEN_HEIGHT = int(SCREEN_WIDTH * 0.8)
1212
programIcon = pygame.image.load('img/favicon.png')
@@ -39,6 +39,8 @@
3939
shoot = False
4040
grenade = False
4141
grenade_thrown = False
42+
molotov = False
43+
molotov_thrown = False
4244

4345

4446

@@ -58,6 +60,7 @@
5860
Mkey = pygame.image.load('img/icons/keyboard/Keyboard & Mouse/Light/M_Key_Light.png').convert_alpha()
5961
Ukey = pygame.image.load('img/icons/keyboard/Keyboard & Mouse/Light/U_Key_Light.png').convert_alpha()
6062
Fkey = pygame.image.load('img/icons/keyboard/Keyboard & Mouse/Light/F_Key_Light.png').convert_alpha()
63+
F5key = pygame.image.load('img/icons/keyboard/Keyboard & Mouse/Light/F5_Key_Light.png').convert_alpha()
6164

6265

6366
# BACKGROUND IMAGES
@@ -80,19 +83,20 @@
8083
bullet_zombie = pygame.image.load('img/icons/bulletzombie.png').convert_alpha
8184

8285
grenade_img = pygame.image.load('img/icons/grenade.png').convert_alpha()
86+
molotov_img = pygame.image.load('img/icons/molotov.png').convert_alpha()
8387

8488
health_box_img = pygame.image.load('img/icons/health_box.png').convert_alpha()
8589
ammo_box_img = pygame.image.load('img/icons/ammo_box.png').convert_alpha()
86-
grenade_box_img = pygame.image.load(
87-
'img/icons/grenade_box.png').convert_alpha()
90+
grenade_box_img = pygame.image.load('img/icons/grenade_box.png').convert_alpha()
91+
molotov_box_img = pygame.image.load('img/icons/molotov_box.png').convert_alpha()
8892
item_boxes = {
8993
'Health' : health_box_img,
9094
'Ammo' : ammo_box_img,
91-
'Grenade' : grenade_box_img
95+
'Grenade' : grenade_box_img,
9296
}
9397

9498
# COLORS
95-
BG = (144, 201, 120)
99+
BG = (81, 6, 13)
96100
RED = (176, 8, 12)
97101
WHITE = (255, 255, 255)
98102
GREEN = (26, 110, 15)
@@ -110,6 +114,9 @@
110114
GRENADESOUND = pygame.mixer.Sound('audio/grenade.mp3')
111115
GRENADESOUND.set_volume(1)
112116

117+
MOLOTOVSOUND = pygame.mixer.Sound('audio/molotov.wav')
118+
MOLOTOVSOUND.set_volume(1)
119+
113120
PICK = pygame.mixer.Sound('audio/grenadepick.mp3')
114121
PICK.set_volume(2)
115122

@@ -134,7 +141,8 @@
134141
GAMEOVER = pygame.mixer.Sound('audio/gameover.wav')
135142
GAMEOVER.set_volume(2)
136143

137-
144+
SCREENSHOT = pygame.mixer.Sound('audio/takingphoto.wav')
145+
GAMEOVER.set_volume(5)
138146

139147
# FONT
140148
font = pygame.font.Font("font/Futurot.ttf", 20)
@@ -143,6 +151,9 @@
143151
YOUDIED = pygame.font.Font("font/Futurot.ttf", 110)
144152
JanKupczyk = pygame.font.Font("font/Futurot.ttf", 13)
145153

154+
pausetimerevent = pygame.USEREVENT + 1
155+
paused = False
156+
146157
def draw_text(text, font, text_col, x, y):
147158
img = font.render(text, True, text_col)
148159
screen.blit(img, (x, y))
@@ -198,7 +209,7 @@ def __init__(self, char_type, x, y, scale, speed, ammo, grenades):
198209
self.vel_y = 0
199210
self.jump = False
200211
self.in_air = True
201-
self.flip = False
212+
self.flip = True
202213
self.animation_list = []
203214
self.frame_index = 0
204215
self.action = 0
@@ -310,7 +321,7 @@ def move(self, moving_left, moving_right):
310321
def shoot(self):
311322
if self.shoot_cooldown == 0 and self.ammo > 0:
312323
self.shoot_cooldown = 15
313-
bullet = Bullet(self.rect.centerx + (0.80 *
324+
bullet = Bullet(self.rect.centerx + (0.60 *
314325
self.rect.size[0] * self.direction), self.rect.centery, self.direction)
315326
bullet_group.add(bullet)
316327
SHOOT_SOUND.play()
@@ -416,7 +427,7 @@ def process_data(self, data):
416427
elif tile == 17: # create ammo box
417428
item_box = ItemBox(
418429
'Ammo', x * TILE_SIZE, y * TILE_SIZE)
419-
item_box_group.add(item_box)
430+
item_box_group.add(item_box)
420431
elif tile == 18: # create grenade box
421432
item_box = ItemBox(
422433
'Grenade', x * TILE_SIZE, y * TILE_SIZE)
@@ -513,12 +524,13 @@ def draw(self, health):
513524
pygame.draw.rect(screen, RED, (self.x, self.y, 150, 20))
514525
pygame.draw.rect(screen, GREEN, (self.x, self.y, 150 * ratio, 20))
515526
screen.blit(headhp, (-4, 2))
516-
527+
screen.blit(update_fps(), (1050,5))
528+
draw_text('FPS', font, WHITE, 1010, 5)
517529

518530
class Bullet(pygame.sprite.Sprite):
519531
def __init__(self, x, y, direction):
520532
pygame.sprite.Sprite.__init__(self)
521-
self.speed = 10
533+
self.speed = 11
522534
self.image = bullet_img
523535
self.rect = self.image.get_rect()
524536
self.rect.center = (x, y)
@@ -542,7 +554,11 @@ def update(self):
542554
enemy.health -= 25
543555
ZOMBIEATTACK.play()
544556
self.kill()
545-
557+
558+
def update_fps():
559+
fps = str(int(clock.get_fps()))
560+
fps_text = font.render(fps, 1, pygame.Color("white"))
561+
return fps_text
546562

547563
class Grenade(pygame.sprite.Sprite):
548564
def __init__(self, x, y, direction):
@@ -627,6 +643,11 @@ def update(self):
627643
else:
628644
self.image = self.images[self.frame_index]
629645

646+
#TAKING SCREENSHOT
647+
def screenshot(obj, file_name, position, size):
648+
img = pygame.Surface(size)
649+
img.blit(obj, (0, 0), (position, size))
650+
pygame.image.save(img, "screenshots/ss_.png")
630651

631652
#BTNs
632653
start_button = button.Button(
@@ -680,14 +701,16 @@ def update(self):
680701
screen.blit(Akey, (100, 450))
681702
draw_text('SHOOT', font, WHITE, 210, 512)
682703
screen.blit(SPkey, (125, 480))
683-
draw_text('NADE', font, WHITE, 55, 626)
684-
screen.blit(Qkey, (5, 610))
685-
draw_text('MUTE MUSIC', font, WHITE, 55, 666)
686-
screen.blit(Mkey, (5, 650))
687-
draw_text('UNMUTE MUSIC', font, WHITE, 55, 706)
688-
screen.blit(Ukey, (5, 690))
689-
draw_text('FULLSCREEN', font, WHITE, 55, 746)
690-
screen.blit(Fkey, (5, 730))
704+
draw_text('NADE', font, WHITE, 55, 586)
705+
screen.blit(Qkey, (5, 570))
706+
draw_text('MUTE MUSIC', font, WHITE, 55, 626)
707+
screen.blit(Mkey, (5, 610))
708+
draw_text('UNMUTE MUSIC', font, WHITE, 55, 666)
709+
screen.blit(Ukey, (5, 650))
710+
draw_text('FULLSCREEN', font, WHITE, 55, 706)
711+
screen.blit(Fkey, (5, 690))
712+
draw_text('TAKE SCREENSHOT', font, WHITE, 55, 746)
713+
screen.blit(F5key, (5, 730))
691714
draw_text('EXIT', font, WHITE, 55, 825)
692715
screen.blit(ESCkey, (5, 810))
693716
draw_text('©2021 Jan Kupczyk', JanKupczyk, WHITE, 905, 845)
@@ -710,6 +733,9 @@ def update(self):
710733
draw_text('GRENADES: ', font, WHITE, 10, 60)
711734
for x in range(player.grenades):
712735
screen.blit(grenade_img, (135 + (x * 15), 60))
736+
draw_text('MOLOTOVS: ', font, WHITE, 10, 85)
737+
for x in range(player.grenades):
738+
screen.blit(molotov_img, (140 + (x * 15), 90))
713739

714740
player.update()
715741
player.draw()
@@ -805,12 +831,22 @@ def update(self):
805831
player.jump = True
806832
if event.key == pygame.K_ESCAPE:
807833
run = False
834+
MENUSELECT.play()
808835
if event.key == pygame.K_m:
809836
pygame.mixer.music.pause()
837+
MENUSELECT.play()
810838
if event.key == pygame.K_u:
811839
pygame.mixer.music.unpause()
840+
MENUSELECT.play()
812841
if event.key == pygame.K_f:
813-
pygame.display.toggle_fullscreen()
842+
pygame.display.set_mode((1920, 1080), pygame.FULLSCREEN)
843+
MENUSELECT.play()
844+
if event.key == pygame.K_F5:
845+
screenshottaken = draw_text('Screenshot taken!', font, WHITE, 0, 840,)
846+
MENUSELECT.play()
847+
SCREENSHOT.play()
848+
screenshot(screen, "screenshots/screenshot.png", (20, 100), (1080, 864))
849+
print("Screenshot taken")
814850

815851
# KEYBOARDS SETT2
816852
if event.type == pygame.KEYUP:

tempCodeRunnerFile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
die
1+
10

0 commit comments

Comments
 (0)