My OOP practice project
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

130 lines
3.8 KiB

4 years ago
import pygame
import pygame_menu
import sys
4 years ago
from bullets import Bullet
from beings import *
from surfaces import SlowTimeSurf
from particles import *
4 years ago
######## Set up things that will not change
4 years ago
pygame.init()
pygame.display.set_caption('Healthless')
windowX = 832
windowY = 832
4 years ago
window = pygame.display.set_mode((windowX,windowY))
icon = pygame.image.load('pics/logo.png')
pygame.display.set_icon(icon)
font = pygame.font.Font('freesansbold.ttf', 46)
4 years ago
########
DEBUG = False
4 years ago
################################################################
4 years ago
def play():
4 years ago
FPS = 70
clock = pygame.time.Clock()
pygame.mouse.set_visible(False)
slowsurf = SlowTimeSurf(400,20)
enemy = Enemy(100,100)
enemy2 = Enemy(windowX,200)
player = Player()
4 years ago
death_timer = 70
SCORE = 0
##########################
4 years ago
while True:
4 years ago
for event in pygame.event.get():
if event.type == pygame.QUIT:
gamerun = False
pygame.quit(),sys.exit()
break
window.fill((41, 64, 59))
pygame.draw.rect(window,(0,0,0),(0,720,windowX,5))
if DEBUG == True:
for row in range(0,windowX,32):
pygame.draw.rect(window,(184, 227, 179, 1),(row,0,2,windowY))
for column in range(0,windowY,64):
pygame.draw.rect(window,(184, 227, 179),(0,column,windowX,2))
##########################
4 years ago
#PPPPPPPPPPPPPPPPPPPPPPPPP
slowsurf.place(window)
if slowsurf.collide(player.player_rect):
enemy.vel -= 0.1
enemy2.vel -= 0.1
print("Colliding !")
else:
enemy.vel = 3
enemy2.vel = 3
player.teleportation()
player.shoot(window)
player.draw(window)
player.update()
player.collision(window)
4 years ago
if player.out_of_area():
death_timer -= 1
timertext_color = (255-death_timer-60,3.6*death_timer,10)
text = font.render(str(death_timer), True, timertext_color)
window.blit(text,(windowX//2,windowY//2 - 100))
if death_timer <= 1:
4 years ago
print('DED')
break
else:
death_timer = 70
#PPPPPPPPPPPPPPPPPPPPPPPPP
4 years ago
#EEEEEEEEEEEEEEEEEEEEEEEEE
if enemy.alive == True:
enemy.enemy_shoot(window)
enemy.draw(window)
enemy.move('right')
enemy.collision(window)
if enemy.enemy_x >= windowX-10: #That returning thingy
enemy.enemy_x = 5
4 years ago
if enemy2.alive == True:
enemy2.enemy_shoot(window)
enemy2.move('left')
enemy2.draw(window)
enemy2.collision(window)
if enemy2.enemy_x <= 5: #That returning thingy
enemy2.enemy_x = windowX
4 years ago
if enemy.out_of_area() and enemy.alive == True or enemy.enemy_y + enemy.en_height >= 720 and enemy.alive == True:
enemy.alive = False
SCORE += 1
if enemy2.out_of_area() and enemy2.alive == True or enemy2.enemy_y + enemy2.en_height >= 720 and enemy2.alive == True:
enemy2.alive = False
SCORE += 1
if enemy.alive == False and enemy2.alive == False:
print('Win-win')
4 years ago
break
#EEEEEEEEEEEEEEEEEEEEEEEEE
4 years ago
score_font = font.render(str(SCORE), True, (114, 150, 47))
window.blit(score_font,(100,100))
4 years ago
clock.tick(FPS)
4 years ago
pygame.display.update()
4 years ago
pass
4 years ago
##################################################################
4 years ago
def quit():
pygame_menu.events.EXIT
sys.exit()
4 years ago
while True:
4 years ago
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit(),sys.exit()
break
menu = pygame_menu.Menu(windowX,windowY,'Healthless',theme = pygame_menu.themes.THEME_BLUE)
menu.add_button('Play', play)
menu.add_button('Quit', quit)
menu.mainloop(window)