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.

73 lines
2.0 KiB

4 years ago
import pygame
import pygame_menu
import sys
import random
import time
from bullets import *
from player import *
from enemy import *
pygame.init()
pygame.display.set_caption('Healthless')
windowX = 600
windowY = 600
window = pygame.display.set_mode((windowX,windowY))
icon = pygame.image.load('pics/logo.png')
pygame.display.set_icon(icon)
4 years ago
######## Load Images
4 years ago
bullet_image = pygame.image.load('pics/second_bullet.png')
enemy_image = pygame.image.load('pics/enemy.png')
player_image = pygame.image.load('pics/player.png')
4 years ago
########
4 years ago
#rand_color = (int(random.randint(0,254)),int(random.randint(0,254)) ,int(random.randint(0,254)))
4 years ago
################################################################
4 years ago
def play():
4 years ago
FPS = 70
clock = pygame.time.Clock()
start_color = (0,0,0)
pygame.mouse.set_visible(False)
enemy = Enemy(10,random.randint(10,250),30,60,30,30) #(100,100,30,60,30,30) x,y,width,height, damage and health ???
player = Player(300,300,10,64,32,100) #(300,300,10,64,32,100) x,y,vel,height,width, health ???
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((0,70,80))
player.debug()
player.shoot(window,start_color,bullet_image)
player.draw(window,start_color,player_image)
player.update(window,start_color,bullet_image)
enemy.draw(window,start_color,enemy_image)
enemy.update()
4 years ago
if player.y == 0: #Just to try a "death"
break
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)