Revert "clean up mess"

This reverts commit 80fb1421bdb043b13568f6cc41bc76d7f2e8c8a9.
This commit is contained in:
adrienmalin 2019-01-01 04:21:03 +01:00
parent 80fb1421bd
commit 131e17975b
37 changed files with 1262 additions and 189 deletions

14
Breakage1.tres Normal file
View File

@ -0,0 +1,14 @@
[gd_resource type="PrismMesh" load_steps=2 format=2]
[ext_resource path="res://SparkSpatialmaterial.tres" type="Material" id=1]
[resource]
material = ExtResource( 1 )
custom_aabb = AABB( 0, 0, 0, 0, 0, 0 )
left_to_right = 2.98023e-008
size = Vector3( 0.2, 0.2, 0.2 )
subdivide_width = 2
subdivide_height = 0
subdivide_depth = 0

14
Breakage2.tres Normal file
View File

@ -0,0 +1,14 @@
[gd_resource type="PrismMesh" load_steps=2 format=2]
[ext_resource path="res://SparkSpatialmaterial.tres" type="Material" id=1]
[resource]
material = ExtResource( 1 )
custom_aabb = AABB( 0, 0, 0, 0, 0, 0 )
left_to_right = 0.5
size = Vector3( 0.2, 0.2, 0.2 )
subdivide_width = 2
subdivide_height = 0
subdivide_depth = 0

109
ExplodingLine.tscn Normal file
View File

@ -0,0 +1,109 @@
[gd_scene load_steps=10 format=2]
[ext_resource path="res://Tetrominos/Mino/Breakage1.tres" type="PrismMesh" id=1]
[ext_resource path="res://Tetrominos/Mino/Breakage2.tres" type="PrismMesh" id=2]
[ext_resource path="res://Tetrominos/Mino/BackMaterial.tres" type="Material" id=3]
[sub_resource type="Gradient" id=1]
offsets = PoolRealArray( 0, 1 )
colors = PoolColorArray( 0, 0, 0, 1, 1, 1, 1, 1 )
[sub_resource type="GradientTexture" id=2]
flags = 4
gradient = SubResource( 1 )
width = 2048
[sub_resource type="Gradient" id=3]
offsets = PoolRealArray( 0, 1 )
colors = PoolColorArray( 0.802765, 1, 0.451172, 1, 1, 1, 1, 0 )
[sub_resource type="GradientTexture" id=4]
flags = 4
gradient = SubResource( 3 )
width = 2048
[sub_resource type="ParticlesMaterial" id=5]
render_priority = 0
trail_divisor = 2
trail_color_modifier = SubResource( 4 )
emission_shape = 2
emission_box_extents = Vector3( 8, 0.5, 0.5 )
flag_align_y = false
flag_rotate_y = true
flag_disable_z = false
spread = 10.0
flatness = 0.0
gravity = Vector3( 0, -20, 0 )
initial_velocity = 10.0
initial_velocity_random = 0.8
angular_velocity = 197.74
angular_velocity_random = 1.0
linear_accel = 100.0
linear_accel_random = 0.84
radial_accel = 8.48
radial_accel_random = 0.85
tangential_accel = 0.0
tangential_accel_random = 0.0
damping = 0.0
damping_random = 0.0
angle = 402.7
angle_random = 0.78
scale = 0.5
scale_random = 1.0
color_ramp = SubResource( 2 )
hue_variation = 0.0
hue_variation_random = 0.0
anim_speed = 0.0
anim_speed_random = 0.0
anim_offset = 0.0
anim_offset_random = 0.0
anim_loop = false
_sections_unfolded = [ "Color", "Emission Shape", "Gravity", "Scale", "Spread" ]
[sub_resource type="CubeMesh" id=6]
material = ExtResource( 3 )
custom_aabb = AABB( 0, 0, 0, 0, 0, 0 )
size = Vector3( 0.2, 0.2, 0.2 )
subdivide_width = 0
subdivide_height = 0
subdivide_depth = 0
[node name="ExplodingLine" type="Particles" index="0"]
layers = 1
material_override = null
cast_shadow = 1
extra_cull_margin = 0.0
use_in_baked_light = false
lod_min_distance = 0.0
lod_min_hysteresis = 0.0
lod_max_distance = 0.0
lod_max_hysteresis = 0.0
emitting = false
amount = 1000
lifetime = 2.0
one_shot = true
preprocess = 0.0
speed_scale = 2.18
explosiveness = 0.9
randomness = 0.69
fixed_fps = 0
fract_delta = true
visibility_aabb = AABB( -5, -0.5, -1, 10, 1, 2 )
local_coords = false
draw_order = 0
process_material = SubResource( 5 )
draw_passes = 3
draw_pass_1 = ExtResource( 1 )
draw_pass_2 = ExtResource( 2 )
draw_pass_3 = SubResource( 6 )
_sections_unfolded = [ "Draw Passes", "Drawing", "Process Material", "Time", "Transform" ]

View File

@ -1,6 +1,6 @@
[gd_resource type="PrismMesh" load_steps=2 format=2]
[ext_resource path="res://ExplodingLine/SparkSpatialmaterial.tres" type="Material" id=1]
[ext_resource path="res://Tetrominos/Mino/MinoMaterial.tres" type="Material" id=1]
[resource]

View File

@ -1,6 +1,6 @@
[gd_resource type="PrismMesh" load_steps=2 format=2]
[ext_resource path="res://ExplodingLine/SparkSpatialmaterial.tres" type="Material" id=1]
[ext_resource path="res://Tetrominos/Mino/MinoMaterial.tres" type="Material" id=1]
[resource]

View File

@ -1,8 +1,10 @@
[gd_scene load_steps=10 format=2]
[ext_resource path="res://Tetrominos/Mino/Breakage1.tres" type="PrismMesh" id=1]
[ext_resource path="res://Tetrominos/Mino/Breakage2.tres" type="PrismMesh" id=2]
[ext_resource path="res://Tetrominos/Mino/BackMaterial.tres" type="Material" id=3]
[ext_resource path="res://ExplodingLine/Breakage1.tres" type="PrismMesh" id=1]
[ext_resource path="res://ExplodingLine/Breakage2.tres" type="PrismMesh" id=2]
[ext_resource path="res://GridMap/BackMaterial.tres" type="Material" id=3]
[sub_resource type="Gradient" id=1]

View File

@ -23,14 +23,14 @@ params_point_size = 1.0
params_billboard_mode = 0
params_grow = false
params_use_alpha_scissor = false
albedo_color = Color( 0.887543, 1, 0.738281, 0.529294 )
metallic = 0.78
albedo_color = Color( 0.67451, 1, 0.988235, 0.108118 )
metallic = 0.22
metallic_specular = 1.0
metallic_texture_channel = 0
roughness = 0.49
roughness_texture_channel = 0
emission_enabled = true
emission = Color( 1, 1, 0.700471, 1 )
emission = Color( 0.700471, 1, 0.98947, 1 )
emission_energy = 0.2
emission_operator = 0
emission_on_uv2 = false
@ -55,5 +55,5 @@ uv2_triplanar_sharpness = 1.0
proximity_fade_enable = true
proximity_fade_distance = 1.0
distance_fade_enable = false
_sections_unfolded = [ "Emission", "Proximity Fade" ]
_sections_unfolded = [ "Albedo", "Emission", "Metallic", "Parameters" ]

32
GridBack.tscn Normal file
View File

@ -0,0 +1,32 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://Tetrominos/Mino/BackMaterial.tres" type="Material" id=1]
[sub_resource type="CubeMesh" id=3]
material = ExtResource( 1 )
custom_aabb = AABB( 0, 0, 0, 0, 0, 0 )
size = Vector3( 11, 22, 0.1 )
subdivide_width = 0
subdivide_height = 0
subdivide_depth = 0
[node name="GridBack" type="MeshInstance"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 4.5, 9.5, -1 )
layers = 1
material_override = null
cast_shadow = 1
extra_cull_margin = 0.0
use_in_baked_light = false
lod_min_distance = 0.0
lod_min_hysteresis = 0.0
lod_max_distance = 0.0
lod_max_hysteresis = 0.0
mesh = SubResource( 3 )
skeleton = NodePath("..")
material/0 = null
_sections_unfolded = [ "Transform" ]

256
GridMap.gd Normal file
View File

@ -0,0 +1,256 @@
extends GridMap
const ExplodingLine = preload("res://ExplodingLine.tscn")
const Tetromino = preload("res://Tetrominos/Tetromino.gd")
const TetroI = preload("res://Tetrominos/TetroI.tscn")
const TetroJ = preload("res://Tetrominos/TetroJ.tscn")
const TetroL = preload("res://Tetrominos/TetroL.tscn")
const TetroO = preload("res://Tetrominos/TetroO.tscn")
const TetroS = preload("res://Tetrominos/TetroS.tscn")
const TetroT = preload("res://Tetrominos/TetroT.tscn")
const TetroZ = preload("res://Tetrominos/TetroZ.tscn")
const EMPTY_CELL = -1
const NB_MINOES = 4
const NEXT_POSITION = Vector3(13, 16, 0)
const START_POSITION = Vector3(5, 20, 0)
const HOLD_POSITION = Vector3(-5, 16, 0)
const SCORES = [
[0, 4, 1],
[1, 8, 2],
[3, 12],
[5, 16],
[8]
]
const LINES_CLEARED_NAMES = ["", "SINGLE", "DOUBLE", "TRIPLE", "TETRIS"]
const T_SPIN_NAMES = ["", "MINI T-SPIN", "T-SPIN"]
export (int) var NB_LINES
export (int) var NB_COLLUMNS
var next_piece = random_piece()
var current_piece
var held_piece
var current_piece_held = false
var locked = false
var autoshift_action = ""
var movements = {
"move_right": Vector3(1, 0, 0),
"move_left": Vector3(-1, 0, 0),
"soft_drop": Vector3(0, -1, 0)
}
var exploding_lines = []
var lines_to_clear = []
var hard_dropping = false
var random_bag = []
var playing = true
var level = 0
var goal = 0
var score = 0
func _ready():
randomize()
for y in range(NB_LINES):
exploding_lines.append(ExplodingLine.instance())
add_child(exploding_lines[y])
exploding_lines[y].translation = Vector3(NB_COLLUMNS/2, y, 1)
new_level()
func new_level():
level += 1
goal += 5 * level
$DropTimer.wait_time = pow(0.8 - ((level - 1) * 0.007), level - 1)
if level > 15:
$LockDelay.wait_time = 0.5 * pow(0.9, level-15)
print("LEVEL ", level, " Goal ", goal)
new_piece()
func random_piece():
if not random_bag:
random_bag = [
TetroI,
TetroJ,
TetroL,
TetroO,
TetroS,
TetroT,
TetroZ
]
var choice = randi() % random_bag.size()
var piece = random_bag[choice].instance()
random_bag.remove(choice)
add_child(piece)
return piece
func new_piece():
current_piece = next_piece
current_piece.translation = START_POSITION
next_piece = random_piece()
next_piece.translation = NEXT_POSITION
if move(movements["soft_drop"]):
$DropTimer.start()
$LockDelay.start()
current_piece_held = false
else:
game_over()
func _process(delta):
if autoshift_action:
if not Input.is_action_pressed(autoshift_action):
$AutoShiftDelay.stop()
$AutoShiftTimer.stop()
autoshift_action = ""
if Input.is_action_just_pressed("pause"):
pause()
if playing and not hard_dropping:
for action in movements:
if action != autoshift_action:
if Input.is_action_pressed(action):
move(movements[action])
autoshift_action = action
$AutoShiftTimer.stop()
$AutoShiftDelay.start()
if Input.is_action_just_pressed("hard_drop"):
hard_dropping = true
$HardDropTimer.start()
if Input.is_action_just_pressed("rotate_clockwise"):
rotate(Tetromino.CLOCKWISE)
if Input.is_action_just_pressed("rotate_counterclockwise"):
rotate(Tetromino.COUNTERCLOCKWISE)
if Input.is_action_just_pressed("hold"):
hold()
func _on_AutoShiftDelay_timeout():
if playing and autoshift_action:
move(movements[autoshift_action])
$AutoShiftTimer.start()
func _on_AutoShiftTimer_timeout():
if playing and autoshift_action:
move(movements[autoshift_action])
func is_free_cell(position):
return (
0 <= position.x and position.x < NB_COLLUMNS
and position.y >= 0
and get_cell_item(position.x, position.y, 0) == GridMap.INVALID_CELL_ITEM
)
func possible_positions(initial_positions, movement):
var position
var test_positions = []
for i in range(4):
position = initial_positions[i] + movement
if is_free_cell(position):
test_positions.append(position)
if test_positions.size() == NB_MINOES:
return test_positions
else:
return []
func move(movement):
if current_piece.move(movement):
update_ghost_piece()
$LockDelay.start()
return true
else:
return false
func rotate(direction):
if current_piece.rotate(direction):
update_ghost_piece()
$LockDelay.start()
return true
else:
return false
func update_ghost_piece():
var positions = current_piece.positions()
for i in range(Tetromino.NB_MINOES):
$GhostPiece.minoes[i].translation = $GhostPiece.to_local(positions[i])
while $GhostPiece.move(movements["soft_drop"]):
pass
func _on_DropTimer_timeout():
move(movements["soft_drop"])
func _on_HardDropTimer_timeout():
if not move(movements["soft_drop"]):
$HardDropTimer.stop()
hard_dropping = false
lock_piece()
func _on_LockDelay_timeout():
if not move(movements["soft_drop"]):
lock_piece()
func lock_piece():
for mino in current_piece.minoes:
set_cell_item(current_piece.to_global(mino.translation).x, current_piece.to_global(mino.translation).y, 0, 0)
remove_child(current_piece)
line_clear()
func line_clear():
var NB_MINOES
lines_to_clear = []
for y in range(NB_LINES-1, -1, -1):
NB_MINOES = 0
for x in range(NB_COLLUMNS):
if get_cell_item(x, y, 0) == 0:
NB_MINOES += 1
if NB_MINOES == NB_COLLUMNS:
for x in range(NB_COLLUMNS):
set_cell_item(x, y, 0, EMPTY_CELL)
lines_to_clear.append(y)
exploding_lines[y].restart()
if lines_to_clear:
$ExplosionDelay.start()
update_score()
func update_score():
if lines_to_clear or current_piece.t_spin:
var s = SCORES[lines_to_clear.size()][current_piece.t_spin]
score += 100 * s
goal -= s
print(T_SPIN_NAMES[current_piece.t_spin], ' ', LINES_CLEARED_NAMES[lines_to_clear.size()], " Score ", score)
if goal <= 0:
new_level()
else:
new_piece()
func _on_ExplosionDelay_timeout():
for cleared_line in lines_to_clear:
for y in range(cleared_line, NB_LINES+2):
for x in range(NB_COLLUMNS):
set_cell_item(x, y, 0, get_cell_item(x, y+1, 0))
func hold():
if not current_piece_held:
if held_piece:
var tmp = held_piece
held_piece = current_piece
current_piece = tmp
current_piece.translation = START_POSITION
else:
held_piece = current_piece
new_piece()
held_piece.translation = HOLD_POSITION
current_piece_held = true
func pause():
playing = not playing
if playing:
$DropTimer.start()
$LockDelay.start()
print("RESUME")
else:
$DropTimer.stop()
$LockDelay.stop()
print("PAUSE")
func game_over():
playing = false
$DropTimer.stop()
$AutoShiftDelay.stop()
$AutoShiftTimer.stop()
print("GAME OVER")

115
GridMap.tscn Normal file
View File

@ -0,0 +1,115 @@
[gd_scene load_steps=7 format=2]
[ext_resource path="res://Tetrominos/Mino/MinoLibrary.tres" type="MeshLibrary" id=1]
[ext_resource path="res://GridMap.gd" type="Script" id=2]
[ext_resource path="res://GridBack.tscn" type="PackedScene" id=3]
[ext_resource path="res://Tetrominos/Mino/BackMaterial.tres" type="Material" id=4]
[ext_resource path="res://Tetrominos/GhostPiece.tscn" type="PackedScene" id=5]
[sub_resource type="CubeMesh" id=1]
material = ExtResource( 4 )
custom_aabb = AABB( 0, 0, 0, 0, 0, 0 )
size = Vector3( 1, 1, 1 )
subdivide_width = 0
subdivide_height = 0
subdivide_depth = 0
[node name="GridMap" type="GridMap" index="0"]
theme = ExtResource( 1 )
cell_size = Vector3( 1, 1, 1 )
cell_octant_size = 8
cell_center_x = false
cell_center_y = false
cell_center_z = false
cell_scale = 1.0
collision_layer = 1
collision_mask = 1
data = {
"cells": PoolIntArray( 13, 0, 0, 65543, 0, 0 )
}
script = ExtResource( 2 )
_sections_unfolded = [ "Cell", "Transform" ]
__meta__ = {
"_editor_clip_": 0,
"_editor_floor_": Vector3( 0, 3, 0 )
}
NB_LINES = 20
NB_COLLUMNS = 10
[node name="DropTimer" type="Timer" parent="." index="0"]
process_mode = 1
wait_time = 1.0
one_shot = false
autostart = false
[node name="LockDelay" type="Timer" parent="." index="1"]
process_mode = 1
wait_time = 0.5
one_shot = true
autostart = false
[node name="AutoShiftDelay" type="Timer" parent="." index="2"]
process_mode = 1
wait_time = 0.17
one_shot = true
autostart = false
[node name="AutoShiftTimer" type="Timer" parent="." index="3"]
process_mode = 1
wait_time = 0.02
one_shot = false
autostart = true
[node name="HardDropTimer" type="Timer" parent="." index="4"]
process_mode = 0
wait_time = 0.01
one_shot = false
autostart = false
[node name="ExplosionDelay" type="Timer" parent="." index="5"]
process_mode = 1
wait_time = 0.1
one_shot = true
autostart = false
[node name="GridBack" parent="." index="6" instance=ExtResource( 3 )]
transform = Transform( 10, 0, 0, 0, 20, 0, 0, 0, 0.1, 4.5, 9.5, -1 )
mesh = SubResource( 1 )
[node name="HoldBack" parent="." index="7" instance=ExtResource( 3 )]
transform = Transform( 7, 0, 0, 0, 7, 0, 0, 0, 0.1, -5, 16, -1 )
mesh = SubResource( 1 )
[node name="NextBack" parent="." index="8" instance=ExtResource( 3 )]
transform = Transform( 7, 0, 0, 0, 7, 0, 0, 0, 0.1, 14, 16, -1 )
mesh = SubResource( 1 )
[node name="GhostPiece" parent="." index="9" instance=ExtResource( 5 )]
_sections_unfolded = [ "Transform" ]
[connection signal="timeout" from="DropTimer" to="." method="_on_DropTimer_timeout"]
[connection signal="timeout" from="LockDelay" to="." method="_on_LockDelay_timeout"]
[connection signal="timeout" from="AutoShiftDelay" to="." method="_on_AutoShiftDelay_timeout"]
[connection signal="timeout" from="AutoShiftTimer" to="." method="_on_AutoShiftTimer_timeout"]
[connection signal="timeout" from="HardDropTimer" to="." method="_on_HardDropTimer_timeout"]
[connection signal="timeout" from="ExplosionDelay" to="." method="_on_ExplosionDelay_timeout"]

View File

@ -1,9 +1,8 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://Tetrominos/Mino/BackMaterial.tres" type="Material" id=1]
[ext_resource path="res://GridMap/BackMaterial.tres" type="Material" id=1]
[sub_resource type="CubeMesh" id=3]
[sub_resource type="CubeMesh" id=1]
material = ExtResource( 1 )
custom_aabb = AABB( 0, 0, 0, 0, 0, 0 )
@ -24,7 +23,7 @@ lod_min_distance = 0.0
lod_min_hysteresis = 0.0
lod_max_distance = 0.0
lod_max_hysteresis = 0.0
mesh = SubResource( 3 )
mesh = SubResource( 1 )
skeleton = NodePath("..")
material/0 = null
_sections_unfolded = [ "Transform" ]

View File

@ -1,6 +1,6 @@
extends GridMap
const ExplodingLine = preload("res://ExplodingLine.tscn")
const ExplodingLine = preload("res://ExplodingLine/ExplodingLine.tscn")
const Tetromino = preload("res://Tetrominos/Tetromino.gd")
const TetroI = preload("res://Tetrominos/TetroI.tscn")
const TetroJ = preload("res://Tetrominos/TetroJ.tscn")
@ -10,11 +10,21 @@ const TetroS = preload("res://Tetrominos/TetroS.tscn")
const TetroT = preload("res://Tetrominos/TetroT.tscn")
const TetroZ = preload("res://Tetrominos/TetroZ.tscn")
const NB_LINES = 20
const NB_COLLUMNS = 10
const EMPTY_CELL = -1
const NB_MINOES = 4
const NEXT_POSITION = Vector3(13, 16, 0)
const START_POSITION = Vector3(5, 20, 0)
const HOLD_POSITION = Vector3(-5, 16, 0)
const movements = {
"move_right": Vector3(1, 0, 0),
"move_left": Vector3(-1, 0, 0),
"soft_drop": Vector3(0, -1, 0)
}
const SCORES = [
[0, 4, 1],
[1, 8, 2],
@ -23,27 +33,21 @@ const SCORES = [
[8]
]
const LINES_CLEARED_NAMES = ["", "SINGLE", "DOUBLE", "TRIPLE", "TETRIS"]
const T_SPIN_NAMES = ["", "MINI T-SPIN", "T-SPIN"]
const T_SPIN_NAMES = ["", "T-SPIN", "MINI T-SPIN"]
export (int) var NB_LINES
export (int) var NB_COLLUMNS
const MIDI_MOVE_CHANNELS = [] #[7, 8, 9, 11, 12]
var next_piece = random_piece()
var current_piece
var held_piece
var current_piece_held = false
var locked = false
var autoshift_action = ""
var movements = {
"move_right": Vector3(1, 0, 0),
"move_left": Vector3(-1, 0, 0),
"soft_drop": Vector3(0, -1, 0)
}
var exploding_lines = []
var lines_to_clear = []
var hard_dropping = false
var random_bag = []
var playing = true
var level = 0
var goal = 0
var score = 0
@ -54,6 +58,7 @@ func _ready():
exploding_lines.append(ExplodingLine.instance())
add_child(exploding_lines[y])
exploding_lines[y].translation = Vector3(NB_COLLUMNS/2, y, 1)
resume()
new_level()
func new_level():
@ -68,13 +73,8 @@ func new_level():
func random_piece():
if not random_bag:
random_bag = [
TetroI,
TetroJ,
TetroL,
TetroO,
TetroS,
TetroT,
TetroZ
TetroI, TetroJ, TetroL, TetroO,
TetroS, TetroT, TetroZ
]
var choice = randi() % random_bag.size()
var piece = random_bag[choice].instance()
@ -85,6 +85,8 @@ func random_piece():
func new_piece():
current_piece = next_piece
current_piece.translation = START_POSITION
current_piece.emit_trail(true)
autoshift_action = ""
next_piece = random_piece()
next_piece.translation = NEXT_POSITION
if move(movements["soft_drop"]):
@ -101,24 +103,31 @@ func _process(delta):
$AutoShiftTimer.stop()
autoshift_action = ""
if Input.is_action_just_pressed("pause"):
pause()
if playing and not hard_dropping:
for action in movements:
if action != autoshift_action:
if Input.is_action_pressed(action):
move(movements[action])
autoshift_action = action
$AutoShiftTimer.stop()
$AutoShiftDelay.start()
if Input.is_action_just_pressed("hard_drop"):
hard_dropping = true
$HardDropTimer.start()
if Input.is_action_just_pressed("rotate_clockwise"):
rotate(Tetromino.CLOCKWISE)
if Input.is_action_just_pressed("rotate_counterclockwise"):
rotate(Tetromino.COUNTERCLOCKWISE)
if Input.is_action_just_pressed("hold"):
hold()
if playing:
pause()
else:
resume()
if playing:
process_actions()
func process_actions():
for action in movements:
if action != autoshift_action:
if Input.is_action_pressed(action):
move(movements[action])
autoshift_action = action
$AutoShiftTimer.stop()
$AutoShiftDelay.start()
if Input.is_action_just_pressed("hard_drop"):
while move(movements["soft_drop"]):
pass
lock_piece()
if Input.is_action_just_pressed("rotate_clockwise"):
rotate(Tetromino.CLOCKWISE)
if Input.is_action_just_pressed("rotate_counterclockwise"):
rotate(Tetromino.COUNTERCLOCKWISE)
if Input.is_action_just_pressed("hold"):
hold()
func _on_AutoShiftDelay_timeout():
if playing and autoshift_action:
@ -143,14 +152,13 @@ func possible_positions(initial_positions, movement):
position = initial_positions[i] + movement
if is_free_cell(position):
test_positions.append(position)
if test_positions.size() == NB_MINOES:
if test_positions.size() == Tetromino.NB_MINOES:
return test_positions
else:
return []
func move(movement):
if current_piece.move(movement):
update_ghost_piece()
$LockDelay.start()
return true
else:
@ -158,28 +166,14 @@ func move(movement):
func rotate(direction):
if current_piece.rotate(direction):
update_ghost_piece()
$LockDelay.start()
return true
else:
return false
func update_ghost_piece():
var positions = current_piece.positions()
for i in range(Tetromino.NB_MINOES):
$GhostPiece.minoes[i].translation = $GhostPiece.to_local(positions[i])
while $GhostPiece.move(movements["soft_drop"]):
pass
func _on_DropTimer_timeout():
move(movements["soft_drop"])
func _on_HardDropTimer_timeout():
if not move(movements["soft_drop"]):
$HardDropTimer.stop()
hard_dropping = false
lock_piece()
func _on_LockDelay_timeout():
if not move(movements["soft_drop"]):
lock_piece()
@ -192,38 +186,40 @@ func lock_piece():
func line_clear():
var NB_MINOES
lines_to_clear = []
var lines_cleared = 0
for y in range(NB_LINES-1, -1, -1):
NB_MINOES = 0
for x in range(NB_COLLUMNS):
if get_cell_item(x, y, 0) == 0:
NB_MINOES += 1
if NB_MINOES == NB_COLLUMNS:
for x in range(NB_COLLUMNS):
set_cell_item(x, y, 0, EMPTY_CELL)
lines_to_clear.append(y)
for y2 in range(y, NB_LINES+2):
for x in range(NB_COLLUMNS):
set_cell_item(x, y2, 0, get_cell_item(x, y2+1, 0))
lines_cleared += 1
exploding_lines[y].restart()
if lines_to_clear:
$ExplosionDelay.start()
update_score()
func update_score():
if lines_to_clear or current_piece.t_spin:
var s = SCORES[lines_to_clear.size()][current_piece.t_spin]
if lines_cleared or current_piece.t_spin:
var s = SCORES[lines_cleared][current_piece.t_spin]
score += 100 * s
goal -= s
print(T_SPIN_NAMES[current_piece.t_spin], ' ', LINES_CLEARED_NAMES[lines_to_clear.size()], " Score ", score)
print(T_SPIN_NAMES[current_piece.t_spin], ' ', LINES_CLEARED_NAMES[lines_cleared], " Score ", score)
if lines_cleared == Tetromino.NB_MINOES:
for channel in $MidiPlayer.line_clear_notes:
$MidiPlayer.channel_status[channel].vomume = 127
$MidiPlayer/LineCLearTimer.wait_time = 0.86
else:
for channel in $MidiPlayer.line_clear_notes:
$MidiPlayer.channel_status[channel].vomume = 100
$MidiPlayer/LineCLearTimer.wait_time = 0.43
$MidiPlayer.mute_midi_channels($MidiPlayer.line_clear_notes, false)
$MidiPlayer.play_line_clear()
$MidiPlayer/LineCLearTimer.start()
if goal <= 0:
new_level()
else:
new_piece()
func _on_ExplosionDelay_timeout():
for cleared_line in lines_to_clear:
for y in range(cleared_line, NB_LINES+2):
for x in range(NB_COLLUMNS):
set_cell_item(x, y, 0, get_cell_item(x, y+1, 0))
func hold():
if not current_piece_held:
if held_piece:
@ -231,26 +227,38 @@ func hold():
held_piece = current_piece
current_piece = tmp
current_piece.translation = START_POSITION
current_piece.emit_trail(true)
else:
held_piece = current_piece
new_piece()
held_piece.emit_trail(false)
held_piece.translation = HOLD_POSITION
current_piece_held = true
func pause():
playing = not playing
if playing:
$DropTimer.start()
$LockDelay.start()
print("RESUME")
else:
$DropTimer.stop()
$LockDelay.stop()
print("PAUSE")
func resume():
playing = true
$DropTimer.start()
$LockDelay.start()
$MidiPlayer.resume()
$MidiPlayer.mute_midi_channels($MidiPlayer.line_clear_notes, true)
print("RESUME")
func game_over():
func pause():
playing = false
$DropTimer.stop()
$AutoShiftDelay.stop()
$AutoShiftTimer.stop()
$LockDelay.stop()
$MidiPlayer.stop()
print("PAUSE")
func game_over():
pause()
print("GAME OVER")
func _notification(what):
if what == MainLoop.NOTIFICATION_WM_FOCUS_OUT:
pause()
if what == MainLoop.NOTIFICATION_WM_FOCUS_IN:
resume()
func _on_LineCLearTimer_timeout():
$MidiPlayer.mute_midi_channels($MidiPlayer.line_clear_notes, true)

View File

@ -3,10 +3,8 @@
[ext_resource path="res://Tetrominos/Mino/MinoLibrary.tres" type="MeshLibrary" id=1]
[ext_resource path="res://GridMap/GridMap.gd" type="Script" id=2]
[ext_resource path="res://GridMap/GridBack.tscn" type="PackedScene" id=3]
[ext_resource path="res://Tetrominos/Mino/BackMaterial.tres" type="Material" id=4]
[ext_resource path="res://Tetrominos/GhostPiece.tscn" type="PackedScene" id=5]
[ext_resource path="res://GridMap/BackMaterial.tres" type="Material" id=4]
[ext_resource path="res://midi/MidiPlayer.tscn" type="PackedScene" id=5]
[sub_resource type="CubeMesh" id=1]
@ -17,7 +15,7 @@ subdivide_width = 0
subdivide_height = 0
subdivide_depth = 0
[node name="GridMap" type="GridMap" index="0"]
[node name="GridMap" type="GridMap"]
theme = ExtResource( 1 )
cell_size = Vector3( 1, 1, 1 )
@ -29,16 +27,14 @@ cell_scale = 1.0
collision_layer = 1
collision_mask = 1
data = {
"cells": PoolIntArray( 13, 0, 0, 65543, 0, 0 )
"cells": PoolIntArray( )
}
script = ExtResource( 2 )
_sections_unfolded = [ "Cell", "Transform" ]
__meta__ = {
"_editor_clip_": 0,
"_editor_floor_": Vector3( 0, 3, 0 )
"_editor_clip_": 1,
"_editor_floor_": Vector3( 0, -1, 0 )
}
NB_LINES = 20
NB_COLLUMNS = 10
[node name="DropTimer" type="Timer" parent="." index="0"]
@ -68,38 +64,35 @@ wait_time = 0.02
one_shot = false
autostart = true
[node name="HardDropTimer" type="Timer" parent="." index="4"]
process_mode = 0
wait_time = 0.01
one_shot = false
autostart = false
[node name="ExplosionDelay" type="Timer" parent="." index="5"]
process_mode = 1
wait_time = 0.1
one_shot = true
autostart = false
[node name="GridBack" parent="." index="6" instance=ExtResource( 3 )]
[node name="GridBack" parent="." index="4" instance=ExtResource( 3 )]
transform = Transform( 10, 0, 0, 0, 20, 0, 0, 0, 0.1, 4.5, 9.5, -1 )
mesh = SubResource( 1 )
[node name="HoldBack" parent="." index="7" instance=ExtResource( 3 )]
[node name="HoldBack" parent="." index="5" instance=ExtResource( 3 )]
transform = Transform( 7, 0, 0, 0, 7, 0, 0, 0, 0.1, -5, 16, -1 )
mesh = SubResource( 1 )
[node name="NextBack" parent="." index="8" instance=ExtResource( 3 )]
[node name="NextBack" parent="." index="6" instance=ExtResource( 3 )]
transform = Transform( 7, 0, 0, 0, 7, 0, 0, 0, 0.1, 14, 16, -1 )
mesh = SubResource( 1 )
[node name="GhostPiece" parent="." index="9" instance=ExtResource( 5 )]
[node name="MidiPlayer" parent="." index="7" instance=ExtResource( 5 )]
_sections_unfolded = [ "Transform" ]
file = "res://midi/Tetris - Song A.mid"
volume_db = -24
loop = true
loop_start = 1.81
soundfont = "res://midi/FluidR3 GM.sf2"
[node name="LineCLearTimer" type="Timer" parent="MidiPlayer" index="1"]
process_mode = 1
wait_time = 1.41
one_shot = true
autostart = false
[connection signal="timeout" from="DropTimer" to="." method="_on_DropTimer_timeout"]
@ -109,8 +102,6 @@ _sections_unfolded = [ "Transform" ]
[connection signal="timeout" from="AutoShiftTimer" to="." method="_on_AutoShiftTimer_timeout"]
[connection signal="timeout" from="HardDropTimer" to="." method="_on_HardDropTimer_timeout"]
[connection signal="timeout" from="ExplosionDelay" to="." method="_on_ExplosionDelay_timeout"]
[connection signal="timeout" from="MidiPlayer/LineCLearTimer" to="." method="_on_LineCLearTimer_timeout"]

143
Mino.tscn Normal file
View File

@ -0,0 +1,143 @@
[gd_scene load_steps=6 format=2]
[ext_resource path="res://MinoMesh.tscn" type="PackedScene" id=1]
[ext_resource path="res://MinoMesh.tres" type="CubeMesh" id=2]
[sub_resource type="SpatialMaterial" id=1]
render_priority = 0
flags_transparent = true
flags_unshaded = false
flags_vertex_lighting = false
flags_no_depth_test = false
flags_use_point_size = false
flags_world_triplanar = false
flags_fixed_size = false
flags_albedo_tex_force_srgb = false
vertex_color_use_as_albedo = false
vertex_color_is_srgb = false
params_diffuse_mode = 0
params_specular_mode = 0
params_blend_mode = 1
params_cull_mode = 0
params_depth_draw_mode = 0
params_line_width = 1.0
params_point_size = 1.0
params_billboard_mode = 0
params_grow = false
params_use_alpha_scissor = false
albedo_color = Color( 0.601563, 0.775878, 1, 0.520275 )
metallic = 0.68
metallic_specular = 1.0
metallic_texture_channel = 0
roughness = 0.0
roughness_texture_channel = 0
emission_enabled = false
normal_enabled = false
rim_enabled = false
clearcoat_enabled = false
anisotropy_enabled = false
ao_enabled = false
depth_enabled = false
subsurf_scatter_enabled = false
transmission_enabled = false
refraction_enabled = false
detail_enabled = false
uv1_scale = Vector3( 1, 1, 1 )
uv1_offset = Vector3( 0, 0, 0 )
uv1_triplanar = false
uv1_triplanar_sharpness = 1.0
uv2_scale = Vector3( 1, 1, 1 )
uv2_offset = Vector3( 0, 0, 0 )
uv2_triplanar = false
uv2_triplanar_sharpness = 1.0
proximity_fade_enable = true
proximity_fade_distance = 1.0
distance_fade_enable = false
_sections_unfolded = [ "Emission", "Metallic", "NormalMap", "Proximity Fade" ]
[sub_resource type="GradientTexture" id=2]
flags = 4
width = 2048
[sub_resource type="ParticlesMaterial" id=3]
render_priority = 0
trail_divisor = 1
emission_shape = 0
flag_align_y = false
flag_rotate_y = false
flag_disable_z = true
spread = 0.0
flatness = 0.0
gravity = Vector3( 0, -30, 0 )
initial_velocity = 0.0
initial_velocity_random = 0.0
angular_velocity = 0.0
angular_velocity_random = 0.0
orbit_velocity = 0.0
orbit_velocity_random = 0.0
linear_accel = 0.0
linear_accel_random = 0.0
radial_accel = 0.0
radial_accel_random = 0.0
tangential_accel = 0.0
tangential_accel_random = 0.0
damping = 0.0
damping_random = 0.0
angle = 0.0
angle_random = 0.0
scale = 1.0
scale_random = 0.0
color_ramp = SubResource( 2 )
hue_variation = 0.0
hue_variation_random = 0.0
anim_speed = 0.0
anim_speed_random = 0.0
anim_offset = 0.0
anim_offset_random = 0.0
anim_loop = false
_sections_unfolded = [ "Angular Velocity", "Color", "Gravity", "Initial Velocity" ]
[node name="Mino" type="Spatial"]
_sections_unfolded = [ "Pause", "Transform", "Visibility" ]
[node name="MinoMesh" parent="." index="0" instance=ExtResource( 1 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.5, 0.5, 1 )
_sections_unfolded = [ "Geometry", "Transform", "material" ]
[node name="Trail" type="Particles" parent="." index="1"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.5, 0.5, 0.5 )
visible = false
layers = 1
material_override = SubResource( 1 )
cast_shadow = 1
extra_cull_margin = 0.0
use_in_baked_light = false
lod_min_distance = 0.0
lod_min_hysteresis = 0.0
lod_max_distance = 0.0
lod_max_hysteresis = 0.0
emitting = true
amount = 10
lifetime = 0.1
one_shot = false
preprocess = 0.0
speed_scale = 1.0
explosiveness = 0.0
randomness = 0.0
fixed_fps = 0
fract_delta = true
visibility_aabb = AABB( -4, -4, -4, 8, 8, 8 )
local_coords = false
draw_order = 0
process_material = SubResource( 3 )
draw_passes = 1
draw_pass_1 = ExtResource( 2 )
_sections_unfolded = [ "Draw Passes", "Process Material", "Transform" ]

BIN
MinoLibrary.meshlib Normal file

Binary file not shown.

40
MinoLibrary.tres Normal file

File diff suppressed because one or more lines are too long

59
MinoMaterial.tres Normal file
View File

@ -0,0 +1,59 @@
[gd_resource type="SpatialMaterial" format=2]
[resource]
render_priority = 0
flags_transparent = true
flags_unshaded = false
flags_vertex_lighting = false
flags_no_depth_test = false
flags_use_point_size = false
flags_world_triplanar = false
flags_fixed_size = false
flags_albedo_tex_force_srgb = false
vertex_color_use_as_albedo = false
vertex_color_is_srgb = false
params_diffuse_mode = 0
params_specular_mode = 0
params_blend_mode = 1
params_cull_mode = 0
params_depth_draw_mode = 0
params_line_width = 1.0
params_point_size = 1.0
params_billboard_mode = 0
params_grow = false
params_use_alpha_scissor = false
albedo_color = Color( 0.601563, 0.775878, 1, 1 )
metallic = 0.68
metallic_specular = 1.0
metallic_texture_channel = 0
roughness = 0.46
roughness_texture_channel = 0
emission_enabled = true
emission = Color( 0.71875, 0.897827, 1, 1 )
emission_energy = 0.3
emission_operator = 1
emission_on_uv2 = false
normal_enabled = false
rim_enabled = false
clearcoat_enabled = false
anisotropy_enabled = false
ao_enabled = false
depth_enabled = false
subsurf_scatter_enabled = false
transmission_enabled = false
refraction_enabled = false
detail_enabled = false
uv1_scale = Vector3( 1, 1, 1 )
uv1_offset = Vector3( 0, 0, 0 )
uv1_triplanar = false
uv1_triplanar_sharpness = 1.0
uv2_scale = Vector3( 1, 1, 1 )
uv2_offset = Vector3( 0, 0, 0 )
uv2_triplanar = false
uv2_triplanar_sharpness = 1.0
proximity_fade_enable = true
proximity_fade_distance = 1.0
distance_fade_enable = false
_sections_unfolded = [ "Emission", "NormalMap", "Proximity Fade", "Roughness" ]

10
MinoMesh.tres Normal file
View File

@ -0,0 +1,10 @@
[gd_resource type="CubeMesh" format=2]
[resource]
custom_aabb = AABB( 0, 0, 0, 0, 0, 0 )
size = Vector3( 0.9, 0.9, 1.9 )
subdivide_width = 0
subdivide_height = 0
subdivide_depth = 0

29
MinoMesh.tscn Normal file
View File

@ -0,0 +1,29 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://MinoMaterial.tres" type="Material" id=1]
[sub_resource type="CubeMesh" id=1]
custom_aabb = AABB( 0, 0, 0, 0, 0, 0 )
size = Vector3( 0.9, 0.9, 0.9 )
subdivide_width = 0
subdivide_height = 0
subdivide_depth = 0
[node name="Mino" type="MeshInstance"]
layers = 1
material_override = null
cast_shadow = 1
extra_cull_margin = 0.0
use_in_baked_light = false
lod_min_distance = 0.0
lod_min_hysteresis = 0.0
lod_max_distance = 0.0
lod_max_hysteresis = 0.0
mesh = SubResource( 1 )
skeleton = NodePath("..")
material/0 = ExtResource( 1 )
_sections_unfolded = [ "Transform", "material" ]

11
Mino_Library.tscn Normal file
View File

@ -0,0 +1,11 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://Tetrominos/Mino/MinoMesh.tscn" type="PackedScene" id=1]
[node name="Mino_Library" type="Spatial" index="0"]
[node name="Mino" parent="." index="0" instance=ExtResource( 1 )]

59
SparkSpatialmaterial.tres Normal file
View File

@ -0,0 +1,59 @@
[gd_resource type="SpatialMaterial" format=2]
[resource]
render_priority = 0
flags_transparent = true
flags_unshaded = false
flags_vertex_lighting = false
flags_no_depth_test = false
flags_use_point_size = false
flags_world_triplanar = false
flags_fixed_size = false
flags_albedo_tex_force_srgb = false
vertex_color_use_as_albedo = false
vertex_color_is_srgb = false
params_diffuse_mode = 0
params_specular_mode = 0
params_blend_mode = 1
params_cull_mode = 0
params_depth_draw_mode = 0
params_line_width = 1.0
params_point_size = 1.0
params_billboard_mode = 0
params_grow = false
params_use_alpha_scissor = false
albedo_color = Color( 0.887543, 1, 0.738281, 0.529294 )
metallic = 0.78
metallic_specular = 1.0
metallic_texture_channel = 0
roughness = 0.49
roughness_texture_channel = 0
emission_enabled = true
emission = Color( 1, 1, 0.700471, 1 )
emission_energy = 0.2
emission_operator = 0
emission_on_uv2 = false
normal_enabled = false
rim_enabled = false
clearcoat_enabled = false
anisotropy_enabled = false
ao_enabled = false
depth_enabled = false
subsurf_scatter_enabled = false
transmission_enabled = false
refraction_enabled = false
detail_enabled = false
uv1_scale = Vector3( 1, 1, 1 )
uv1_offset = Vector3( 0, 0, 0 )
uv1_triplanar = false
uv1_triplanar_sharpness = 1.0
uv2_scale = Vector3( 1, 1, 1 )
uv2_offset = Vector3( 0, 0, 0 )
uv2_triplanar = false
uv2_triplanar_sharpness = 1.0
proximity_fade_enable = true
proximity_fade_distance = 1.0
distance_fade_enable = false
_sections_unfolded = [ "Emission", "Proximity Fade" ]

70
TetroI.gd Normal file
View File

@ -0,0 +1,70 @@
extends "Tetrominos/Tetromino.gd"
const CLOCKWISE = -1
const COUNTERCLOCKWISE = 1
const SUPER_ROTATION_SYSTEM = [
{
COUNTERCLOCKWISE: [
Vector3(0, -1, 0),
Vector3(-1, -1, 0),
Vector3(2, -1, 0),
Vector3(-1, 1, 0),
Vector3(2, -2, 0)
],
CLOCKWISE: [
Vector3(1, 0, 0),
Vector3(-1, 0, 0),
Vector3(2, 0, 0),
Vector3(-1, -1, 0),
Vector3(2, 2, 0)
],
},
{
COUNTERCLOCKWISE: [
Vector3(-1, 0, 0),
Vector3(1, 0, 0),
Vector3(-2, 0, 0),
Vector3(1, 1, 0),
Vector3(-2, -2, 0)
],
CLOCKWISE: [
Vector3(0, -1, 0),
Vector3(-1, -1, 0),
Vector3(2, -1, 0),
Vector3(-1, 1, 0),
Vector3(2, -2, 0)
],
},
{
COUNTERCLOCKWISE: [
Vector3(0, 1, 0),
Vector3(1, 1, 0),
Vector3(-2, 1, 0),
Vector3(1, -1, 0),
Vector3(-2, 2, 0)
],
CLOCKWISE: [
Vector3(-1, 0, 0),
Vector3(1, 0, 0),
Vector3(-2, 0, 0),
Vector3(1, 1, 0),
Vector3(-2, -2, 0)
],
},
{
COUNTERCLOCKWISE: [
Vector3(1, 0, 0),
Vector3(-1, 0, 0),
Vector3(2, 0, 0),
Vector3(-1, -1, 0),
Vector3(2, 2, 0)
],
CLOCKWISE: [
Vector3(0, 1, 0),
Vector3(1, 1, 0),
Vector3(-2, 1, 0),
Vector3(1, -1, 0),
Vector3(-2, 2, 0)
],
},
]

6
TetroT.gd Normal file
View File

@ -0,0 +1,6 @@
extends Spatial
var minos
func _ready():
minos = [$Mino, $Mino2, $Mino3, $Mino4]

25
TetroT.tscn Normal file
View File

@ -0,0 +1,25 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://TetroT.gd" type="Script" id=1]
[ext_resource path="res://Mino.tscn" type="PackedScene" id=2]
[node name="TetroT" type="Spatial"]
script = ExtResource( 1 )
_sections_unfolded = [ "Transform" ]
[node name="Mino" parent="." index="0" instance=ExtResource( 2 )]
[node name="Mino2" parent="." index="1" instance=ExtResource( 2 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -1, 0, 0 )
[node name="Mino3" parent="." index="2" instance=ExtResource( 2 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0 )
[node name="Mino4" parent="." index="3" instance=ExtResource( 2 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0 )

View File

@ -1,8 +1,9 @@
[gd_scene load_steps=6 format=2]
[gd_scene load_steps=9 format=2]
[ext_resource path="res://Tetrominos/Mino/MinoMesh.tscn" type="PackedScene" id=1]
[ext_resource path="res://Tetrominos/Mino/MinoMesh.tres" type="CubeMesh" id=2]
[ext_resource path="res://Tetrominos/Mino/TrailMaterial.tres" type="Material" id=3]
[ext_resource path="res://Tetrominos/Mino/SpotLight.tscn" type="PackedScene" id=4]
[sub_resource type="SpatialMaterial" id=1]
@ -27,7 +28,7 @@ params_point_size = 1.0
params_billboard_mode = 0
params_grow = false
params_use_alpha_scissor = false
albedo_color = Color( 0.601563, 0.775878, 1, 0.520275 )
albedo_color = Color( 0.601563, 0.775878, 1, 0.270275 )
metallic = 0.68
metallic_specular = 1.0
metallic_texture_channel = 0
@ -55,7 +56,7 @@ uv2_triplanar_sharpness = 1.0
proximity_fade_enable = true
proximity_fade_distance = 1.0
distance_fade_enable = false
_sections_unfolded = [ "Emission", "Metallic", "NormalMap", "Proximity Fade" ]
_sections_unfolded = [ "Albedo", "Emission", "Metallic", "NormalMap", "Proximity Fade" ]
[sub_resource type="GradientTexture" id=2]
@ -72,7 +73,7 @@ flag_rotate_y = false
flag_disable_z = true
spread = 0.0
flatness = 0.0
gravity = Vector3( 0, -30, 0 )
gravity = Vector3( 0, 0, 0 )
initial_velocity = 0.0
initial_velocity_random = 0.0
angular_velocity = 0.0
@ -99,7 +100,16 @@ anim_speed_random = 0.0
anim_offset = 0.0
anim_offset_random = 0.0
anim_loop = false
_sections_unfolded = [ "Angular Velocity", "Color", "Gravity", "Initial Velocity" ]
_sections_unfolded = [ "Color", "Gravity" ]
[sub_resource type="CubeMesh" id=4]
material = ExtResource( 3 )
custom_aabb = AABB( 0, 0, 0, 0, 0, 0 )
size = Vector3( 0.9, 0.9, 0.9 )
subdivide_width = 0
subdivide_height = 0
subdivide_depth = 0
[node name="Mino" type="Spatial"]
@ -107,13 +117,12 @@ _sections_unfolded = [ "Pause", "Transform", "Visibility" ]
[node name="MinoMesh" parent="." index="0" instance=ExtResource( 1 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.5, 0.5, 1 )
mesh = ExtResource( 2 )
material/0 = null
_sections_unfolded = [ "Geometry", "Transform", "material" ]
[node name="Trail" type="Particles" parent="." index="1"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.5, 0.5, 0.5 )
visible = false
layers = 1
material_override = SubResource( 1 )
cast_shadow = 1
@ -123,8 +132,8 @@ lod_min_distance = 0.0
lod_min_hysteresis = 0.0
lod_max_distance = 0.0
lod_max_hysteresis = 0.0
emitting = true
amount = 10
emitting = false
amount = 4
lifetime = 0.1
one_shot = false
preprocess = 0.0
@ -133,12 +142,17 @@ explosiveness = 0.0
randomness = 0.0
fixed_fps = 0
fract_delta = true
visibility_aabb = AABB( -4, -4, -4, 8, 8, 8 )
visibility_aabb = AABB( -0.5, -0.5, -0.5, 1, 1, 1 )
local_coords = false
draw_order = 0
process_material = SubResource( 3 )
draw_passes = 1
draw_pass_1 = ExtResource( 2 )
_sections_unfolded = [ "Draw Passes", "Process Material", "Transform" ]
draw_pass_1 = SubResource( 4 )
_sections_unfolded = [ "Draw Passes", "Drawing", "Geometry", "LOD", "Process Material", "Time", "Transform" ]
[node name="SpotLight" parent="." index="2" instance=ExtResource( 4 )]
transform = Transform( 1, 0, 0, 0, -4.37114e-008, 1, 0, -1, -4.37114e-008, 0, 0, 1 )
light_energy = 4.0

File diff suppressed because one or more lines are too long

View File

@ -23,16 +23,16 @@ params_point_size = 1.0
params_billboard_mode = 0
params_grow = false
params_use_alpha_scissor = false
albedo_color = Color( 0.601563, 0.775878, 1, 1 )
metallic = 0.68
albedo_color = Color( 0.601563, 0.775878, 1, 0.162157 )
metallic = 0.4
metallic_specular = 1.0
metallic_texture_channel = 0
roughness = 0.46
roughness_texture_channel = 0
emission_enabled = true
emission = Color( 0.71875, 0.897827, 1, 1 )
emission_energy = 0.3
emission_operator = 1
emission = Color( 0.755859, 1, 0.914169, 1 )
emission_energy = 0.7
emission_operator = 0
emission_on_uv2 = false
normal_enabled = false
rim_enabled = false
@ -55,5 +55,5 @@ uv2_triplanar_sharpness = 1.0
proximity_fade_enable = true
proximity_fade_distance = 1.0
distance_fade_enable = false
_sections_unfolded = [ "Emission", "NormalMap", "Proximity Fade", "Roughness" ]
_sections_unfolded = [ "Albedo", "Emission", "NormalMap", "Proximity Fade" ]

View File

@ -1,9 +1,12 @@
[gd_resource type="CubeMesh" format=2]
[gd_resource type="CubeMesh" load_steps=2 format=2]
[ext_resource path="res://Tetrominos/Mino/MinoMaterial.tres" type="Material" id=1]
[resource]
material = ExtResource( 1 )
custom_aabb = AABB( 0, 0, 0, 0, 0, 0 )
size = Vector3( 0.9, 0.9, 1.9 )
size = Vector3( 0.9, 0.9, 0.9 )
subdivide_width = 0
subdivide_height = 0
subdivide_depth = 0

View File

@ -3,6 +3,7 @@
[ext_resource path="res://Tetrominos/Mino/MinoMaterial.tres" type="Material" id=1]
[sub_resource type="CubeMesh" id=1]
custom_aabb = AABB( 0, 0, 0, 0, 0, 0 )
@ -11,7 +12,7 @@ subdivide_width = 0
subdivide_height = 0
subdivide_depth = 0
[node name="Mino" type="MeshInstance"]
[node name="Mino" type="MeshInstance" index="0"]
layers = 1
material_override = null

View File

@ -23,7 +23,7 @@ params_point_size = 1.0
params_billboard_mode = 0
params_grow = false
params_use_alpha_scissor = false
albedo_color = Color( 0.601563, 0.775878, 1, 0.520275 )
albedo_color = Color( 0.601563, 0.775878, 1, 0.0196078 )
metallic = 0.68
metallic_specular = 1.0
metallic_texture_channel = 0
@ -51,5 +51,5 @@ uv2_triplanar_sharpness = 1.0
proximity_fade_enable = true
proximity_fade_distance = 1.0
distance_fade_enable = false
_sections_unfolded = [ "Proximity Fade" ]
_sections_unfolded = [ "Albedo", "Emission", "Proximity Fade" ]

View File

@ -1,4 +1,4 @@
extends "Tetrominos/Tetromino.gd"
extends "Tetromino.gd"
const CLOCKWISE = -1
const COUNTERCLOCKWISE = 1

View File

@ -1,6 +1,26 @@
extends Spatial
extends "Tetromino.gd"
var minos
const T_SLOT = [
Vector3(-1, 1, 0),
Vector3(1, 1, 0),
Vector3(1, -1, 0),
Vector3(-1, -1, 0)
]
func _ready():
minos = [$Mino, $Mino2, $Mino3, $Mino4]
func rotate(direction):
if .rotate(direction):
detect_t_spin()
return true
return false
func detect_t_spin():
var center = to_global(minoes[0].translation)
var a = not get_parent().is_free_cell(center + T_SLOT[orientation])
var b = not get_parent().is_free_cell(center + T_SLOT[(1+orientation)%4])
var c = not get_parent().is_free_cell(center + T_SLOT[(2+orientation)%4])
var d = not get_parent().is_free_cell(center + T_SLOT[(3+orientation)%4])
if a and b and (c or d):
t_spin = T_SPIN
elif c and d and (a or b):
if t_spin != T_SPIN:
t_spin = MINI_T_SPIN

View File

@ -4,24 +4,22 @@
[ext_resource path="res://Tetrominos/Mino/Mino.tscn" type="PackedScene" id=2]
[node name="TetroT" type="Spatial"]
[node name="TetroT" type="Spatial" index="0"]
script = ExtResource( 1 )
_sections_unfolded = [ "Transform" ]
[node name="Mino" parent="." index="0" instance=ExtResource( 2 )]
[node name="Mino0" parent="." index="0" instance=ExtResource( 2 )]
[node name="Mino2" parent="." index="1" instance=ExtResource( 2 )]
[node name="Mino1" parent="." index="1" instance=ExtResource( 2 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -1, 0, 0 )
[node name="Mino3" parent="." index="2" instance=ExtResource( 2 )]
[node name="Mino2" parent="." index="2" instance=ExtResource( 2 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0 )
[node name="Mino3" parent="." index="3" instance=ExtResource( 2 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0 )
[node name="Mino4" parent="." index="3" instance=ExtResource( 2 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0 )

55
TrailMaterial.tres Normal file
View File

@ -0,0 +1,55 @@
[gd_resource type="SpatialMaterial" format=2]
[resource]
render_priority = 0
flags_transparent = true
flags_unshaded = false
flags_vertex_lighting = false
flags_no_depth_test = false
flags_use_point_size = false
flags_world_triplanar = false
flags_fixed_size = false
flags_albedo_tex_force_srgb = false
vertex_color_use_as_albedo = false
vertex_color_is_srgb = false
params_diffuse_mode = 0
params_specular_mode = 0
params_blend_mode = 1
params_cull_mode = 0
params_depth_draw_mode = 0
params_line_width = 1.0
params_point_size = 1.0
params_billboard_mode = 0
params_grow = false
params_use_alpha_scissor = false
albedo_color = Color( 0.601563, 0.775878, 1, 0.520275 )
metallic = 0.68
metallic_specular = 1.0
metallic_texture_channel = 0
roughness = 0.0
roughness_texture_channel = 0
emission_enabled = false
normal_enabled = false
rim_enabled = false
clearcoat_enabled = false
anisotropy_enabled = false
ao_enabled = false
depth_enabled = false
subsurf_scatter_enabled = false
transmission_enabled = false
refraction_enabled = false
detail_enabled = false
uv1_scale = Vector3( 1, 1, 1 )
uv1_offset = Vector3( 0, 0, 0 )
uv1_triplanar = false
uv1_triplanar_sharpness = 1.0
uv2_scale = Vector3( 1, 1, 1 )
uv2_offset = Vector3( 0, 0, 0 )
uv2_triplanar = false
uv2_triplanar_sharpness = 1.0
proximity_fade_enable = true
proximity_fade_distance = 1.0
distance_fade_enable = false
_sections_unfolded = [ "Proximity Fade" ]