Compare commits
2 Commits
addb0db2f3
...
d7bea9b7c8
Author | SHA1 | Date | |
---|---|---|---|
d7bea9b7c8 | |||
5f72db6e89 |
BIN
sounds/music.mp3
Normal file
BIN
sounds/music.mp3
Normal file
Binary file not shown.
@ -34,6 +34,9 @@ NORMAL_ALPHA = 200
|
|||||||
PRELOCKED_ALPHA = 127
|
PRELOCKED_ALPHA = 127
|
||||||
GHOST_ALPHA = 50
|
GHOST_ALPHA = 50
|
||||||
|
|
||||||
|
# Sound paths
|
||||||
|
MUSIC_PATH = "sounds/music.mp3"
|
||||||
|
|
||||||
# Matrix
|
# Matrix
|
||||||
NB_LINES = 20
|
NB_LINES = 20
|
||||||
NB_COLS = 10
|
NB_COLS = 10
|
||||||
@ -465,6 +468,8 @@ class UI(arcade.Window):
|
|||||||
self.matrix_sprite.top = int(self.matrix_sprite.top)
|
self.matrix_sprite.top = int(self.matrix_sprite.top)
|
||||||
self.matrix_sprite.alpha = 100
|
self.matrix_sprite.alpha = 100
|
||||||
|
|
||||||
|
self.music = arcade.load_sound(MUSIC_PATH)
|
||||||
|
|
||||||
self.actions = {
|
self.actions = {
|
||||||
Status.PLAYING: {
|
Status.PLAYING: {
|
||||||
arcade.key.LEFT: self.move_left,
|
arcade.key.LEFT: self.move_left,
|
||||||
@ -502,6 +507,7 @@ class UI(arcade.Window):
|
|||||||
def new_game(self):
|
def new_game(self):
|
||||||
self.pressed_actions = []
|
self.pressed_actions = []
|
||||||
self.auto_repeat = False
|
self.auto_repeat = False
|
||||||
|
arcade.play_sound(self.music)
|
||||||
self.game.new_game()
|
self.game.new_game()
|
||||||
|
|
||||||
def display_new_level(self, level):
|
def display_new_level(self, level):
|
||||||
@ -635,17 +641,19 @@ class UI(arcade.Window):
|
|||||||
|
|
||||||
def pause(self, delta_time=0):
|
def pause(self, delta_time=0):
|
||||||
print("pause")
|
print("pause")
|
||||||
|
self.game.status = "paused"
|
||||||
|
arcade.stop_sound(self.music)
|
||||||
self.stop_fall()
|
self.stop_fall()
|
||||||
self.cancel_prelock()
|
self.cancel_prelock()
|
||||||
self.pressed_actions = []
|
self.pressed_actions = []
|
||||||
self.stop_autorepeat()
|
self.stop_autorepeat()
|
||||||
self.game.status = "paused"
|
|
||||||
|
|
||||||
def resume(self, delta_time=0):
|
def resume(self, delta_time=0):
|
||||||
|
self.game.status = "playing"
|
||||||
|
arcade.play_sound(self.music)
|
||||||
self.start_fall()
|
self.start_fall()
|
||||||
if self.game.current_piece.prelocked:
|
if self.game.current_piece.prelocked:
|
||||||
arcade.schedule(self.lock, self.game.lock_delay)
|
arcade.schedule(self.lock, self.game.lock_delay)
|
||||||
self.game.status = "playing"
|
|
||||||
|
|
||||||
def on_draw(self):
|
def on_draw(self):
|
||||||
arcade.start_render()
|
arcade.start_render()
|
||||||
@ -686,6 +694,7 @@ class UI(arcade.Window):
|
|||||||
arcade.unschedule(self.repeat_action)
|
arcade.unschedule(self.repeat_action)
|
||||||
self.cancel_prelock()
|
self.cancel_prelock()
|
||||||
self.stop_fall()
|
self.stop_fall()
|
||||||
|
arcade.stop_sound(self.music)
|
||||||
print("game over")
|
print("game over")
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user