-
Notifications
You must be signed in to change notification settings - Fork 0
/
constants.py
82 lines (67 loc) · 2.3 KB
/
constants.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import pygame
import os
pygame.font.init()
# Asteroid data
ASTEROID_VELOCITY = 10
ASTEROID_WIDTH = 60
ASTEROID_HEIGHT = 55
NUM_OF_ASTEROIDS = 8
# Keep the coordinates of asteroids
ASTEROID_X = []
ASTEROID_Y = []
#Spaceship data
RED_X = 100
RED_Y = 350
YELLOW_X = 900
YELLOW_y = 350
SPACESHIP_WIDTH = 55
SPACESHIP_HEIGHT = 45
WIDTH, HEIGHT = 900, 500
VEL = 20
MAX_BULLETS = 10
#Border () create the border between 2 playing areas
BORDER = pygame.Rect(WIDTH/2 - 5, 0, 10, HEIGHT)
# The health bar of 2 players and the font of the word declaring the winner
HEALTH = pygame.font.SysFont('comicsans', 40)
WINNER_FONT = pygame.font.SysFont('comicsans', 100)
#Colors (in BGR)
BLACK = (0,0,0)
RED = (255,0,0)
YELLOW = (255,255,0)
WHITE = (255,255,255)
#BULLER_FIRE_SOUND = pygame.mixer.Sound(os.path.join('resources', 'Gun+Silencer.mp3'))
#Bullet data
red_bullets = []
yellow_bullets = []
bullet_velocity = 68
# The list contains all obstacles
ASTEROIDS = []
# All the event
RED_HIT = pygame.USEREVENT + 1
YELLOW_HIT = pygame.USEREVENT + 2
#Display the window of the game
WIN = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("First game!s")
#FPS (the rate of changing the frames)
FPS = 30
#Display and change some aspects of the asteroid's picture
ASTEROID = pygame.transform.rotate(
pygame.image.load(os.path.join('resources', 'comet.png')), 50)
ASTEROID = pygame.transform.scale(
ASTEROID,(ASTEROID_WIDTH, ASTEROID_HEIGHT))
#Load the spaceship's pictures
YELLOW_SPACESHIP_PIC = pygame.image.load(
os.path.join('resources','spaceship_yellow.png'))
RED_SPACESHIP_PIC = pygame.image.load(
os.path.join('resources','spaceship_red.png'))
#Display and change some aspects of the background's picture
SPACE = pygame.transform.scale(
pygame.image.load(os.path.join('resources', 'space.png')), (900,500))
##Display and change some aspects of the spaceship's picture
YELLOW_SPACESHIP = pygame.transform.rotate(pygame.transform.scale(
YELLOW_SPACESHIP_PIC, (SPACESHIP_WIDTH,SPACESHIP_HEIGHT)), 270)
RED_SPACESHIP = pygame.transform.rotate(pygame.transform.scale(
RED_SPACESHIP_PIC, (SPACESHIP_WIDTH,SPACESHIP_HEIGHT)), 90)
#Create 2 mobile rectangles that will follow our 2 spaceships
red = pygame.Rect(100,100,SPACESHIP_WIDTH,SPACESHIP_HEIGHT)
yellow = pygame.Rect(700,100,SPACESHIP_WIDTH,SPACESHIP_HEIGHT)