Compare commits
No commits in common. "fe69557bc6f8aee14f65992ae02a0dc0a46c711f" and "f013a061b2225a275d9b351fc8607d88e55b2f9f" have entirely different histories.
fe69557bc6
...
f013a061b2
253
TetrArcade.py
253
TetrArcade.py
@ -1,12 +1,10 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import arcade
|
import arcade
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
sys.exit(
|
sys.exit(
|
||||||
str(e)
|
str(e) + """
|
||||||
+ """
|
|
||||||
This game require arcade library.
|
This game require arcade library.
|
||||||
You can install it with:
|
You can install it with:
|
||||||
python -m pip install --user arcade"""
|
python -m pip install --user arcade"""
|
||||||
@ -19,14 +17,14 @@ import os
|
|||||||
import itertools
|
import itertools
|
||||||
import configparser
|
import configparser
|
||||||
|
|
||||||
from tetrislogic import TetrisLogic, Color, Phase, Coord, I_Tetrimino, Movement
|
from tetrislogic import TetrisLogic, Color, State, Coord
|
||||||
|
|
||||||
|
|
||||||
# Constants
|
# Constants
|
||||||
# Matrix
|
# Matrix
|
||||||
LINES = 20
|
NB_LINES = 20
|
||||||
COLLUMNS = 10
|
NB_COLS = 10
|
||||||
NEXT_PIECES = 5
|
NB_NEXT = 5
|
||||||
|
|
||||||
# Delays (seconds)
|
# Delays (seconds)
|
||||||
LOCK_DELAY = 0.5
|
LOCK_DELAY = 0.5
|
||||||
@ -35,9 +33,9 @@ AUTOREPEAT_DELAY = 0.300
|
|||||||
AUTOREPEAT_PERIOD = 0.010
|
AUTOREPEAT_PERIOD = 0.010
|
||||||
|
|
||||||
# Piece init coord
|
# Piece init coord
|
||||||
MATRIX_PIECE_COORD = Coord(4, LINES)
|
MATRIX_PIECE_COORD = Coord(4, NB_LINES)
|
||||||
NEXT_PIECES_COORDS = [Coord(COLLUMNS + 4, LINES - 4 * n - 3) for n in range(COLLUMNS)]
|
NEXT_PIECE_COORDS = [Coord(NB_COLS + 4, NB_LINES - 4 * n - 3) for n in range(NB_NEXT)]
|
||||||
HELD_PIECE_COORD = Coord(-5, LINES - 3)
|
HELD_PIECE_COORD = Coord(-5, NB_LINES - 3)
|
||||||
|
|
||||||
# Window
|
# Window
|
||||||
WINDOW_WIDTH = 800
|
WINDOW_WIDTH = 800
|
||||||
@ -51,7 +49,7 @@ BG_COLOR = (7, 11, 21)
|
|||||||
HIGHLIGHT_TEXT_DISPLAY_DELAY = 0.7
|
HIGHLIGHT_TEXT_DISPLAY_DELAY = 0.7
|
||||||
|
|
||||||
# Transparency (0=invisible, 255=opaque)
|
# Transparency (0=invisible, 255=opaque)
|
||||||
NORMAL_ALPHA = 255
|
NORMAL_ALPHA = 200
|
||||||
PRELOCKED_ALPHA = 100
|
PRELOCKED_ALPHA = 100
|
||||||
GHOST_ALPHA = 30
|
GHOST_ALPHA = 30
|
||||||
MATRIX_BG_ALPHA = 100
|
MATRIX_BG_ALPHA = 100
|
||||||
@ -61,7 +59,7 @@ BAR_ALPHA = 75
|
|||||||
MINO_SIZE = 20
|
MINO_SIZE = 20
|
||||||
MINO_SPRITE_SIZE = 21
|
MINO_SPRITE_SIZE = 21
|
||||||
|
|
||||||
if getattr(sys, "frozen", False):
|
if getattr(sys, 'frozen', False):
|
||||||
# The application is frozen
|
# The application is frozen
|
||||||
PROGRAM_DIR = os.path.dirname(sys.executable)
|
PROGRAM_DIR = os.path.dirname(sys.executable)
|
||||||
else:
|
else:
|
||||||
@ -88,12 +86,9 @@ MINOES_COLOR_ID = {
|
|||||||
Color.PRELOCKED: 7,
|
Color.PRELOCKED: 7,
|
||||||
}
|
}
|
||||||
TEXTURES = arcade.load_textures(
|
TEXTURES = arcade.load_textures(
|
||||||
MINOES_SPRITES_PATH,
|
MINOES_SPRITES_PATH, ((i * MINO_SPRITE_SIZE, 0, MINO_SPRITE_SIZE, MINO_SPRITE_SIZE) for i in range(8))
|
||||||
((i * MINO_SPRITE_SIZE, 0, MINO_SPRITE_SIZE, MINO_SPRITE_SIZE) for i in range(8)),
|
|
||||||
)
|
)
|
||||||
TEXTURES = {color: TEXTURES[i] for color, i in MINOES_COLOR_ID.items()}
|
TEXTURES = {color: TEXTURES[i] for color, i in MINOES_COLOR_ID.items()}
|
||||||
NORMAL_TEXTURE = 0
|
|
||||||
LOCKED_TEXTURE = 1
|
|
||||||
|
|
||||||
# Music
|
# Music
|
||||||
MUSIC_DIR = os.path.join(RESOURCES_DIR, "musics")
|
MUSIC_DIR = os.path.join(RESOURCES_DIR, "musics")
|
||||||
@ -110,19 +105,16 @@ HIGHLIGHT_TEXT_SIZE = 20
|
|||||||
|
|
||||||
# User profile path
|
# User profile path
|
||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
USER_PROFILE_DIR = os.environ.get(
|
USER_PROFILE_DIR = os.environ.get("appdata", os.path.expanduser("~\Appdata\Roaming"))
|
||||||
"appdata", os.path.expanduser("~\Appdata\Roaming")
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
USER_PROFILE_DIR = os.environ.get(
|
USER_PROFILE_DIR = os.environ.get("XDG_DATA_HOME", os.path.expanduser("~/.local/share"))
|
||||||
"XDG_DATA_HOME", os.path.expanduser("~/.local/share")
|
|
||||||
)
|
|
||||||
USER_PROFILE_DIR = os.path.join(USER_PROFILE_DIR, "TetrArcade")
|
USER_PROFILE_DIR = os.path.join(USER_PROFILE_DIR, "TetrArcade")
|
||||||
HIGH_SCORE_PATH = os.path.join(USER_PROFILE_DIR, ".high_score")
|
HIGH_SCORE_PATH = os.path.join(USER_PROFILE_DIR, ".high_score")
|
||||||
CONF_PATH = os.path.join(USER_PROFILE_DIR, "TetrArcade.ini")
|
CONF_PATH = os.path.join(USER_PROFILE_DIR, "TetrArcade.ini")
|
||||||
|
|
||||||
|
|
||||||
class MinoSprite(arcade.Sprite):
|
class MinoSprite(arcade.Sprite):
|
||||||
|
|
||||||
def __init__(self, mino, window, alpha):
|
def __init__(self, mino, window, alpha):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.alpha = alpha
|
self.alpha = alpha
|
||||||
@ -131,15 +123,16 @@ class MinoSprite(arcade.Sprite):
|
|||||||
self.append_texture(TEXTURES[Color.PRELOCKED])
|
self.append_texture(TEXTURES[Color.PRELOCKED])
|
||||||
self.set_texture(0)
|
self.set_texture(0)
|
||||||
|
|
||||||
def refresh(self, x, y, texture=0):
|
def refresh(self, x, y, prelocked=False):
|
||||||
self.scale = self.window.scale
|
self.scale = self.window.scale
|
||||||
size = MINO_SIZE * self.scale
|
size = MINO_SIZE * self.scale
|
||||||
self.left = self.window.matrix.bg.left + x * size
|
self.left = self.window.matrix.bg.left + x * size
|
||||||
self.bottom = self.window.matrix.bg.bottom + y * size
|
self.bottom = self.window.matrix.bg.bottom + y * size
|
||||||
self.set_texture(texture)
|
self.set_texture(prelocked)
|
||||||
|
|
||||||
|
|
||||||
class MinoesSprites(arcade.SpriteList):
|
class MinoesSprites(arcade.SpriteList):
|
||||||
|
|
||||||
def resize(self, scale):
|
def resize(self, scale):
|
||||||
for sprite in self:
|
for sprite in self:
|
||||||
sprite.scale = scale
|
sprite.scale = scale
|
||||||
@ -147,6 +140,7 @@ class MinoesSprites(arcade.SpriteList):
|
|||||||
|
|
||||||
|
|
||||||
class TetrominoSprites(MinoesSprites):
|
class TetrominoSprites(MinoesSprites):
|
||||||
|
|
||||||
def __init__(self, tetromino, window, alpha=NORMAL_ALPHA):
|
def __init__(self, tetromino, window, alpha=NORMAL_ALPHA):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.tetromino = tetromino
|
self.tetromino = tetromino
|
||||||
@ -155,13 +149,14 @@ class TetrominoSprites(MinoesSprites):
|
|||||||
mino.sprite = MinoSprite(mino, window, alpha)
|
mino.sprite = MinoSprite(mino, window, alpha)
|
||||||
self.append(mino.sprite)
|
self.append(mino.sprite)
|
||||||
|
|
||||||
def refresh(self, texture=NORMAL_TEXTURE):
|
def refresh(self):
|
||||||
for mino in self.tetromino:
|
for mino in self.tetromino:
|
||||||
coord = mino.coord + self.tetromino.coord
|
coord = mino.coord + self.tetromino.coord
|
||||||
mino.sprite.refresh(coord.x, coord.y, texture)
|
mino.sprite.refresh(coord.x, coord.y, self.tetromino.prelocked)
|
||||||
|
|
||||||
|
|
||||||
class MatrixSprites(MinoesSprites):
|
class MatrixSprites(MinoesSprites):
|
||||||
|
|
||||||
def __init__(self, matrix):
|
def __init__(self, matrix):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.matrix = matrix
|
self.matrix = matrix
|
||||||
@ -180,6 +175,7 @@ class MatrixSprites(MinoesSprites):
|
|||||||
|
|
||||||
|
|
||||||
class TetrArcade(TetrisLogic, arcade.Window):
|
class TetrArcade(TetrisLogic, arcade.Window):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
locale.setlocale(locale.LC_ALL, "")
|
locale.setlocale(locale.LC_ALL, "")
|
||||||
self.highlight_texts = []
|
self.highlight_texts = []
|
||||||
@ -196,7 +192,7 @@ class TetrArcade(TetrisLogic, arcade.Window):
|
|||||||
self.new_conf()
|
self.new_conf()
|
||||||
self.load_conf()
|
self.load_conf()
|
||||||
|
|
||||||
super().__init__(LINES, COLLUMNS, NEXT_PIECES)
|
super().__init__(NB_LINES, NB_COLS, NB_NEXT)
|
||||||
arcade.Window.__init__(
|
arcade.Window.__init__(
|
||||||
self,
|
self,
|
||||||
width=self.init_width,
|
width=self.init_width,
|
||||||
@ -223,21 +219,16 @@ class TetrArcade(TetrisLogic, arcade.Window):
|
|||||||
try:
|
try:
|
||||||
self.music = pyglet.media.Player()
|
self.music = pyglet.media.Player()
|
||||||
playlist = itertools.cycle(
|
playlist = itertools.cycle(
|
||||||
pyglet.media.load(path) for path in MUSICS_PATHS
|
pyglet.media.load(path)
|
||||||
|
for path in MUSICS_PATHS
|
||||||
)
|
)
|
||||||
self.music.queue(playlist)
|
self.music.queue(playlist)
|
||||||
except:
|
except:
|
||||||
Warning("Can't play music.")
|
Warning("Can't play music.")
|
||||||
self.music = None
|
self.play_music = False
|
||||||
else:
|
|
||||||
self.music = None
|
|
||||||
|
|
||||||
def new_conf(self):
|
def new_conf(self):
|
||||||
self.conf["WINDOW"] = {
|
self.conf["WINDOW"] = {"width": WINDOW_WIDTH, "height": WINDOW_HEIGHT, "fullscreen": False}
|
||||||
"width": WINDOW_WIDTH,
|
|
||||||
"height": WINDOW_HEIGHT,
|
|
||||||
"fullscreen": False,
|
|
||||||
}
|
|
||||||
self.conf["KEYBOARD"] = {
|
self.conf["KEYBOARD"] = {
|
||||||
"start": "ENTER",
|
"start": "ENTER",
|
||||||
"move left": "LEFT",
|
"move left": "LEFT",
|
||||||
@ -250,7 +241,9 @@ class TetrArcade(TetrisLogic, arcade.Window):
|
|||||||
"pause": "ESCAPE",
|
"pause": "ESCAPE",
|
||||||
"fullscreen": "F11",
|
"fullscreen": "F11",
|
||||||
}
|
}
|
||||||
self.conf["MUSIC"] = {"play": True}
|
self.conf["MUSIC"] = {
|
||||||
|
"play": True
|
||||||
|
}
|
||||||
self.conf["AUTO-REPEAT"] = {"delay": 0.3, "period": 0.01}
|
self.conf["AUTO-REPEAT"] = {"delay": 0.3, "period": 0.01}
|
||||||
self.load_conf()
|
self.load_conf()
|
||||||
if not os.path.exists(USER_PROFILE_DIR):
|
if not os.path.exists(USER_PROFILE_DIR):
|
||||||
@ -266,61 +259,28 @@ class TetrArcade(TetrisLogic, arcade.Window):
|
|||||||
for action, key in self.conf["KEYBOARD"].items():
|
for action, key in self.conf["KEYBOARD"].items():
|
||||||
self.conf["KEYBOARD"][action] = key.upper()
|
self.conf["KEYBOARD"][action] = key.upper()
|
||||||
self.key_map = {
|
self.key_map = {
|
||||||
Phase.STARTING: {
|
State.STARTING: {
|
||||||
getattr(arcade.key, self.conf["KEYBOARD"]["start"]): self.new_game,
|
getattr(arcade.key, self.conf["KEYBOARD"]["start"]): self.new_game,
|
||||||
getattr(
|
getattr(arcade.key, self.conf["KEYBOARD"]["fullscreen"]): self.toggle_fullscreen,
|
||||||
arcade.key, self.conf["KEYBOARD"]["fullscreen"]
|
|
||||||
): self.toggle_fullscreen,
|
|
||||||
},
|
},
|
||||||
Phase.FALLING: {
|
State.PLAYING: {
|
||||||
getattr(arcade.key, self.conf["KEYBOARD"]["move left"]): self.move_left,
|
getattr(arcade.key, self.conf["KEYBOARD"]["move left"]): self.move_left,
|
||||||
getattr(
|
getattr(arcade.key, self.conf["KEYBOARD"]["move right"]): self.move_right,
|
||||||
arcade.key, self.conf["KEYBOARD"]["move right"]
|
|
||||||
): self.move_right,
|
|
||||||
getattr(arcade.key, self.conf["KEYBOARD"]["soft drop"]): self.soft_drop,
|
getattr(arcade.key, self.conf["KEYBOARD"]["soft drop"]): self.soft_drop,
|
||||||
getattr(arcade.key, self.conf["KEYBOARD"]["hard drop"]): self.hard_drop,
|
getattr(arcade.key, self.conf["KEYBOARD"]["hard drop"]): self.hard_drop,
|
||||||
getattr(
|
getattr(arcade.key, self.conf["KEYBOARD"]["rotate clockwise"]): self.rotate_clockwise,
|
||||||
arcade.key, self.conf["KEYBOARD"]["rotate clockwise"]
|
getattr(arcade.key, self.conf["KEYBOARD"]["rotate counter"]): self.rotate_counter,
|
||||||
): self.rotate_clockwise,
|
getattr(arcade.key, self.conf["KEYBOARD"]["hold"]): self.swap,
|
||||||
getattr(
|
|
||||||
arcade.key, self.conf["KEYBOARD"]["rotate counter"]
|
|
||||||
): self.rotate_counter,
|
|
||||||
getattr(arcade.key, self.conf["KEYBOARD"]["hold"]): self.hold,
|
|
||||||
getattr(arcade.key, self.conf["KEYBOARD"]["pause"]): self.pause,
|
getattr(arcade.key, self.conf["KEYBOARD"]["pause"]): self.pause,
|
||||||
getattr(
|
getattr(arcade.key, self.conf["KEYBOARD"]["fullscreen"]): self.toggle_fullscreen,
|
||||||
arcade.key, self.conf["KEYBOARD"]["fullscreen"]
|
|
||||||
): self.toggle_fullscreen,
|
|
||||||
},
|
},
|
||||||
Phase.LOCK: {
|
State.PAUSED: {
|
||||||
getattr(arcade.key, self.conf["KEYBOARD"]["move left"]): self.move_left,
|
|
||||||
getattr(
|
|
||||||
arcade.key, self.conf["KEYBOARD"]["move right"]
|
|
||||||
): self.move_right,
|
|
||||||
getattr(arcade.key, self.conf["KEYBOARD"]["soft drop"]): self.soft_drop,
|
|
||||||
getattr(arcade.key, self.conf["KEYBOARD"]["hard drop"]): self.hard_drop,
|
|
||||||
getattr(
|
|
||||||
arcade.key, self.conf["KEYBOARD"]["rotate clockwise"]
|
|
||||||
): self.rotate_clockwise,
|
|
||||||
getattr(
|
|
||||||
arcade.key, self.conf["KEYBOARD"]["rotate counter"]
|
|
||||||
): self.rotate_counter,
|
|
||||||
getattr(arcade.key, self.conf["KEYBOARD"]["hold"]): self.hold,
|
|
||||||
getattr(arcade.key, self.conf["KEYBOARD"]["pause"]): self.pause,
|
|
||||||
getattr(
|
|
||||||
arcade.key, self.conf["KEYBOARD"]["fullscreen"]
|
|
||||||
): self.toggle_fullscreen,
|
|
||||||
},
|
|
||||||
Phase.PAUSED: {
|
|
||||||
getattr(arcade.key, self.conf["KEYBOARD"]["pause"]): self.resume,
|
getattr(arcade.key, self.conf["KEYBOARD"]["pause"]): self.resume,
|
||||||
getattr(
|
getattr(arcade.key, self.conf["KEYBOARD"]["fullscreen"]): self.toggle_fullscreen,
|
||||||
arcade.key, self.conf["KEYBOARD"]["fullscreen"]
|
|
||||||
): self.toggle_fullscreen,
|
|
||||||
},
|
},
|
||||||
Phase.OVER: {
|
State.OVER: {
|
||||||
getattr(arcade.key, self.conf["KEYBOARD"]["start"]): self.new_game,
|
getattr(arcade.key, self.conf["KEYBOARD"]["start"]): self.new_game,
|
||||||
getattr(
|
getattr(arcade.key, self.conf["KEYBOARD"]["fullscreen"]): self.toggle_fullscreen,
|
||||||
arcade.key, self.conf["KEYBOARD"]["fullscreen"]
|
|
||||||
): self.toggle_fullscreen,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -331,21 +291,12 @@ class TetrArcade(TetrisLogic, arcade.Window):
|
|||||||
"\n\n\nCONTROLS\n\n"
|
"\n\n\nCONTROLS\n\n"
|
||||||
+ "\n".join(
|
+ "\n".join(
|
||||||
"{:<16s}{:>6s}".format(key, action)
|
"{:<16s}{:>6s}".format(key, action)
|
||||||
for key, action in tuple(self.conf["KEYBOARD"].items())
|
for key, action in tuple(self.conf["KEYBOARD"].items()) + (("QUIT", "ALT+F4"),)
|
||||||
+ (("QUIT", "ALT+F4"),)
|
|
||||||
)
|
)
|
||||||
+ "\n\n\n"
|
+ "\n\n\n"
|
||||||
)
|
)
|
||||||
self.start_text = (
|
self.start_text = "TETRARCADE" + controls_text + "PRESS [{}] TO START".format(self.conf["KEYBOARD"]["start"])
|
||||||
"TETRARCADE"
|
self.pause_text = "PAUSE" + controls_text + "PRESS [{}] TO RESUME".format(self.conf["KEYBOARD"]["pause"])
|
||||||
+ controls_text
|
|
||||||
+ "PRESS [{}] TO START".format(self.conf["KEYBOARD"]["start"])
|
|
||||||
)
|
|
||||||
self.pause_text = (
|
|
||||||
"PAUSE"
|
|
||||||
+ controls_text
|
|
||||||
+ "PRESS [{}] TO RESUME".format(self.conf["KEYBOARD"]["pause"])
|
|
||||||
)
|
|
||||||
self.game_over_text = """GAME
|
self.game_over_text = """GAME
|
||||||
OVER
|
OVER
|
||||||
|
|
||||||
@ -358,73 +309,74 @@ AGAIN""".format(
|
|||||||
|
|
||||||
self.play_music = self.conf["MUSIC"].getboolean("play")
|
self.play_music = self.conf["MUSIC"].getboolean("play")
|
||||||
|
|
||||||
def on_new_game(self, next_pieces):
|
def on_new_game(self):
|
||||||
self.highlight_texts = []
|
self.highlight_texts = []
|
||||||
|
|
||||||
self.matrix.sprites = MatrixSprites(self.matrix)
|
self.matrix.sprites = MatrixSprites(self.matrix)
|
||||||
for piece in next_pieces:
|
if self.play_music:
|
||||||
piece.sprites = TetrominoSprites(piece, self)
|
|
||||||
|
|
||||||
if self.music:
|
|
||||||
self.music.seek(0)
|
self.music.seek(0)
|
||||||
self.music.play()
|
self.music.play()
|
||||||
|
|
||||||
|
def on_new_piece(self, piece):
|
||||||
|
piece.sprites = TetrominoSprites(piece, self)
|
||||||
|
|
||||||
def on_new_level(self, level):
|
def on_new_level(self, level):
|
||||||
self.show_text("LEVEL\n{:n}".format(level))
|
self.show_text("LEVEL\n{:n}".format(level))
|
||||||
|
|
||||||
def on_generation_phase(self, matrix, falling_piece, ghost_piece, next_pieces):
|
def on_generation_phase(self, piece):
|
||||||
matrix.sprites.refresh()
|
self.matrix.sprites.refresh()
|
||||||
falling_piece.sprites = TetrominoSprites(falling_piece, self)
|
self.matrix.ghost.sprites = TetrominoSprites(self.matrix.ghost, self, GHOST_ALPHA)
|
||||||
ghost_piece.sprites = TetrominoSprites(ghost_piece, self, GHOST_ALPHA)
|
for tetromino in [self.matrix.piece, self.matrix.ghost] + self.next.pieces:
|
||||||
next_pieces[-1].sprites = TetrominoSprites(next_pieces[-1], self)
|
tetromino.sprites.refresh()
|
||||||
for piece, coord in zip(next_pieces, NEXT_PIECES_COORDS):
|
|
||||||
piece.coord = coord
|
|
||||||
piece.sprites.refresh()
|
|
||||||
|
|
||||||
def on_falling_phase(self, falling_piece, ghost_piece):
|
def on_falling_phase(self):
|
||||||
falling_piece.sprites.refresh()
|
self.matrix.piece.sprites.refresh()
|
||||||
ghost_piece.sprites.refresh()
|
|
||||||
|
|
||||||
def on_lock_phase(self, locked_piece):
|
def on_moved(self, moved):
|
||||||
locked_piece.sprites.refresh(texture=LOCKED_TEXTURE)
|
self.matrix.piece.sprites.refresh()
|
||||||
|
self.matrix.ghost.sprites.refresh()
|
||||||
|
|
||||||
def on_locked(self, matrix, locked_piece):
|
def on_rotated(self, direction):
|
||||||
for mino in locked_piece:
|
for tetromino in (self.matrix.piece, self.matrix.ghost):
|
||||||
matrix.sprites.append(mino.sprite)
|
tetromino.sprites.refresh()
|
||||||
|
|
||||||
def on_line_remove(self, matrix, y):
|
def on_lock_phase(self):
|
||||||
matrix.sprites.remove_line(y)
|
self.matrix.piece.sprites.refresh()
|
||||||
|
self.matrix.sprites.refresh()
|
||||||
|
|
||||||
def on_pattern_phase(self, pattern_name, pattern_score, nb_combo, combo_score):
|
def on_locked(self, piece):
|
||||||
if pattern_score:
|
piece.sprites.refresh()
|
||||||
self.show_text("{:s}\n{:n}".format(pattern_name, pattern_score))
|
for mino in piece:
|
||||||
if combo_score:
|
self.matrix.sprites.append(mino.sprite)
|
||||||
self.show_text("COMBO x{:n}\n{:n}".format(nb_combo, combo_score))
|
|
||||||
|
|
||||||
def on_hold(self, held_piece):
|
def on_line_remove(self, y):
|
||||||
held_piece.coord = HELD_PIECE_COORD
|
self.matrix.sprites.remove_line(y)
|
||||||
if type(held_piece) == I_Tetrimino:
|
|
||||||
held_piece.coord += Movement.LEFT
|
def swap(self):
|
||||||
held_piece.sprites.refresh()
|
super().swap()
|
||||||
|
self.matrix.ghost.sprites = TetrominoSprites(self.matrix.ghost, self, GHOST_ALPHA)
|
||||||
|
for tetromino in (self.held.piece, self.matrix.piece, self.matrix.ghost):
|
||||||
|
if tetromino:
|
||||||
|
tetromino.sprites.refresh()
|
||||||
|
|
||||||
def pause(self):
|
def pause(self):
|
||||||
super().pause()
|
super().pause()
|
||||||
if self.music:
|
if self.play_music:
|
||||||
self.music.pause()
|
self.music.pause()
|
||||||
|
|
||||||
def resume(self):
|
def resume(self):
|
||||||
super().resume()
|
super().resume()
|
||||||
if self.music:
|
if self.play_music:
|
||||||
self.music.play()
|
self.music.play()
|
||||||
|
|
||||||
def on_game_over(self):
|
def game_over(self):
|
||||||
if self.music:
|
super().game_over()
|
||||||
|
if self.play_music:
|
||||||
self.music.pause()
|
self.music.pause()
|
||||||
|
|
||||||
def on_key_press(self, key, modifiers):
|
def on_key_press(self, key, modifiers):
|
||||||
for key_or_modifier in (key, modifiers):
|
for key_or_modifier in (key, modifiers):
|
||||||
try:
|
try:
|
||||||
action = self.key_map[self.phase][key_or_modifier]
|
action = self.key_map[self.state][key_or_modifier]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
@ -433,7 +385,7 @@ AGAIN""".format(
|
|||||||
def on_key_release(self, key, modifiers):
|
def on_key_release(self, key, modifiers):
|
||||||
for key_or_modifier in (key, modifiers):
|
for key_or_modifier in (key, modifiers):
|
||||||
try:
|
try:
|
||||||
action = self.key_map[self.phase][key_or_modifier]
|
action = self.key_map[self.state][key_or_modifier]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
@ -453,29 +405,22 @@ AGAIN""".format(
|
|||||||
arcade.start_render()
|
arcade.start_render()
|
||||||
self.bg.draw()
|
self.bg.draw()
|
||||||
|
|
||||||
if self.phase not in (Phase.STARTING, Phase.PAUSED):
|
if self.state in (State.PLAYING, State.OVER):
|
||||||
self.matrix.bg.draw()
|
self.matrix.bg.draw()
|
||||||
self.held.bg.draw()
|
self.held.bg.draw()
|
||||||
self.next.bg.draw()
|
self.next.bg.draw()
|
||||||
self.matrix.sprites.draw()
|
self.matrix.sprites.draw()
|
||||||
|
|
||||||
for tetromino in [
|
for tetromino in [self.held.piece, self.matrix.piece, self.matrix.ghost] + self.next.pieces:
|
||||||
self.held.piece,
|
|
||||||
self.matrix.piece,
|
|
||||||
self.matrix.ghost,
|
|
||||||
] + self.next.pieces:
|
|
||||||
if tetromino:
|
if tetromino:
|
||||||
tetromino.sprites.draw()
|
tetromino.sprites.draw()
|
||||||
|
|
||||||
t = time.localtime(self.stats.time)
|
t = time.localtime(self.stats.time)
|
||||||
font_size = STATS_TEXT_SIZE * self.scale
|
font_size = STATS_TEXT_SIZE * self.scale
|
||||||
for y, text in enumerate(
|
for y, text in enumerate(("TIME", "LINES", "GOAL", "LEVEL", "HIGH SCORE", "SCORE")):
|
||||||
("TIME", "LINES", "GOAL", "LEVEL", "HIGH SCORE", "SCORE")
|
|
||||||
):
|
|
||||||
arcade.draw_text(
|
arcade.draw_text(
|
||||||
text=text,
|
text=text,
|
||||||
start_x=self.matrix.bg.left
|
start_x=self.matrix.bg.left - self.scale * (STATS_TEXT_MARGIN + STATS_TEXT_WIDTH),
|
||||||
- self.scale * (STATS_TEXT_MARGIN + STATS_TEXT_WIDTH),
|
|
||||||
start_y=self.matrix.bg.bottom + 1.5 * (2 * y + 1) * font_size,
|
start_y=self.matrix.bg.bottom + 1.5 * (2 * y + 1) * font_size,
|
||||||
color=TEXT_COLOR,
|
color=TEXT_COLOR,
|
||||||
font_size=font_size,
|
font_size=font_size,
|
||||||
@ -505,11 +450,11 @@ AGAIN""".format(
|
|||||||
)
|
)
|
||||||
|
|
||||||
highlight_text = {
|
highlight_text = {
|
||||||
Phase.STARTING: self.start_text,
|
State.STARTING: self.start_text,
|
||||||
Phase.FALLING: self.highlight_texts[0] if self.highlight_texts else "",
|
State.PLAYING: self.highlight_texts[0] if self.highlight_texts else "",
|
||||||
Phase.PAUSED: self.pause_text,
|
State.PAUSED: self.pause_text,
|
||||||
Phase.OVER: self.game_over_text,
|
State.OVER: self.game_over_text,
|
||||||
}.get(self.phase, "")
|
}.get(self.state, "")
|
||||||
if highlight_text:
|
if highlight_text:
|
||||||
arcade.draw_text(
|
arcade.draw_text(
|
||||||
text=highlight_text,
|
text=highlight_text,
|
||||||
@ -555,11 +500,7 @@ AGAIN""".format(
|
|||||||
|
|
||||||
self.matrix.sprites.resize(self.scale)
|
self.matrix.sprites.resize(self.scale)
|
||||||
|
|
||||||
for tetromino in [
|
for tetromino in [self.held.piece, self.matrix.piece, self.matrix.ghost] + self.next.pieces:
|
||||||
self.held.piece,
|
|
||||||
self.matrix.piece,
|
|
||||||
self.matrix.ghost,
|
|
||||||
] + self.next.pieces:
|
|
||||||
if tetromino:
|
if tetromino:
|
||||||
tetromino.sprites.resize(self.scale)
|
tetromino.sprites.resize(self.scale)
|
||||||
|
|
||||||
@ -614,7 +555,7 @@ High score could not be saved:
|
|||||||
|
|
||||||
def on_close(self):
|
def on_close(self):
|
||||||
self.save_high_score()
|
self.save_high_score()
|
||||||
if self.music:
|
if self.play_music:
|
||||||
self.music.pause()
|
self.music.pause()
|
||||||
super().on_close()
|
super().on_close()
|
||||||
|
|
||||||
|
30
setup.py
30
setup.py
@ -9,14 +9,20 @@ else:
|
|||||||
base = None
|
base = None
|
||||||
icon = None
|
icon = None
|
||||||
|
|
||||||
excludes = ["tkinter", "PyQt4", "PyQt5", "PySide", "PySide2"]
|
excludes = [
|
||||||
|
"tkinter",
|
||||||
|
"PyQt4",
|
||||||
|
"PyQt5",
|
||||||
|
"PySide",
|
||||||
|
"PySide2"
|
||||||
|
]
|
||||||
|
|
||||||
executable = Executable(
|
executable = Executable(
|
||||||
script="TetrArcade.py",
|
script = "TetrArcade.py",
|
||||||
icon=icon,
|
icon = icon,
|
||||||
base=base,
|
base = base,
|
||||||
shortcutName="TetrArcade",
|
shortcutName="TetrArcade",
|
||||||
shortcutDir="DesktopFolder",
|
shortcutDir="DesktopFolder"
|
||||||
)
|
)
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
@ -24,14 +30,14 @@ options = {
|
|||||||
"packages": ["arcade", "pyglet"],
|
"packages": ["arcade", "pyglet"],
|
||||||
"excludes": excludes,
|
"excludes": excludes,
|
||||||
"include_files": "resources",
|
"include_files": "resources",
|
||||||
"silent": True,
|
"silent": True
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setup(
|
setup(
|
||||||
name="TetrArcade",
|
name = "TetrArcade",
|
||||||
version="0.3",
|
version = "0.3",
|
||||||
description="Tetris clone",
|
description = "Tetris clone",
|
||||||
author="AdrienMalin",
|
author = "AdrienMalin",
|
||||||
executables=[executable],
|
executables = [executable],
|
||||||
options=options,
|
options = options,
|
||||||
)
|
)
|
||||||
|
13
test.py
13
test.py
@ -1,6 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from TetrArcade import TetrArcade, Phase, MinoSprite
|
from TetrArcade import TetrArcade, State, MinoSprite
|
||||||
from tetrislogic import Mino, Color, Coord
|
from tetrislogic import Mino, Color, Coord
|
||||||
|
|
||||||
game = TetrArcade()
|
game = TetrArcade()
|
||||||
@ -14,17 +14,12 @@ game.move_left()
|
|||||||
game.pause()
|
game.pause()
|
||||||
game.resume()
|
game.resume()
|
||||||
game.move_right()
|
game.move_right()
|
||||||
game.hold()
|
game.swap()
|
||||||
game.rotate_clockwise()
|
game.rotate_clockwise()
|
||||||
game.hold()
|
|
||||||
game.rotate_counter()
|
game.rotate_counter()
|
||||||
for i in range(22):
|
for i in range(12):
|
||||||
game.soft_drop()
|
game.soft_drop()
|
||||||
game.on_draw()
|
|
||||||
game.lock_phase()
|
|
||||||
game.hold()
|
|
||||||
game.matrix.sprites.refresh()
|
game.matrix.sprites.refresh()
|
||||||
game.on_draw()
|
game.on_draw()
|
||||||
while game.phase != Phase.OVER:
|
while game.state != State.OVER:
|
||||||
game.hard_drop()
|
game.hard_drop()
|
||||||
game.on_draw()
|
|
||||||
|
@ -1,15 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from .consts import LINES, COLLUMNS, NEXT_PIECES
|
from .consts import LINES, COLLUMNS, NEXT_PIECES
|
||||||
from .utils import Movement, Rotation, Color, Coord, Phase
|
from .utils import Movement, Rotation, Color, Coord
|
||||||
from .tetromino import (
|
from .tetromino import Mino, Tetromino
|
||||||
Mino,
|
from .tetrislogic import TetrisLogic, State, Matrix
|
||||||
Tetromino,
|
|
||||||
I_Tetrimino,
|
|
||||||
J_Tetrimino,
|
|
||||||
L_Tetrimino,
|
|
||||||
O_Tetrimino,
|
|
||||||
S_Tetrimino,
|
|
||||||
T_Tetrimino,
|
|
||||||
Z_Tetrimino,
|
|
||||||
)
|
|
||||||
from .tetrislogic import TetrisLogic, Matrix
|
|
||||||
|
@ -15,3 +15,5 @@ AUTOREPEAT_PERIOD = 0.010 # Official : 0.010 s
|
|||||||
|
|
||||||
# Piece init coord
|
# Piece init coord
|
||||||
MATRIX_PIECE_COORD = Coord(4, LINES)
|
MATRIX_PIECE_COORD = Coord(4, LINES)
|
||||||
|
NEXT_PIECE_COORDS = [Coord(COLLUMNS + 4, LINES - 4 * n - 3) for n in range(NEXT_PIECES)]
|
||||||
|
HELD_PIECE_COORD = Coord(-5, LINES - 3)
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
import random
|
||||||
import pickle
|
import pickle
|
||||||
|
|
||||||
from .utils import Coord, Movement, Rotation, T_Spin, Phase
|
from .utils import Coord, Movement, Rotation, T_Spin
|
||||||
from .tetromino import Tetromino, T_Tetrimino
|
from .tetromino import Tetromino, T_Tetrimino, I_Tetrimino
|
||||||
from .consts import (
|
from .consts import (
|
||||||
LINES,
|
LINES,
|
||||||
COLLUMNS,
|
COLLUMNS,
|
||||||
@ -12,6 +13,8 @@ from .consts import (
|
|||||||
AUTOREPEAT_DELAY,
|
AUTOREPEAT_DELAY,
|
||||||
AUTOREPEAT_PERIOD,
|
AUTOREPEAT_PERIOD,
|
||||||
MATRIX_PIECE_COORD,
|
MATRIX_PIECE_COORD,
|
||||||
|
NEXT_PIECE_COORDS,
|
||||||
|
HELD_PIECE_COORD,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -19,7 +22,16 @@ LINES_CLEAR_NAME = "LINES_CLEAR_NAME"
|
|||||||
CRYPT_KEY = 987943759387540938469837689379857347598347598379584857934579343
|
CRYPT_KEY = 987943759387540938469837689379857347598347598379584857934579343
|
||||||
|
|
||||||
|
|
||||||
|
class State:
|
||||||
|
|
||||||
|
STARTING = "STARTING"
|
||||||
|
PLAYING = "PLAYING"
|
||||||
|
PAUSED = "PAUSED"
|
||||||
|
OVER = "OVER"
|
||||||
|
|
||||||
|
|
||||||
class PieceContainer:
|
class PieceContainer:
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.piece = None
|
self.piece = None
|
||||||
|
|
||||||
@ -29,12 +41,12 @@ class HoldQueue(PieceContainer):
|
|||||||
|
|
||||||
|
|
||||||
class Matrix(list, PieceContainer):
|
class Matrix(list, PieceContainer):
|
||||||
|
|
||||||
def __init__(self, lines, collumns):
|
def __init__(self, lines, collumns):
|
||||||
list.__init__(self)
|
list.__init__(self)
|
||||||
PieceContainer.__init__(self)
|
PieceContainer.__init__(self)
|
||||||
self.lines = lines
|
self.lines = lines
|
||||||
self.collumns = collumns
|
self.collumns = collumns
|
||||||
self.ghost = None
|
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
self.clear()
|
self.clear()
|
||||||
@ -45,12 +57,11 @@ class Matrix(list, PieceContainer):
|
|||||||
self.append([None for x in range(self.collumns)])
|
self.append([None for x in range(self.collumns)])
|
||||||
|
|
||||||
def cell_is_free(self, coord):
|
def cell_is_free(self, coord):
|
||||||
return (
|
return 0 <= coord.x < self.collumns and 0 <= coord.y and not self[coord.y][coord.x]
|
||||||
0 <= coord.x < self.collumns and 0 <= coord.y and not self[coord.y][coord.x]
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class NextQueue(PieceContainer):
|
class NextQueue(PieceContainer):
|
||||||
|
|
||||||
def __init__(self, nb_pieces):
|
def __init__(self, nb_pieces):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.nb_pieces = nb_pieces
|
self.nb_pieces = nb_pieces
|
||||||
@ -59,14 +70,6 @@ class NextQueue(PieceContainer):
|
|||||||
|
|
||||||
class Stats:
|
class Stats:
|
||||||
|
|
||||||
SCORES = (
|
|
||||||
{LINES_CLEAR_NAME: "", T_Spin.NONE: 0, T_Spin.MINI: 1, T_Spin.T_SPIN: 4},
|
|
||||||
{LINES_CLEAR_NAME: "SINGLE", T_Spin.NONE: 1, T_Spin.MINI: 2, T_Spin.T_SPIN: 8},
|
|
||||||
{LINES_CLEAR_NAME: "DOUBLE", T_Spin.NONE: 3, T_Spin.T_SPIN: 12},
|
|
||||||
{LINES_CLEAR_NAME: "TRIPLE", T_Spin.NONE: 5, T_Spin.T_SPIN: 16},
|
|
||||||
{LINES_CLEAR_NAME: "TETRIS", T_Spin.NONE: 8},
|
|
||||||
)
|
|
||||||
|
|
||||||
def _get_score(self):
|
def _get_score(self):
|
||||||
return self._score
|
return self._score
|
||||||
|
|
||||||
@ -103,32 +106,6 @@ class Stats:
|
|||||||
def update_time(self):
|
def update_time(self):
|
||||||
self.time += 1
|
self.time += 1
|
||||||
|
|
||||||
def pattern_phase(self, t_spin, lines_cleared):
|
|
||||||
pattern_name = []
|
|
||||||
pattern_score = 0
|
|
||||||
combo_score = 0
|
|
||||||
|
|
||||||
if t_spin:
|
|
||||||
pattern_name.append(t_spin)
|
|
||||||
if lines_cleared:
|
|
||||||
pattern_name.append(self.SCORES[lines_cleared][LINES_CLEAR_NAME])
|
|
||||||
self.combo += 1
|
|
||||||
else:
|
|
||||||
self.combo = -1
|
|
||||||
|
|
||||||
if lines_cleared or t_spin:
|
|
||||||
pattern_score = self.SCORES[lines_cleared][t_spin]
|
|
||||||
self.goal -= pattern_score
|
|
||||||
pattern_score *= 100 * self.level
|
|
||||||
pattern_name = "\n".join(pattern_name)
|
|
||||||
|
|
||||||
if self.combo >= 1:
|
|
||||||
combo_score = (20 if lines_cleared == 1 else 50) * self.combo * self.level
|
|
||||||
|
|
||||||
self.score += pattern_score + combo_score
|
|
||||||
|
|
||||||
return pattern_name, pattern_score, self.combo, combo_score
|
|
||||||
|
|
||||||
|
|
||||||
class TetrisLogic:
|
class TetrisLogic:
|
||||||
|
|
||||||
@ -138,13 +115,22 @@ class TetrisLogic:
|
|||||||
AUTOREPEAT_DELAY = AUTOREPEAT_DELAY
|
AUTOREPEAT_DELAY = AUTOREPEAT_DELAY
|
||||||
AUTOREPEAT_PERIOD = AUTOREPEAT_PERIOD
|
AUTOREPEAT_PERIOD = AUTOREPEAT_PERIOD
|
||||||
MATRIX_PIECE_COORD = MATRIX_PIECE_COORD
|
MATRIX_PIECE_COORD = MATRIX_PIECE_COORD
|
||||||
|
NEXT_PIECE_COORDS = NEXT_PIECE_COORDS
|
||||||
|
HELD_PIECE_COORD = HELD_PIECE_COORD
|
||||||
|
random_bag = []
|
||||||
|
|
||||||
def __init__(self, lines=LINES, collumns=COLLUMNS, next_pieces=NEXT_PIECES):
|
def __init__(
|
||||||
|
self,
|
||||||
|
lines=LINES,
|
||||||
|
collumns=COLLUMNS,
|
||||||
|
next_pieces=NEXT_PIECES,
|
||||||
|
):
|
||||||
self.stats = Stats()
|
self.stats = Stats()
|
||||||
self.load_high_score()
|
self.load_high_score()
|
||||||
self.phase = Phase.STARTING
|
self.state = State.STARTING
|
||||||
self.held = HoldQueue()
|
self.held = HoldQueue()
|
||||||
self.matrix = Matrix(lines, collumns)
|
self.matrix = Matrix(lines, collumns)
|
||||||
|
self.matrix.ghost = None
|
||||||
self.next = NextQueue(next_pieces)
|
self.next = NextQueue(next_pieces)
|
||||||
self.autorepeatable_actions = (self.move_left, self.move_right, self.soft_drop)
|
self.autorepeatable_actions = (self.move_left, self.move_right, self.soft_drop)
|
||||||
self.pressed_actions = []
|
self.pressed_actions = []
|
||||||
@ -156,19 +142,35 @@ class TetrisLogic:
|
|||||||
self.auto_repeat = False
|
self.auto_repeat = False
|
||||||
|
|
||||||
self.matrix.reset()
|
self.matrix.reset()
|
||||||
self.next.pieces = [Tetromino() for n in range(self.next.nb_pieces)]
|
self.next.pieces = [self.new_piece() for n in range(self.next.nb_pieces)]
|
||||||
self.held.piece = None
|
self.held.piece = None
|
||||||
|
self.state = State.PLAYING
|
||||||
self.start(self.stats.update_time, 1)
|
self.start(self.stats.update_time, 1)
|
||||||
|
|
||||||
self.on_new_game(self.next.pieces)
|
self.on_new_game()
|
||||||
|
|
||||||
self.new_level()
|
self.new_level()
|
||||||
|
|
||||||
def on_new_game(self, next_pieces):
|
def on_new_game(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def new_piece(self):
|
||||||
|
if not self.random_bag:
|
||||||
|
self.random_bag = list(Tetromino.shapes)
|
||||||
|
random.shuffle(self.random_bag)
|
||||||
|
piece = self.random_bag.pop()()
|
||||||
|
self.on_new_piece(piece)
|
||||||
|
return piece
|
||||||
|
|
||||||
|
def on_new_piece(self, piece):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def new_level(self):
|
def new_level(self):
|
||||||
self.stats.new_level()
|
self.stats.new_level()
|
||||||
|
self.restart(self.fall, self.stats.fall_delay)
|
||||||
|
|
||||||
self.on_new_level(self.stats.level)
|
self.on_new_level(self.stats.level)
|
||||||
|
|
||||||
self.generation_phase()
|
self.generation_phase()
|
||||||
|
|
||||||
def on_new_level(self, level):
|
def on_new_level(self, level):
|
||||||
@ -176,133 +178,122 @@ class TetrisLogic:
|
|||||||
|
|
||||||
def generation_phase(self):
|
def generation_phase(self):
|
||||||
self.matrix.piece = self.next.pieces.pop(0)
|
self.matrix.piece = self.next.pieces.pop(0)
|
||||||
self.next.pieces.append(Tetromino())
|
|
||||||
self.matrix.piece.coord = self.MATRIX_PIECE_COORD
|
self.matrix.piece.coord = self.MATRIX_PIECE_COORD
|
||||||
self.matrix.ghost = self.matrix.piece.ghost()
|
self.matrix.ghost = self.matrix.piece.ghost()
|
||||||
|
self.move_ghost()
|
||||||
|
self.next.pieces.append(self.new_piece())
|
||||||
|
self.next.pieces[-1].coord = self.NEXT_PIECE_COORDS[-1]
|
||||||
|
for tetromino, coord in zip(self.next.pieces, self.NEXT_PIECE_COORDS):
|
||||||
|
tetromino.coord = coord
|
||||||
|
|
||||||
self.on_generation_phase(
|
self.on_generation_phase(self.matrix.piece)
|
||||||
self.matrix, self.matrix.piece, self.matrix.ghost, self.next.pieces
|
self.on_falling_phase()
|
||||||
)
|
|
||||||
if not self.move(Movement.DOWN):
|
if not self.can_move(self.matrix.piece.coord, (mino.coord for mino in self.matrix.piece)):
|
||||||
self.game_over()
|
self.game_over()
|
||||||
else:
|
|
||||||
self.restart(self.fall, self.stats.fall_delay)
|
|
||||||
self.falling_phase()
|
|
||||||
|
|
||||||
def on_generation_phase(self, matrix, falling_piece, ghost_piece, next_pieces):
|
def on_generation_phase(self, piece):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def falling_phase(self):
|
def on_falling_phase(self):
|
||||||
self.phase = Phase.FALLING
|
pass
|
||||||
|
|
||||||
|
def move_left(self):
|
||||||
|
self.move(Movement.LEFT)
|
||||||
|
|
||||||
|
def move_right(self):
|
||||||
|
self.move(Movement.RIGHT)
|
||||||
|
|
||||||
|
def rotate_clockwise(self):
|
||||||
|
self.rotate(Rotation.CLOCKWISE)
|
||||||
|
|
||||||
|
def rotate_counter(self):
|
||||||
|
self.rotate(Rotation.COUNTER)
|
||||||
|
|
||||||
|
def move_ghost(self):
|
||||||
self.matrix.ghost.coord = self.matrix.piece.coord
|
self.matrix.ghost.coord = self.matrix.piece.coord
|
||||||
for ghost_mino, current_mino in zip(self.matrix.ghost, self.matrix.piece):
|
for ghost_mino, current_mino in zip(self.matrix.ghost, self.matrix.piece):
|
||||||
ghost_mino.coord = current_mino.coord
|
ghost_mino.coord = current_mino.coord
|
||||||
while self.space_to_move(
|
while self.can_move(self.matrix.ghost.coord + Movement.DOWN, (mino.coord for mino in self.matrix.ghost)):
|
||||||
self.matrix.ghost.coord + Movement.DOWN,
|
|
||||||
(mino.coord for mino in self.matrix.ghost),
|
|
||||||
):
|
|
||||||
self.matrix.ghost.coord += Movement.DOWN
|
self.matrix.ghost.coord += Movement.DOWN
|
||||||
|
|
||||||
self.on_falling_phase(self.matrix.piece, self.matrix.ghost)
|
def soft_drop(self):
|
||||||
|
moved = self.move(Movement.DOWN)
|
||||||
|
if moved:
|
||||||
|
self.stats.score += 1
|
||||||
|
return moved
|
||||||
|
|
||||||
def on_falling_phase(self, falling_piece, ghost_piece):
|
def hard_drop(self):
|
||||||
pass
|
while self.move(Movement.DOWN, prelock=False):
|
||||||
|
self.stats.score += 2
|
||||||
|
self.lock()
|
||||||
|
|
||||||
def fall(self):
|
def fall(self):
|
||||||
self.move(Movement.DOWN)
|
self.move(Movement.DOWN)
|
||||||
|
|
||||||
def move(self, movement, rotated_coords=None, lock=True):
|
def move(self, movement, prelock=True):
|
||||||
potential_coord = self.matrix.piece.coord + movement
|
potential_coord = self.matrix.piece.coord + movement
|
||||||
if self.space_to_move(
|
if self.can_move(potential_coord, (mino.coord for mino in self.matrix.piece)):
|
||||||
potential_coord,
|
if self.matrix.piece.prelocked:
|
||||||
rotated_coords or (mino.coord for mino in self.matrix.piece),
|
self.restart(self.lock, self.stats.lock_delay)
|
||||||
):
|
|
||||||
self.matrix.piece.coord = potential_coord
|
self.matrix.piece.coord = potential_coord
|
||||||
if rotated_coords:
|
if not movement == Movement.DOWN:
|
||||||
for mino, coord in zip(self.matrix.piece, rotated_coords):
|
self.matrix.piece.last_rotation_point = None
|
||||||
mino.coord = coord
|
self.move_ghost()
|
||||||
else:
|
self.on_moved(movement)
|
||||||
if movement != Movement.DOWN:
|
|
||||||
self.matrix.piece.last_rotation_point = None
|
|
||||||
if self.phase == Phase.LOCK:
|
|
||||||
self.restart(self.pattern_phase, self.stats.lock_delay)
|
|
||||||
self.falling_phase()
|
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
if lock and self.phase != Phase.LOCK and movement == Movement.DOWN:
|
if prelock and not self.matrix.piece.prelocked and movement == Movement.DOWN:
|
||||||
self.lock_phase()
|
self.matrix.piece.prelocked = True
|
||||||
|
self.start(self.lock, self.stats.lock_delay)
|
||||||
|
self.on_lock_phase()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def lock_phase(self):
|
def on_moved(self, movement):
|
||||||
self.phase = Phase.LOCK
|
|
||||||
self.on_lock_phase(self.matrix.piece)
|
|
||||||
self.start(self.pattern_phase, self.stats.lock_delay)
|
|
||||||
|
|
||||||
def on_lock_phase(self, locked_piece):
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def space_to_move(self, potential_coord, minoes_coord):
|
|
||||||
return all(
|
|
||||||
self.matrix.cell_is_free(potential_coord + mino_coord)
|
|
||||||
for mino_coord in minoes_coord
|
|
||||||
)
|
|
||||||
|
|
||||||
def rotate(self, rotation):
|
def rotate(self, rotation):
|
||||||
rotated_coords = tuple(
|
rotated_coords = tuple(Coord(rotation * mino.coord.y, -rotation * mino.coord.x) for mino in self.matrix.piece)
|
||||||
Coord(rotation * mino.coord.y, -rotation * mino.coord.x)
|
for rotation_point, liberty_degree in enumerate(self.matrix.piece.SRS[rotation][self.matrix.piece.orientation], start=1):
|
||||||
for mino in self.matrix.piece
|
potential_coord = self.matrix.piece.coord + liberty_degree
|
||||||
)
|
if self.can_move(potential_coord, rotated_coords):
|
||||||
for rotation_point, liberty_degree in enumerate(
|
if self.matrix.piece.prelocked:
|
||||||
self.matrix.piece.SRS[rotation][self.matrix.piece.orientation], start=1
|
self.restart(self.lock, self.stats.lock_delay)
|
||||||
):
|
self.matrix.piece.coord = potential_coord
|
||||||
if self.move(liberty_degree, rotated_coords):
|
for mino, coord in zip(self.matrix.piece, rotated_coords):
|
||||||
self.matrix.piece.orientation = (
|
mino.coord = coord
|
||||||
self.matrix.piece.orientation + rotation
|
self.matrix.piece.orientation = (self.matrix.piece.orientation + rotation) % 4
|
||||||
) % 4
|
|
||||||
self.matrix.piece.last_rotation_point = rotation_point
|
self.matrix.piece.last_rotation_point = rotation_point
|
||||||
|
self.move_ghost()
|
||||||
|
self.on_rotated(rotation)
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def hold(self):
|
def on_rotated(self, direction):
|
||||||
if not self.matrix.piece.hold_enabled:
|
|
||||||
return
|
|
||||||
|
|
||||||
self.matrix.piece.hold_enabled = False
|
|
||||||
self.stop(self.pattern_phase)
|
|
||||||
self.stop(self.fall)
|
|
||||||
self.matrix.piece, self.held.piece = self.held.piece, self.matrix.piece
|
|
||||||
|
|
||||||
self.on_hold(self.held.piece)
|
|
||||||
|
|
||||||
if self.matrix.piece:
|
|
||||||
self.matrix.piece.coord = self.MATRIX_PIECE_COORD
|
|
||||||
self.matrix.ghost = self.matrix.piece.ghost()
|
|
||||||
self.falling_phase()
|
|
||||||
else:
|
|
||||||
self.generation_phase()
|
|
||||||
|
|
||||||
def on_hold(self, held_piece):
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def pattern_phase(self):
|
def on_lock_phase(self):
|
||||||
self.phase = Phase.PATTERN
|
pass
|
||||||
|
|
||||||
|
SCORES = (
|
||||||
|
{LINES_CLEAR_NAME: "", T_Spin.NONE: 0, T_Spin.MINI: 1, T_Spin.T_SPIN: 4},
|
||||||
|
{LINES_CLEAR_NAME: "SINGLE", T_Spin.NONE: 1, T_Spin.MINI: 2, T_Spin.T_SPIN: 8},
|
||||||
|
{LINES_CLEAR_NAME: "DOUBLE", T_Spin.NONE: 3, T_Spin.T_SPIN: 12},
|
||||||
|
{LINES_CLEAR_NAME: "TRIPLE", T_Spin.NONE: 5, T_Spin.T_SPIN: 16},
|
||||||
|
{LINES_CLEAR_NAME: "TETRIS", T_Spin.NONE: 8},
|
||||||
|
)
|
||||||
|
|
||||||
|
def lock(self):
|
||||||
self.matrix.piece.prelocked = False
|
self.matrix.piece.prelocked = False
|
||||||
self.stop(self.pattern_phase)
|
self.stop(self.lock)
|
||||||
self.stop(self.fall)
|
|
||||||
|
|
||||||
# Piece unlocked
|
# Piece unlocked
|
||||||
if self.space_to_move(
|
if self.can_move(self.matrix.piece.coord + Movement.DOWN, (mino.coord for mino in self.matrix.piece)):
|
||||||
self.matrix.piece.coord + Movement.DOWN,
|
|
||||||
(mino.coord for mino in self.matrix.piece),
|
|
||||||
):
|
|
||||||
return
|
return
|
||||||
|
|
||||||
# Game over
|
# Game over
|
||||||
if all(
|
if all((mino.coord + self.matrix.piece.coord).y >= self.matrix.lines for mino in self.matrix.piece):
|
||||||
(mino.coord + self.matrix.piece.coord).y >= self.matrix.lines
|
|
||||||
for mino in self.matrix.piece
|
|
||||||
):
|
|
||||||
self.game_over()
|
self.game_over()
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -314,13 +305,13 @@ class TetrisLogic:
|
|||||||
coord = mino.coord + self.matrix.piece.coord
|
coord = mino.coord + self.matrix.piece.coord
|
||||||
if coord.y <= self.matrix.lines + 3:
|
if coord.y <= self.matrix.lines + 3:
|
||||||
self.matrix[coord.y][coord.x] = mino
|
self.matrix[coord.y][coord.x] = mino
|
||||||
self.on_locked(self.matrix, self.matrix.piece)
|
self.on_locked(self.matrix.piece)
|
||||||
|
|
||||||
|
self.pattern_phase()
|
||||||
|
|
||||||
|
def pattern_phase(self):
|
||||||
# T-Spin
|
# T-Spin
|
||||||
if (
|
if type(self.matrix.piece) == T_Tetrimino and self.matrix.piece.last_rotation_point is not None:
|
||||||
type(self.matrix.piece) == T_Tetrimino
|
|
||||||
and self.matrix.piece.last_rotation_point is not None
|
|
||||||
):
|
|
||||||
a = self.is_t_slot(0)
|
a = self.is_t_slot(0)
|
||||||
b = self.is_t_slot(1)
|
b = self.is_t_slot(1)
|
||||||
c = self.is_t_slot(3)
|
c = self.is_t_slot(3)
|
||||||
@ -339,16 +330,38 @@ class TetrisLogic:
|
|||||||
for y, line in reversed(list(enumerate(self.matrix))):
|
for y, line in reversed(list(enumerate(self.matrix))):
|
||||||
if all(mino for mino in line):
|
if all(mino for mino in line):
|
||||||
lines_cleared += 1
|
lines_cleared += 1
|
||||||
self.on_line_remove(self.matrix, y)
|
self.on_line_remove(y)
|
||||||
self.matrix.pop(y)
|
self.matrix.pop(y)
|
||||||
self.matrix.append_new_line()
|
self.matrix.append_new_line()
|
||||||
if lines_cleared:
|
if lines_cleared:
|
||||||
self.stats.lines_cleared += lines_cleared
|
self.stats.lines_cleared += lines_cleared
|
||||||
|
|
||||||
pattern_name, pattern_score, nb_combo, combo_score = self.stats.pattern_phase(
|
# Scoring
|
||||||
t_spin, lines_cleared
|
lock_strings = []
|
||||||
)
|
lock_score = 0
|
||||||
self.on_pattern_phase(pattern_name, pattern_score, nb_combo, combo_score)
|
|
||||||
|
if t_spin:
|
||||||
|
lock_strings.append(t_spin)
|
||||||
|
if lines_cleared:
|
||||||
|
lock_strings.append(self.SCORES[lines_cleared][LINES_CLEAR_NAME])
|
||||||
|
self.stats.combo += 1
|
||||||
|
else:
|
||||||
|
self.stats.combo = -1
|
||||||
|
|
||||||
|
if lines_cleared or t_spin:
|
||||||
|
ds = self.SCORES[lines_cleared][t_spin]
|
||||||
|
self.stats.goal -= ds
|
||||||
|
ds *= 100 * self.stats.level
|
||||||
|
lock_score += ds
|
||||||
|
lock_strings.append(str(ds))
|
||||||
|
self.show_text("\n".join(lock_strings))
|
||||||
|
|
||||||
|
if self.stats.combo >= 1:
|
||||||
|
ds = (20 if lines_cleared == 1 else 50) * self.stats.combo * self.stats.level
|
||||||
|
lock_score += ds
|
||||||
|
self.show_text("COMBO x{:n}\n{:n}".format(self.stats.combo, ds))
|
||||||
|
|
||||||
|
self.stats.score += lock_score
|
||||||
|
|
||||||
if self.stats.goal <= 0:
|
if self.stats.goal <= 0:
|
||||||
self.new_level()
|
self.new_level()
|
||||||
@ -358,73 +371,62 @@ class TetrisLogic:
|
|||||||
if self.pressed_actions:
|
if self.pressed_actions:
|
||||||
self.start(self.repeat_action, self.AUTOREPEAT_DELAY)
|
self.start(self.repeat_action, self.AUTOREPEAT_DELAY)
|
||||||
|
|
||||||
def on_locked(self, matrix, locked_piece):
|
def on_locked(piece):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def on_line_remove(self, matrix, y):
|
def on_line_remove(self, y):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def on_pattern_phase(self, pattern_name, pattern_score, nb_combo, combo_score):
|
def can_move(self, potential_coord, minoes_coords):
|
||||||
pass
|
return all(self.matrix.cell_is_free(potential_coord + mino_coord) for mino_coord in minoes_coords)
|
||||||
|
|
||||||
def move_left(self):
|
|
||||||
self.move(Movement.LEFT)
|
|
||||||
|
|
||||||
def move_right(self):
|
|
||||||
self.move(Movement.RIGHT)
|
|
||||||
|
|
||||||
def rotate_clockwise(self):
|
|
||||||
self.rotate(Rotation.CLOCKWISE)
|
|
||||||
|
|
||||||
def rotate_counter(self):
|
|
||||||
self.rotate(Rotation.COUNTER)
|
|
||||||
|
|
||||||
def soft_drop(self):
|
|
||||||
moved = self.move(Movement.DOWN)
|
|
||||||
if moved:
|
|
||||||
self.stats.score += 1
|
|
||||||
return moved
|
|
||||||
|
|
||||||
def hard_drop(self):
|
|
||||||
while self.move(Movement.DOWN, lock=False):
|
|
||||||
self.stats.score += 2
|
|
||||||
self.pattern_phase()
|
|
||||||
|
|
||||||
T_SLOT_COORDS = (Coord(-1, 1), Coord(1, 1), Coord(-1, 1), Coord(-1, -1))
|
T_SLOT_COORDS = (Coord(-1, 1), Coord(1, 1), Coord(-1, 1), Coord(-1, -1))
|
||||||
|
|
||||||
def is_t_slot(self, n):
|
def is_t_slot(self, n):
|
||||||
t_slot_coord = (
|
t_slot_coord = self.matrix.piece.coord + self.T_SLOT_COORDS[(self.matrix.piece.orientation + n) % 4]
|
||||||
self.matrix.piece.coord
|
|
||||||
+ self.T_SLOT_COORDS[(self.matrix.piece.orientation + n) % 4]
|
|
||||||
)
|
|
||||||
return not self.matrix.cell_is_free(t_slot_coord)
|
return not self.matrix.cell_is_free(t_slot_coord)
|
||||||
|
|
||||||
|
def swap(self):
|
||||||
|
if self.matrix.piece.hold_enabled:
|
||||||
|
self.matrix.piece.hold_enabled = False
|
||||||
|
self.matrix.piece.prelocked = False
|
||||||
|
self.stop(self.lock)
|
||||||
|
self.matrix.piece, self.held.piece = self.held.piece, self.matrix.piece
|
||||||
|
self.held.piece.coord = self.HELD_PIECE_COORD
|
||||||
|
if type(self.held.piece) == I_Tetrimino:
|
||||||
|
self.held.piece.coord += Movement.LEFT
|
||||||
|
for mino, coord in zip(self.held.piece, self.held.piece.MINOES_COORDS):
|
||||||
|
mino.coord = coord
|
||||||
|
|
||||||
|
if self.matrix.piece:
|
||||||
|
self.matrix.piece.coord = self.MATRIX_PIECE_COORD
|
||||||
|
self.matrix.ghost = self.matrix.piece.ghost()
|
||||||
|
self.move_ghost()
|
||||||
|
else:
|
||||||
|
self.generation_phase()
|
||||||
|
|
||||||
def pause(self):
|
def pause(self):
|
||||||
self.phase = Phase.PAUSED
|
self.state = State.PAUSED
|
||||||
self.stop_all()
|
self.stop_all()
|
||||||
self.pressed_actions = []
|
self.pressed_actions = []
|
||||||
self.auto_repeat = False
|
self.auto_repeat = False
|
||||||
self.stop(self.repeat_action)
|
self.stop(self.repeat_action)
|
||||||
|
|
||||||
def resume(self):
|
def resume(self):
|
||||||
self.phase = Phase.FALLING
|
self.state = State.PLAYING
|
||||||
self.start(self.fall, self.stats.fall_delay)
|
self.start(self.fall, self.stats.fall_delay)
|
||||||
if self.phase == Phase.LOCK:
|
if self.matrix.piece.prelocked:
|
||||||
self.start(self.pattern_phase, self.stats.lock_delay)
|
self.start(self.lock, self.stats.lock_delay)
|
||||||
self.start(self.stats.update_time, 1)
|
self.start(self.stats.update_time, 1)
|
||||||
|
|
||||||
def game_over(self):
|
def game_over(self):
|
||||||
self.phase = Phase.OVER
|
self.state = State.OVER
|
||||||
self.stop_all()
|
self.stop_all()
|
||||||
self.save_high_score()
|
self.save_high_score()
|
||||||
self.on_game_over()
|
|
||||||
|
|
||||||
def on_game_over(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def stop_all(self):
|
def stop_all(self):
|
||||||
self.stop(self.fall)
|
self.stop(self.fall)
|
||||||
self.stop(self.pattern_phase)
|
self.stop(self.lock)
|
||||||
self.stop(self.stats.update_time)
|
self.stop(self.stats.update_time)
|
||||||
|
|
||||||
def do_action(self, action):
|
def do_action(self, action):
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import random
|
|
||||||
|
|
||||||
from .utils import Coord, Rotation, Color
|
from .utils import Coord, Rotation, Color
|
||||||
|
|
||||||
|
|
||||||
@ -16,20 +14,9 @@ class MetaTetromino(type):
|
|||||||
Tetromino.shapes.append(cls)
|
Tetromino.shapes.append(cls)
|
||||||
|
|
||||||
|
|
||||||
class Tetromino:
|
class Tetromino(list):
|
||||||
|
|
||||||
shapes = []
|
shapes = []
|
||||||
random_bag = []
|
|
||||||
|
|
||||||
def __new__(cls):
|
|
||||||
if not cls.random_bag:
|
|
||||||
cls.random_bag = list(cls.shapes)
|
|
||||||
random.shuffle(cls.random_bag)
|
|
||||||
return cls.random_bag.pop()()
|
|
||||||
|
|
||||||
|
|
||||||
class TetrominoBase(list):
|
|
||||||
|
|
||||||
# Super rotation system
|
# Super rotation system
|
||||||
SRS = {
|
SRS = {
|
||||||
Rotation.CLOCKWISE: (
|
Rotation.CLOCKWISE: (
|
||||||
@ -57,7 +44,7 @@ class TetrominoBase(list):
|
|||||||
return type(self)()
|
return type(self)()
|
||||||
|
|
||||||
|
|
||||||
class O_Tetrimino(TetrominoBase, metaclass=MetaTetromino):
|
class O_Tetrimino(Tetromino, metaclass=MetaTetromino):
|
||||||
|
|
||||||
SRS = {
|
SRS = {
|
||||||
Rotation.CLOCKWISE: (tuple(), tuple(), tuple(), tuple()),
|
Rotation.CLOCKWISE: (tuple(), tuple(), tuple(), tuple()),
|
||||||
@ -70,7 +57,7 @@ class O_Tetrimino(TetrominoBase, metaclass=MetaTetromino):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
class I_Tetrimino(TetrominoBase, metaclass=MetaTetromino):
|
class I_Tetrimino(Tetromino, metaclass=MetaTetromino):
|
||||||
|
|
||||||
SRS = {
|
SRS = {
|
||||||
Rotation.CLOCKWISE: (
|
Rotation.CLOCKWISE: (
|
||||||
@ -90,31 +77,31 @@ class I_Tetrimino(TetrominoBase, metaclass=MetaTetromino):
|
|||||||
MINOES_COLOR = Color.CYAN
|
MINOES_COLOR = Color.CYAN
|
||||||
|
|
||||||
|
|
||||||
class T_Tetrimino(TetrominoBase, metaclass=MetaTetromino):
|
class T_Tetrimino(Tetromino, metaclass=MetaTetromino):
|
||||||
|
|
||||||
MINOES_COORDS = (Coord(-1, 0), Coord(0, 0), Coord(0, 1), Coord(1, 0))
|
MINOES_COORDS = (Coord(-1, 0), Coord(0, 0), Coord(0, 1), Coord(1, 0))
|
||||||
MINOES_COLOR = Color.MAGENTA
|
MINOES_COLOR = Color.MAGENTA
|
||||||
|
|
||||||
|
|
||||||
class L_Tetrimino(TetrominoBase, metaclass=MetaTetromino):
|
class L_Tetrimino(Tetromino, metaclass=MetaTetromino):
|
||||||
|
|
||||||
MINOES_COORDS = (Coord(-1, 0), Coord(0, 0), Coord(1, 0), Coord(1, 1))
|
MINOES_COORDS = (Coord(-1, 0), Coord(0, 0), Coord(1, 0), Coord(1, 1))
|
||||||
MINOES_COLOR = Color.ORANGE
|
MINOES_COLOR = Color.ORANGE
|
||||||
|
|
||||||
|
|
||||||
class J_Tetrimino(TetrominoBase, metaclass=MetaTetromino):
|
class J_Tetrimino(Tetromino, metaclass=MetaTetromino):
|
||||||
|
|
||||||
MINOES_COORDS = (Coord(-1, 1), Coord(-1, 0), Coord(0, 0), Coord(1, 0))
|
MINOES_COORDS = (Coord(-1, 1), Coord(-1, 0), Coord(0, 0), Coord(1, 0))
|
||||||
MINOES_COLOR = Color.BLUE
|
MINOES_COLOR = Color.BLUE
|
||||||
|
|
||||||
|
|
||||||
class S_Tetrimino(TetrominoBase, metaclass=MetaTetromino):
|
class S_Tetrimino(Tetromino, metaclass=MetaTetromino):
|
||||||
|
|
||||||
MINOES_COORDS = (Coord(-1, 0), Coord(0, 0), Coord(0, 1), Coord(1, 1))
|
MINOES_COORDS = (Coord(-1, 0), Coord(0, 0), Coord(0, 1), Coord(1, 1))
|
||||||
MINOES_COLOR = Color.GREEN
|
MINOES_COLOR = Color.GREEN
|
||||||
|
|
||||||
|
|
||||||
class Z_Tetrimino(TetrominoBase, metaclass=MetaTetromino):
|
class Z_Tetrimino(Tetromino, metaclass=MetaTetromino):
|
||||||
|
|
||||||
MINOES_COORDS = (Coord(-1, 1), Coord(0, 1), Coord(0, 0), Coord(1, 0))
|
MINOES_COORDS = (Coord(-1, 1), Coord(0, 1), Coord(0, 0), Coord(1, 0))
|
||||||
MINOES_COLOR = Color.RED
|
MINOES_COLOR = Color.RED
|
||||||
|
@ -37,13 +37,3 @@ class Color:
|
|||||||
ORANGE = 4
|
ORANGE = 4
|
||||||
RED = 5
|
RED = 5
|
||||||
YELLOW = 6
|
YELLOW = 6
|
||||||
|
|
||||||
|
|
||||||
class Phase:
|
|
||||||
|
|
||||||
STARTING = "STARTING"
|
|
||||||
FALLING = "FALLING"
|
|
||||||
LOCK = "LOCK"
|
|
||||||
PATTERN = "PATTERN"
|
|
||||||
PAUSED = "PAUSED"
|
|
||||||
OVER = "OVER"
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user