test t-spin only on lock
This commit is contained in:
		| @ -132,9 +132,10 @@ func _on_DropTimer_timeout(): | ||||
| 		 | ||||
| func lock(): | ||||
| 	if $Matrix/GridMap.lock(current_piece): | ||||
| 		var t_spin = current_piece.t_spin() | ||||
| 		var lines_cleared = $Matrix/GridMap.clear_lines() | ||||
| 		$Stats.piece_locked(lines_cleared, current_piece.t_spin) | ||||
| 		if lines_cleared or current_piece.t_spin: | ||||
| 		$Stats.piece_locked(lines_cleared, t_spin) | ||||
| 		if lines_cleared or t_spin: | ||||
| 			$MidiPlayer.piece_locked(lines_cleared) | ||||
| 		remove_child(current_piece) | ||||
| 		new_piece() | ||||
|  | ||||
| @ -69,11 +69,12 @@ func piece_dropped(ds): | ||||
| func piece_locked(lines, t_spin): | ||||
| 	var ds | ||||
| 	if lines or t_spin: | ||||
| 		var text = t_spin | ||||
| 		if lines and t_spin: | ||||
| 			text += " " | ||||
| 		text += LINES_CLEARED_NAMES[lines] | ||||
| 		flash_text.print(text) | ||||
| 			flash_text.print(t_spin + " " + LINES_CLEARED_NAMES[lines]) | ||||
| 		elif lines: | ||||
| 			flash_text.print(LINES_CLEARED_NAMES[lines]) | ||||
| 		elif t_spin: | ||||
| 			flash_text.print(t_spin) | ||||
| 		ds = SCORES[lines][t_spin] | ||||
| 		goal -= ds | ||||
| 		$VBC/Goal.text = str(goal) | ||||
|  | ||||
| @ -1,4 +1,5 @@ | ||||
| extends "Tetromino.gd" | ||||
|  | ||||
| func rotate(direction): | ||||
| 	return 0 | ||||
| 	return false | ||||
| 	 | ||||
| @ -3,8 +3,7 @@ | ||||
| [ext_resource path="res://Tetrominos/TetroO.gd" type="Script" id=1] | ||||
| [ext_resource path="res://Tetrominos/Mino/Mino.tscn" type="PackedScene" id=2] | ||||
|  | ||||
|  | ||||
| [node name="TetroO" type="Spatial" index="0"] | ||||
| [node name="TetroO" type="Spatial"] | ||||
|  | ||||
| script = ExtResource( 1 ) | ||||
|  | ||||
|  | ||||
| @ -7,22 +7,15 @@ const T_SLOT = [ | ||||
| 	Vector3(-1, -1, 0) | ||||
| ] | ||||
| 	 | ||||
| var rotation_point_5_used = false | ||||
|  | ||||
| func rotate(direction): | ||||
| 	var rotation_point = .rotate(direction) | ||||
| 	if rotation_point: | ||||
| 		var center = to_global(minoes[0].translation) | ||||
| 		var a = not grid_map.is_free_cell(center + T_SLOT[orientation]) | ||||
| 		var b = not grid_map.is_free_cell(center + T_SLOT[(1+orientation)%4]) | ||||
| 		var c = not grid_map.is_free_cell(center + T_SLOT[(2+orientation)%4]) | ||||
| 		var d = not grid_map.is_free_cell(center + T_SLOT[(3+orientation)%4]) | ||||
| 		if a and b and (c or d) or rotation_point_5_used: | ||||
| 			t_spin = "T-SPIN" | ||||
| 		elif c and d and (a or b): | ||||
| 			t_spin = "MINI T-SPIN" | ||||
| 		else: | ||||
| 			t_spin = "" | ||||
| 		if rotation_point == 5: | ||||
| 			rotation_point_5_used = true | ||||
| 	return rotation_point | ||||
| func t_spin(): | ||||
| 	var center = to_global(minoes[0].translation) | ||||
| 	var a = not grid_map.is_free_cell(center + T_SLOT[orientation]) | ||||
| 	var b = not grid_map.is_free_cell(center + T_SLOT[(1+orientation)%4]) | ||||
| 	var c = not grid_map.is_free_cell(center + T_SLOT[(3+orientation)%4]) | ||||
| 	var d = not grid_map.is_free_cell(center + T_SLOT[(2+orientation)%4]) | ||||
| 	if rotation_point_5_used or (a and b and (c or d)): | ||||
| 		return "T-SPIN" | ||||
| 	elif c and d and (a or b): | ||||
| 		return "MINI T-SPIN" | ||||
| 	else: | ||||
| 		return "" | ||||
| @ -3,7 +3,7 @@ | ||||
| [ext_resource path="res://Tetrominos/TetroT.gd" type="Script" id=1] | ||||
| [ext_resource path="res://Tetrominos/Mino/Mino.tscn" type="PackedScene" id=2] | ||||
|  | ||||
| [node name="TetroT" type="Spatial" index="0"] | ||||
| [node name="TetroT" type="Spatial"] | ||||
|  | ||||
| script = ExtResource( 1 ) | ||||
|  | ||||
|  | ||||
| @ -74,7 +74,7 @@ var minoes = [] | ||||
| var grid_map | ||||
| var lock_delay | ||||
| var orientation = 0 | ||||
| var t_spin = "" | ||||
| var rotation_point_5_used = false | ||||
|  | ||||
| func _ready(): | ||||
| 	randomize() | ||||
| @ -112,13 +112,17 @@ func rotate(direction): | ||||
| 	var movements = SUPER_ROTATION_SYSTEM[orientation][direction] | ||||
| 	for i in range(movements.size()): | ||||
| 		if grid_map.possible_positions(rotated_translations, movements[i]): | ||||
| 			orientation -= direction | ||||
| 			orientation %= NB_MINOES | ||||
| 			orientation = (orientation - direction) % NB_MINOES | ||||
| 			set_translations(rotated_translations) | ||||
| 			translate(movements[i]) | ||||
| 			lock_delay.start() | ||||
| 			return i+1 | ||||
| 	return 0 | ||||
| 			if i == 4: | ||||
| 				rotation_point_5_used = true | ||||
| 			return true | ||||
| 	return false | ||||
| 	 | ||||
| func t_spin(): | ||||
| 	return "" | ||||
| 	 | ||||
| func emit_trail(visible): | ||||
| 	var trail | ||||
|  | ||||
		Reference in New Issue
	
	Block a user