Class: Textbringer::TetrisMode
- Inherits:
-
GamegridMode
- Object
- Mode
- GamegridMode
- Textbringer::TetrisMode
- Defined in:
- lib/textbringer/modes/tetris_mode.rb
Constant Summary collapse
- BOARD_WIDTH =
10- BOARD_HEIGHT =
20- BORDER_VALUE =
cell value used for the 1-cell border around the board
8- PIECE_COLORS =
{ 1 => :gamegrid_block_cyan, 2 => :gamegrid_block_yellow, 3 => :gamegrid_block_magenta, 4 => :gamegrid_block_green, 5 => :gamegrid_block_red, 6 => :gamegrid_block_blue, 7 => :gamegrid_block_white, }.freeze
- PIECE_NAMES =
["", "I", "O", "T", "S", "Z", "J", "L"].freeze
- PIECES =
Pieces[rotation][row][col] — 4×4 bounding box, 1-indexed types
[ nil, # 1: I (cyan) [ [[0,0,0,0],[1,1,1,1],[0,0,0,0],[0,0,0,0]], [[0,0,1,0],[0,0,1,0],[0,0,1,0],[0,0,1,0]], [[0,0,0,0],[0,0,0,0],[1,1,1,1],[0,0,0,0]], [[0,1,0,0],[0,1,0,0],[0,1,0,0],[0,1,0,0]], ], # 2: O (yellow) [ [[0,1,1,0],[0,1,1,0],[0,0,0,0],[0,0,0,0]], [[0,1,1,0],[0,1,1,0],[0,0,0,0],[0,0,0,0]], [[0,1,1,0],[0,1,1,0],[0,0,0,0],[0,0,0,0]], [[0,1,1,0],[0,1,1,0],[0,0,0,0],[0,0,0,0]], ], # 3: T (magenta) [ [[0,1,0,0],[1,1,1,0],[0,0,0,0],[0,0,0,0]], [[0,1,0,0],[0,1,1,0],[0,1,0,0],[0,0,0,0]], [[0,0,0,0],[1,1,1,0],[0,1,0,0],[0,0,0,0]], [[0,1,0,0],[1,1,0,0],[0,1,0,0],[0,0,0,0]], ], # 4: S (green) [ [[0,1,1,0],[1,1,0,0],[0,0,0,0],[0,0,0,0]], [[1,0,0,0],[1,1,0,0],[0,1,0,0],[0,0,0,0]], [[0,1,1,0],[1,1,0,0],[0,0,0,0],[0,0,0,0]], [[1,0,0,0],[1,1,0,0],[0,1,0,0],[0,0,0,0]], ], # 5: Z (red) [ [[1,1,0,0],[0,1,1,0],[0,0,0,0],[0,0,0,0]], [[0,0,1,0],[0,1,1,0],[0,1,0,0],[0,0,0,0]], [[1,1,0,0],[0,1,1,0],[0,0,0,0],[0,0,0,0]], [[0,0,1,0],[0,1,1,0],[0,1,0,0],[0,0,0,0]], ], # 6: J (blue) [ [[1,0,0,0],[1,1,1,0],[0,0,0,0],[0,0,0,0]], [[0,1,1,0],[0,1,0,0],[0,1,0,0],[0,0,0,0]], [[0,0,0,0],[1,1,1,0],[0,0,1,0],[0,0,0,0]], [[0,1,0,0],[0,1,0,0],[1,1,0,0],[0,0,0,0]], ], # 7: L (white) [ [[0,0,1,0],[1,1,1,0],[0,0,0,0],[0,0,0,0]], [[0,1,0,0],[0,1,0,0],[0,1,1,0],[0,0,0,0]], [[0,0,0,0],[1,1,1,0],[1,0,0,0],[0,0,0,0]], [[1,1,0,0],[0,1,0,0],[0,1,0,0],[0,0,0,0]], ], ].freeze
Constants inherited from Mode
Constants included from Commands
Commands::CLIPBOARD_AVAILABLE, Commands::COMPLETION_POPUP_STATUS, Commands::CTAGS, Commands::EMAIL_REGEXP, Commands::HELP_RING, Commands::ISEARCH_STATUS, Commands::ISPELL_STATUS, Commands::ISPELL_WORD_REGEXP, Commands::KEYBOARD_MACROS, Commands::LSP_DOCUMENT_VERSIONS, Commands::LSP_STATUS, Commands::REGISTERS, Commands::RE_SEARCH_STATUS, Commands::URI_REGEXP
Constants included from Utils
Utils::COMPLETION, Utils::EXPRESSION_COMPLETOR, Utils::EXPRESSION_COMPLETOR_OPTIONS, Utils::HOOKS
Instance Attribute Summary collapse
-
#game_over ⇒ Object
readonly
Returns the value of attribute game_over.
-
#level ⇒ Object
readonly
Returns the value of attribute level.
-
#lines_cleared ⇒ Object
readonly
Returns the value of attribute lines_cleared.
-
#next_type ⇒ Object
readonly
Returns the value of attribute next_type.
-
#paused ⇒ Object
readonly
Returns the value of attribute paused.
-
#piece_rot ⇒ Object
readonly
Returns the value of attribute piece_rot.
-
#piece_type ⇒ Object
readonly
Returns the value of attribute piece_type.
-
#piece_x ⇒ Object
readonly
Returns the value of attribute piece_x.
-
#piece_y ⇒ Object
readonly
Returns the value of attribute piece_y.
-
#score ⇒ Object
readonly
Returns the value of attribute score.
Attributes inherited from Mode
Instance Method Summary collapse
-
#initialize(buffer) ⇒ TetrisMode
constructor
A new instance of TetrisMode.
Methods inherited from GamegridMode
Methods inherited from Mode
define_generic_command, define_local_command, define_syntax, inherited, list, #name, #syntax_table
Methods included from Commands
[], #buffer_uri, #command_help, command_table, #completion_popup_done, completion_popup_mode_active?, #completion_popup_pre_command_hook, #completion_popup_start, #current_prefix_arg, define_command, #ensure_ispell_active, #execute_keyboard_macro, #get_tags, #insert_completion, #isearch_done, #isearch_mode, #isearch_mode?, #isearch_pre_command_hook, #isearch_prompt, #isearch_repeat, #isearch_repeat_backward, #isearch_repeat_forward, #isearch_search, #ispell_done, #ispell_forward, #ispell_mode, #keymap_bindings, list, #lsp_after_set_visited_file_name_hook, #lsp_close_signature_window, #lsp_completion_context, #lsp_find_file_hook, #lsp_open_document, #lsp_position, #lsp_setup_buffer_hooks, #lsp_show_signature_window, #lsp_signature_pre_command_hook, #lsp_text_document_sync_kind, #lsp_utf16_length, #match_beginning, #match_end, #match_string, #message_misspelled, #number_prefix_arg, #prefix_numeric_value, #read_input_method_name, #read_keyboard_macro, #read_register, #replace_match, undefine_command, #universal_argument_mode
Methods included from Utils
add_hook, background, complete_for_minibuffer, delete_completions_window, foreground, foreground!, get_hooks, message, read_buffer, read_char, read_command_name, read_encoding, read_event, read_expression, read_file_name, read_from_minibuffer, read_key_sequence, read_object, read_single_char, received_keyboard_quit?, remove_hook, ruby_install_name, run_hooks, run_hooks_in, self_insert_and_exit_minibuffer, set_transient_map, show_exception, sit_for, sleep_for, y_or_n?, yes_or_no?
Constructor Details
#initialize(buffer) ⇒ TetrisMode
Returns a new instance of TetrisMode.
91 92 93 94 95 96 97 |
# File 'lib/textbringer/modes/tetris_mode.rb', line 91 def initialize(buffer) super buffer.keymap = TETRIS_MODE_MAP @game_over = true @paused = false @grid = nil end |
Instance Attribute Details
#game_over ⇒ Object (readonly)
Returns the value of attribute game_over.
87 88 89 |
# File 'lib/textbringer/modes/tetris_mode.rb', line 87 def game_over @game_over end |
#level ⇒ Object (readonly)
Returns the value of attribute level.
87 88 89 |
# File 'lib/textbringer/modes/tetris_mode.rb', line 87 def level @level end |
#lines_cleared ⇒ Object (readonly)
Returns the value of attribute lines_cleared.
87 88 89 |
# File 'lib/textbringer/modes/tetris_mode.rb', line 87 def lines_cleared @lines_cleared end |
#next_type ⇒ Object (readonly)
Returns the value of attribute next_type.
87 88 89 |
# File 'lib/textbringer/modes/tetris_mode.rb', line 87 def next_type @next_type end |
#paused ⇒ Object (readonly)
Returns the value of attribute paused.
87 88 89 |
# File 'lib/textbringer/modes/tetris_mode.rb', line 87 def paused @paused end |
#piece_rot ⇒ Object (readonly)
Returns the value of attribute piece_rot.
87 88 89 |
# File 'lib/textbringer/modes/tetris_mode.rb', line 87 def piece_rot @piece_rot end |
#piece_type ⇒ Object (readonly)
Returns the value of attribute piece_type.
87 88 89 |
# File 'lib/textbringer/modes/tetris_mode.rb', line 87 def piece_type @piece_type end |
#piece_x ⇒ Object (readonly)
Returns the value of attribute piece_x.
87 88 89 |
# File 'lib/textbringer/modes/tetris_mode.rb', line 87 def piece_x @piece_x end |
#piece_y ⇒ Object (readonly)
Returns the value of attribute piece_y.
87 88 89 |
# File 'lib/textbringer/modes/tetris_mode.rb', line 87 def piece_y @piece_y end |
#score ⇒ Object (readonly)
Returns the value of attribute score.
87 88 89 |
# File 'lib/textbringer/modes/tetris_mode.rb', line 87 def score @score end |