Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
jankupczyk authored Apr 11, 2021
1 parent 673f2a1 commit 008261c
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 15 deletions.
41 changes: 26 additions & 15 deletions MAINGAME.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@


# IMAGES
start_img = pygame.image.load('img/start_btn.png').convert_alpha()
exit_img = pygame.image.load('img/exit_btn.png').convert_alpha()
restart_img = pygame.image.load('img/restart_btn.png').convert_alpha()
start_img = pygame.image.load('img/btn/start_btn.png').convert_alpha()
exit_img = pygame.image.load('img/btn/exit_btn.png').convert_alpha()
restart_img = pygame.image.load('img/btn/restart_btn.png').convert_alpha()
menubg = pygame.image.load('img/background/menuzombioo.png').convert_alpha()

#KEYBOARD
Expand All @@ -67,6 +67,8 @@
'img/background/2_background_NEST/2_game_background.png').convert_alpha()
mountain_img = pygame.image.load('img/background/2_background_NEST/2_game_background.png').convert_alpha()
sky_img = pygame.image.load('img/Background/sky_cloud.png').convert_alpha()
headhp = pygame.image.load('img/player/headHP.png').convert_alpha()
headdeadhp = pygame.image.load('img/player/headdeadHP.png').convert_alpha()
# TILES ETC
img_list = []
for x in range(TILE_TYPES):
Expand Down Expand Up @@ -137,6 +139,8 @@
# FONT
font = pygame.font.Font("font/Futurot.ttf", 20)
zombiootitle = pygame.font.Font("font/Futurot.ttf", 90)
BTNtext = pygame.font.Font("font/Futurot.ttf", 50)
YOUDIED = pygame.font.Font("font/Futurot.ttf", 110)
JanKupczyk = pygame.font.Font("font/Futurot.ttf", 13)

def draw_text(text, font, text_col, x, y):
Expand Down Expand Up @@ -188,7 +192,7 @@ def __init__(self, char_type, x, y, scale, speed, ammo, grenades):
self.start_ammo = ammo
self.shoot_cooldown = 0
self.grenades = grenades
self.health = 100
self.health = 120
self.max_health = self.health
self.direction = 1
self.vel_y = 0
Expand Down Expand Up @@ -306,7 +310,7 @@ def move(self, moving_left, moving_right):
def shoot(self):
if self.shoot_cooldown == 0 and self.ammo > 0:
self.shoot_cooldown = 15
bullet = Bullet(self.rect.centerx + (0.75 *
bullet = Bullet(self.rect.centerx + (0.80 *
self.rect.size[0] * self.direction), self.rect.centery, self.direction)
bullet_group.add(bullet)
SHOOT_SOUND.play()
Expand Down Expand Up @@ -487,10 +491,10 @@ def update(self):
if player.health > player.max_health:
player.health = player.max_health
elif self.item_type == 'Ammo':
player.ammo += 15
player.ammo += 20
RELOAD.play()
elif self.item_type == 'Grenade':
player.grenades += 3
player.grenades += 1
PICK.play()
self.kill()

Expand All @@ -508,6 +512,7 @@ def draw(self, health):
pygame.draw.rect(screen, BLACK, (self.x - 2, self.y - 2, 154, 24))
pygame.draw.rect(screen, RED, (self.x, self.y, 150, 20))
pygame.draw.rect(screen, GREEN, (self.x, self.y, 150 * ratio, 20))
screen.blit(headhp, (-4, 2))


class Bullet(pygame.sprite.Sprite):
Expand Down Expand Up @@ -576,19 +581,19 @@ def update(self):
self.rect.y += dy

# CD TIMER
self.timer -= 1
self.timer -= 0.95
if self.timer <= 0:
self.kill()
explosion = Explosion(self.rect.x, self.rect.y, 0.5)
explosion = Explosion(self.rect.x, self.rect.y, 1.5)
explosion_group.add(explosion)
#DAMAGE
if abs(self.rect.centerx - player.rect.centerx) < TILE_SIZE * 2 and \
abs(self.rect.centery - player.rect.centery) < TILE_SIZE * 2:
player.health -= 50
for enemy in enemy_group:
if abs(self.rect.centerx - enemy.rect.centerx) < TILE_SIZE * 2 and \
abs(self.rect.centery - enemy.rect.centery) < TILE_SIZE * 2:
enemy.health -= 50
if abs(self.rect.centerx - enemy.rect.centerx) < TILE_SIZE * 3 and \
abs(self.rect.centery - enemy.rect.centery) < TILE_SIZE * 3:
enemy.health -= 100
GRUNTING.play()


Expand All @@ -611,7 +616,7 @@ def __init__(self, x, y, scale):
def update(self):
self.rect.x += screen_scroll

EXPLOSION_SPEED = 5
EXPLOSION_SPEED = 7
self.counter += 1

if self.counter >= EXPLOSION_SPEED:
Expand Down Expand Up @@ -685,7 +690,7 @@ def update(self):
screen.blit(Fkey, (5, 730))
draw_text('EXIT', font, WHITE, 55, 825)
screen.blit(ESCkey, (5, 810))
draw_text('Jan Kupczyk', JanKupczyk, WHITE, 936, 845)
draw_text('©2021 Jan Kupczyk', JanKupczyk, WHITE, 905, 845)
# BTNS MENU
if start_button.draw(screen):
start_game = True
Expand All @@ -698,6 +703,7 @@ def update(self):
draw_bg()
world.draw()
health_bar.draw(player.health)
draw_text('HEALTH', font, WHITE, 46, 12)
draw_text('AMMO: ', font, WHITE, 10, 35)
for x in range(player.ammo):
screen.blit(bullet_img, (90 + (x * 10), 40))
Expand Down Expand Up @@ -764,11 +770,14 @@ def update(self):
player, health_bar = world.process_data(world_data)
else:
screen_scroll = 0
GAMEOVER.play()
draw_text('YOU DIED!', YOUDIED, WHITE, 260, 150), GAMEOVER.stop()
screen.blit(headdeadhp, (-4, 2))
if restart_button.draw(screen):
MENUSELECT.play()
bg_scroll = 0
world_data = reset_level()
# load in level data and create world
#CREATE WORLD DATA
with open(f'level{level}_data.csv', newline='') as csvfile:
reader = csv.reader(csvfile, delimiter=',')
for x, row in enumerate(reader):
Expand All @@ -780,6 +789,7 @@ def update(self):
for event in pygame.event.get():
# QUIT GAME
if event.type == pygame.QUIT:
MENUSELECT.play()
run = False
# KEYBOARD SETT
if event.type == pygame.KEYDOWN:
Expand Down Expand Up @@ -814,6 +824,7 @@ def update(self):
grenade = False
grenade_thrown = False


pygame.display.update()

pygame.quit()
33 changes: 33 additions & 0 deletions MAINGAME.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# -*- mode: python ; coding: utf-8 -*-

block_cipher = None


a = Analysis(['MAINGAME.py'],
pathex=['C:\\Users\\zakha\\OneDrive\\Pulpit\\Zombioo'],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name='MAINGAME',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=False )
Binary file modified Zombioo.exe
Binary file not shown.

0 comments on commit 008261c

Please sign in to comment.