-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
54 lines (40 loc) · 1.45 KB
/
main.py
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
import pygame
import math
from game import Game
pygame.init()
pygame.display.set_caption("Shooter")
screen = pygame.display.set_mode((1080,720))
backround = pygame.image.load("assets/bg.jpg")
banner = pygame.image.load("assets/banner.png")
banner = pygame.transform.scale(banner, (500,500))
banner_rect = banner.get_rect()
banner_rect.x = math.ceil(screen.get_width()/4)
play_button = pygame.image.load("assets/button.png")
play_button = pygame.transform.scale(play_button, (400, 150))
play_button_rect = play_button.get_rect()
play_button_rect.x = math.ceil(screen.get_width()/3.33)
play_button_rect.y = math.ceil(screen.get_height()/2)
running = True
game = Game()
while running:
screen.blit(backround, (0,-200))
if game.is_playing:
game.update(screen)
else:
screen.blit(play_button, play_button_rect)
screen.blit(banner, banner_rect)
pygame.display.flip()
for event in pygame.event.get():
if event.type == pygame.QUIT:
running == False
pygame.quit()
print("Fermeture du jeu")
elif event.type == pygame.KEYDOWN:
game.pressed[event.key] = True
if event.key == pygame.K_SPACE:
game.player.launch_projectile()
elif event.type == pygame.KEYUP:
game.pressed[event.key] = False
elif event.type == pygame.MOUSEBUTTONDOWN:
if play_button_rect.collidepoint(event.pos):
game.start()