-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgame.py
More file actions
67 lines (51 loc) · 1.66 KB
/
Copy pathgame.py
File metadata and controls
67 lines (51 loc) · 1.66 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
"Imports"
import pygame
from player import Player
from enemy import Enemy
pygame.init()
pygame.font.init()
# score
myfont = pygame.font.SysFont('Comic Sans MS', 16)
# creare screen
screen = pygame.display.set_mode((800, 600))
clock = pygame.time.Clock()
previous_time = pygame.time.get_ticks()
# backgournd
background = pygame.image.load("background.jpg")
# titlu si logo
pygame.display.set_caption("Invazia Spatiala")
pygame.display.set_icon(pygame.image.load("icon.png"))
# TEST MENU
# menu = pygameMenu.Menu(300, 400, 'Welcome',
# theme=pygameMenu.themes.THEME_BLUE)
# new player
player1 = Player(390, 480, screen, pygame)
# new enemy
enemy01 = Enemy(550, 50, screen, pygame)
screen_rect = screen.get_rect()
# game loop
RUNNING = True
while RUNNING:
# RGB -- RED,GREE,BLUE
screen.fill((0, 0, 0))
# background image
screen.blit(background, (0, 0))
SCORE_DISPLAY = "SCORE: {}".format(player1.score)
textsurface = myfont.render(SCORE_DISPLAY, False, (255, 0, 0))
screen.blit(textsurface, (0, 0))
# TESTING
for event in pygame.event.get():
if event.type == pygame.QUIT:
RUNNING = False
keys_pressed = pygame.key.get_pressed()
player1.move(keys_pressed, screen_rect)
player1.pewpew2(keys_pressed)
player1.player_collision(enemy01)
player1.check_enemy_bullet_collision(enemy01.get_enemy_bullet_rect())
enemy01.set_game_over(player1.return_isOver())
enemy01.reset(player1.bullet_collision(enemy01))
enemy01.move()
player1.draw(myfont)
enemy01.draw()
pygame.display.flip()
pygame.display.update()