-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.py
62 lines (47 loc) · 1.98 KB
/
settings.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
import pygame
class Settings:
"""Una clase para guardar toda la configuracion de alien invasion."""
def __init__(self):
"""Inicializa la configuracion del juego"""
# Inicializa los sonidos
pygame.mixer.init()
self.bullet_sound = pygame.mixer.Sound('sounds/laser1.wav')
self.ship_sound = pygame.mixer.Sound('sounds/Explosion_01.wav')
self.alien_sound = pygame.mixer.Sound('sounds/Explosion_02.wav')
self.game_over_sound = pygame.mixer.Sound('sounds/game_over_02.wav')
#Configuracion de la pantalla
self.screen_width = 1200
self.screen_height = 800
self.bg_color = (230, 230, 230)
#Configuración de la nave
self.ship_limit = 3
#Configuracion de las balas
self.bullet_width = 3
self.bullet_height = 15
self.bullet_color = (60, 60 ,60)
self.bullets_allowed = 3
# Configuraciones del alien.
self.fleet_drop_speed = 10
# Rapidez con la que se acelera el juego.
self.speedup_scale = 1.1
# Lo rapido que aumenta el valor en puntos de los aliens
self.score_scale = 1.5
# Carga el texto del high_score.txt
self.high_score_txt = 'high_score.txt'
self.initializate_dynamic_settings()
def initializate_dynamic_settings(self):
"""Inicializa las configuraciones que cambian durante el juego."""
self.ship_speed = 1.5
self.bullet_speed = 1.0
self.alien_speed = 1.0
# flet_direction de 1 representa derecha; -1 representa izquierda.
self.fleet_direction = 1
# Puntuacion.
self.alien_points = 50
def increase_speed(self):
"""Incrementa las configuraciones develocidad"""
self.ship_speed *= self.speedup_scale
self.bullet_speed *= self.speedup_scale
self.alien_speed *= self.speedup_scale
self.alien_points = int(self.alien_points * self.score_scale)
#print(self.alien_points)