GHOST PIECE
This commit is contained in:
parent
ac6e561c3d
commit
92b97dbfb3
@ -43,7 +43,7 @@ func new_game(level):
|
|||||||
func new_piece():
|
func new_piece():
|
||||||
current_piece = next_piece
|
current_piece = next_piece
|
||||||
current_piece.translation = $Matrix/Position3D.translation
|
current_piece.translation = $Matrix/Position3D.translation
|
||||||
current_piece.turn_light(true)
|
current_piece.move_ghost()
|
||||||
next_piece = random_piece()
|
next_piece = random_piece()
|
||||||
next_piece.translation = $Next/Position3D.translation
|
next_piece.translation = $Next/Position3D.translation
|
||||||
if $Matrix/GridMap.possible_positions(current_piece.get_translations(), THERE):
|
if $Matrix/GridMap.possible_positions(current_piece.get_translations(), THERE):
|
||||||
@ -159,13 +159,12 @@ func hold():
|
|||||||
var swap = current_piece
|
var swap = current_piece
|
||||||
current_piece = held_piece
|
current_piece = held_piece
|
||||||
held_piece = swap
|
held_piece = swap
|
||||||
held_piece.turn_light(false)
|
|
||||||
for mino in held_piece.minoes:
|
for mino in held_piece.minoes:
|
||||||
mino.get_node("LockingMesh").visible = false
|
mino.get_node("LockingMesh").visible = false
|
||||||
held_piece.translation = $Hold/Position3D.translation
|
held_piece.translation = $Hold/Position3D.translation
|
||||||
if current_piece:
|
if current_piece:
|
||||||
current_piece.translation = $Matrix/Position3D.translation
|
current_piece.translation = $Matrix/Position3D.translation
|
||||||
current_piece.turn_light(true)
|
current_piece.move_ghost()
|
||||||
else:
|
else:
|
||||||
new_piece()
|
new_piece()
|
||||||
|
|
||||||
@ -182,6 +181,7 @@ func resume():
|
|||||||
$Hold.visible = true
|
$Hold.visible = true
|
||||||
$Next.visible = true
|
$Next.visible = true
|
||||||
current_piece.visible = true
|
current_piece.visible = true
|
||||||
|
$Ghost.visible = true
|
||||||
if held_piece:
|
if held_piece:
|
||||||
held_piece.visible = true
|
held_piece.visible = true
|
||||||
next_piece.visible = true
|
next_piece.visible = true
|
||||||
@ -203,6 +203,7 @@ func pause(gui=null):
|
|||||||
$Hold.visible = false
|
$Hold.visible = false
|
||||||
$Next.visible = false
|
$Next.visible = false
|
||||||
current_piece.visible = false
|
current_piece.visible = false
|
||||||
|
$Ghost.visible = false
|
||||||
if held_piece:
|
if held_piece:
|
||||||
held_piece.visible = false
|
held_piece.visible = false
|
||||||
next_piece.visible = false
|
next_piece.visible = false
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=21 format=2]
|
[gd_scene load_steps=22 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://Environment.tres" type="Environment" id=1]
|
[ext_resource path="res://Environment.tres" type="Environment" id=1]
|
||||||
[ext_resource path="res://Main.gd" type="Script" id=2]
|
[ext_resource path="res://Main.gd" type="Script" id=2]
|
||||||
@ -14,6 +14,7 @@
|
|||||||
[ext_resource path="res://controls.tscn" type="PackedScene" id=12]
|
[ext_resource path="res://controls.tscn" type="PackedScene" id=12]
|
||||||
[ext_resource path="res://Start.tscn" type="PackedScene" id=13]
|
[ext_resource path="res://Start.tscn" type="PackedScene" id=13]
|
||||||
[ext_resource path="res://fonts/Gamer.ttf" type="DynamicFontData" id=14]
|
[ext_resource path="res://fonts/Gamer.ttf" type="DynamicFontData" id=14]
|
||||||
|
[ext_resource path="res://Tetrominos/Ghost.tscn" type="PackedScene" id=15]
|
||||||
|
|
||||||
[sub_resource type="SpatialMaterial" id=1]
|
[sub_resource type="SpatialMaterial" id=1]
|
||||||
|
|
||||||
@ -146,14 +147,14 @@ extra_spacing_bottom = 5
|
|||||||
font_data = ExtResource( 14 )
|
font_data = ExtResource( 14 )
|
||||||
_sections_unfolded = [ "Extra Spacing", "Font", "Settings" ]
|
_sections_unfolded = [ "Extra Spacing", "Font", "Settings" ]
|
||||||
|
|
||||||
[node name="Main" type="WorldEnvironment" index="0"]
|
[node name="Main" type="WorldEnvironment"]
|
||||||
|
|
||||||
environment = ExtResource( 1 )
|
environment = ExtResource( 1 )
|
||||||
script = ExtResource( 2 )
|
script = ExtResource( 2 )
|
||||||
|
|
||||||
[node name="Background" type="Sprite3D" parent="." index="0"]
|
[node name="Background" type="Sprite3D" parent="." index="0"]
|
||||||
|
|
||||||
transform = Transform( 12.8, 0, 0, 0, 8.53, 0, 0, 0, 1, 4.5, 29, -34 )
|
transform = Transform( 12.8, 0, 0, 0, 8.53, 0, 0, 0, 1, 4.5, 28.8, -34 )
|
||||||
layers = 1
|
layers = 1
|
||||||
material_override = null
|
material_override = null
|
||||||
cast_shadow = 1
|
cast_shadow = 1
|
||||||
@ -627,6 +628,10 @@ flat = false
|
|||||||
align = 1
|
align = 1
|
||||||
_sections_unfolded = [ "Margin", "custom_colors", "custom_fonts" ]
|
_sections_unfolded = [ "Margin", "custom_colors", "custom_fonts" ]
|
||||||
|
|
||||||
|
[node name="Ghost" parent="." index="16" instance=ExtResource( 15 )]
|
||||||
|
|
||||||
|
visible = false
|
||||||
|
|
||||||
[connection signal="timeout" from="Matrix/DropTrail/Delay" to="." method="_on_DropTrailDelay_timeout"]
|
[connection signal="timeout" from="Matrix/DropTrail/Delay" to="." method="_on_DropTrailDelay_timeout"]
|
||||||
|
|
||||||
[connection signal="timeout" from="DropTimer" to="." method="_on_DropTimer_timeout"]
|
[connection signal="timeout" from="DropTimer" to="." method="_on_DropTimer_timeout"]
|
||||||
|
247
source/Tetrominos/Ghost.tscn
Normal file
247
source/Tetrominos/Ghost.tscn
Normal file
@ -0,0 +1,247 @@
|
|||||||
|
[gd_scene load_steps=4 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Tetrominos/TetroI.gd" type="Script" id=1]
|
||||||
|
|
||||||
|
[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.259529 )
|
||||||
|
metallic = 1.0
|
||||||
|
metallic_specular = 0.63
|
||||||
|
metallic_texture_channel = 4
|
||||||
|
roughness = 0.46
|
||||||
|
roughness_texture_channel = 0
|
||||||
|
emission_enabled = true
|
||||||
|
emission = Color( 0.446159, 0.591797, 0.540939, 1 )
|
||||||
|
emission_energy = 0.15
|
||||||
|
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 = [ "Albedo", "Emission", "Metallic", "NormalMap", "Proximity Fade" ]
|
||||||
|
|
||||||
|
[sub_resource type="CubeMesh" id=2]
|
||||||
|
|
||||||
|
material = SubResource( 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="Ghost" type="Spatial" index="0"]
|
||||||
|
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
|
[node name="Mino0" type="Spatial" parent="." index="0"]
|
||||||
|
|
||||||
|
transform = Transform( 0.997027, 0, 0, 0, 0.997027, 0, 0, 0, 0.997027, 0, 0, 0 )
|
||||||
|
_sections_unfolded = [ "Pause", "Transform", "Visibility" ]
|
||||||
|
|
||||||
|
[node name="MinoMesh" type="MeshInstance" parent="Mino0" 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
|
||||||
|
mesh = SubResource( 2 )
|
||||||
|
skeleton = NodePath("..")
|
||||||
|
material/0 = null
|
||||||
|
_sections_unfolded = [ "Geometry", "Transform", "material" ]
|
||||||
|
|
||||||
|
[node name="OmniLight" type="OmniLight" parent="Mino0" index="1"]
|
||||||
|
|
||||||
|
layers = 1
|
||||||
|
light_color = Color( 1, 1, 1, 1 )
|
||||||
|
light_energy = 16.0
|
||||||
|
light_indirect_energy = 1.0
|
||||||
|
light_negative = false
|
||||||
|
light_specular = 0.5
|
||||||
|
light_bake_mode = 1
|
||||||
|
light_cull_mask = -1
|
||||||
|
shadow_enabled = false
|
||||||
|
shadow_color = Color( 0, 0, 0, 1 )
|
||||||
|
shadow_bias = 0.15
|
||||||
|
shadow_contact = 0.0
|
||||||
|
shadow_reverse_cull_face = false
|
||||||
|
editor_only = false
|
||||||
|
omni_range = 5.0
|
||||||
|
omni_attenuation = 1.0
|
||||||
|
omni_shadow_mode = 1
|
||||||
|
omni_shadow_detail = 1
|
||||||
|
_sections_unfolded = [ "Light" ]
|
||||||
|
|
||||||
|
[node name="Mino1" type="Spatial" parent="." index="1"]
|
||||||
|
|
||||||
|
transform = Transform( 0.997027, 0, 0, 0, 0.997027, 0, 0, 0, 0.997027, 0, 0, 0 )
|
||||||
|
_sections_unfolded = [ "Pause", "Transform", "Visibility" ]
|
||||||
|
|
||||||
|
[node name="MinoMesh" type="MeshInstance" parent="Mino1" 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
|
||||||
|
mesh = SubResource( 2 )
|
||||||
|
skeleton = NodePath("..")
|
||||||
|
material/0 = null
|
||||||
|
_sections_unfolded = [ "Geometry", "Transform", "material" ]
|
||||||
|
|
||||||
|
[node name="OmniLight" type="OmniLight" parent="Mino1" index="1"]
|
||||||
|
|
||||||
|
layers = 1
|
||||||
|
light_color = Color( 1, 1, 1, 1 )
|
||||||
|
light_energy = 16.0
|
||||||
|
light_indirect_energy = 1.0
|
||||||
|
light_negative = false
|
||||||
|
light_specular = 0.5
|
||||||
|
light_bake_mode = 1
|
||||||
|
light_cull_mask = -1
|
||||||
|
shadow_enabled = false
|
||||||
|
shadow_color = Color( 0, 0, 0, 1 )
|
||||||
|
shadow_bias = 0.15
|
||||||
|
shadow_contact = 0.0
|
||||||
|
shadow_reverse_cull_face = false
|
||||||
|
editor_only = false
|
||||||
|
omni_range = 5.0
|
||||||
|
omni_attenuation = 1.0
|
||||||
|
omni_shadow_mode = 1
|
||||||
|
omni_shadow_detail = 1
|
||||||
|
_sections_unfolded = [ "Light" ]
|
||||||
|
|
||||||
|
[node name="Mino2" type="Spatial" parent="." index="2"]
|
||||||
|
|
||||||
|
transform = Transform( 0.997027, 0, 0, 0, 0.997027, 0, 0, 0, 0.997027, 0, 0, 0 )
|
||||||
|
_sections_unfolded = [ "Pause", "Transform", "Visibility" ]
|
||||||
|
|
||||||
|
[node name="MinoMesh" type="MeshInstance" parent="Mino2" 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
|
||||||
|
mesh = SubResource( 2 )
|
||||||
|
skeleton = NodePath("..")
|
||||||
|
material/0 = null
|
||||||
|
_sections_unfolded = [ "Geometry", "Transform", "material" ]
|
||||||
|
|
||||||
|
[node name="OmniLight" type="OmniLight" parent="Mino2" index="1"]
|
||||||
|
|
||||||
|
layers = 1
|
||||||
|
light_color = Color( 1, 1, 1, 1 )
|
||||||
|
light_energy = 16.0
|
||||||
|
light_indirect_energy = 1.0
|
||||||
|
light_negative = false
|
||||||
|
light_specular = 0.5
|
||||||
|
light_bake_mode = 1
|
||||||
|
light_cull_mask = -1
|
||||||
|
shadow_enabled = false
|
||||||
|
shadow_color = Color( 0, 0, 0, 1 )
|
||||||
|
shadow_bias = 0.15
|
||||||
|
shadow_contact = 0.0
|
||||||
|
shadow_reverse_cull_face = false
|
||||||
|
editor_only = false
|
||||||
|
omni_range = 5.0
|
||||||
|
omni_attenuation = 1.0
|
||||||
|
omni_shadow_mode = 1
|
||||||
|
omni_shadow_detail = 1
|
||||||
|
_sections_unfolded = [ "Light" ]
|
||||||
|
|
||||||
|
[node name="Mino3" type="Spatial" parent="." index="3"]
|
||||||
|
|
||||||
|
transform = Transform( 0.997027, 0, 0, 0, 0.997027, 0, 0, 0, 0.997027, 0, 0, 0 )
|
||||||
|
_sections_unfolded = [ "Pause", "Transform", "Visibility" ]
|
||||||
|
|
||||||
|
[node name="MinoMesh" type="MeshInstance" parent="Mino3" 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
|
||||||
|
mesh = SubResource( 2 )
|
||||||
|
skeleton = NodePath("..")
|
||||||
|
material/0 = null
|
||||||
|
_sections_unfolded = [ "Geometry", "Transform", "material" ]
|
||||||
|
|
||||||
|
[node name="OmniLight" type="OmniLight" parent="Mino3" index="1"]
|
||||||
|
|
||||||
|
layers = 1
|
||||||
|
light_color = Color( 1, 1, 1, 1 )
|
||||||
|
light_energy = 16.0
|
||||||
|
light_indirect_energy = 1.0
|
||||||
|
light_negative = false
|
||||||
|
light_specular = 0.5
|
||||||
|
light_bake_mode = 1
|
||||||
|
light_cull_mask = -1
|
||||||
|
shadow_enabled = false
|
||||||
|
shadow_color = Color( 0, 0, 0, 1 )
|
||||||
|
shadow_bias = 0.15
|
||||||
|
shadow_contact = 0.0
|
||||||
|
shadow_reverse_cull_face = false
|
||||||
|
editor_only = false
|
||||||
|
omni_range = 5.0
|
||||||
|
omni_attenuation = 1.0
|
||||||
|
omni_shadow_mode = 1
|
||||||
|
omni_shadow_detail = 1
|
||||||
|
_sections_unfolded = [ "Light" ]
|
||||||
|
|
||||||
|
|
@ -79,30 +79,7 @@ mesh = ExtResource( 2 )
|
|||||||
material/0 = null
|
material/0 = null
|
||||||
_sections_unfolded = [ "Geometry", "Transform", "material" ]
|
_sections_unfolded = [ "Geometry", "Transform", "material" ]
|
||||||
|
|
||||||
[node name="SpotLight" type="SpotLight" parent="." index="1"]
|
[node name="LockingMesh" type="MeshInstance" parent="." index="1"]
|
||||||
|
|
||||||
transform = Transform( 1, 0, 0, 0, 0.0174524, 0.999848, 0, -0.999848, 0.0174524, 0, 4, 1 )
|
|
||||||
layers = 1
|
|
||||||
light_color = Color( 1, 1, 1, 1 )
|
|
||||||
light_energy = 16.0
|
|
||||||
light_indirect_energy = 1.0
|
|
||||||
light_negative = false
|
|
||||||
light_specular = 0.86
|
|
||||||
light_bake_mode = 1
|
|
||||||
light_cull_mask = -1
|
|
||||||
shadow_enabled = false
|
|
||||||
shadow_color = Color( 0, 0, 0, 1 )
|
|
||||||
shadow_bias = 0.15
|
|
||||||
shadow_contact = 0.0
|
|
||||||
shadow_reverse_cull_face = false
|
|
||||||
editor_only = false
|
|
||||||
spot_range = 30.0
|
|
||||||
spot_attenuation = 0.5
|
|
||||||
spot_angle = 5.0
|
|
||||||
spot_angle_attenuation = 2.0
|
|
||||||
_sections_unfolded = [ "Editor", "Light", "Spot", "Transform" ]
|
|
||||||
|
|
||||||
[node name="LockingMesh" type="MeshInstance" parent="." index="2"]
|
|
||||||
|
|
||||||
visible = false
|
visible = false
|
||||||
layers = 1
|
layers = 1
|
||||||
|
@ -73,17 +73,19 @@ var super_rotation_system = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
var minoes = []
|
var minoes = []
|
||||||
var grid_map
|
|
||||||
var lock_delay
|
|
||||||
var orientation = 0
|
var orientation = 0
|
||||||
var rotation_point_5_used = false
|
var rotation_point_5_used = false
|
||||||
var rotated_last = false
|
var rotated_last = false
|
||||||
|
var grid_map
|
||||||
|
var lock_delay
|
||||||
|
var ghost
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
for i in range(NB_MINOES):
|
for i in range(NB_MINOES):
|
||||||
minoes.append(get_node("Mino"+str(i)))
|
minoes.append(get_node("Mino"+str(i)))
|
||||||
grid_map = get_node("../Matrix/GridMap")
|
grid_map = get_node("../Matrix/GridMap")
|
||||||
lock_delay = get_node("../LockDelay")
|
lock_delay = get_node("../LockDelay")
|
||||||
|
ghost = get_node("../Ghost")
|
||||||
|
|
||||||
func set_translations(translations):
|
func set_translations(translations):
|
||||||
for i in range(NB_MINOES):
|
for i in range(NB_MINOES):
|
||||||
@ -100,6 +102,7 @@ func move(movement):
|
|||||||
translate(movement)
|
translate(movement)
|
||||||
unlocking()
|
unlocking()
|
||||||
rotated_last = false
|
rotated_last = false
|
||||||
|
move_ghost()
|
||||||
return true
|
return true
|
||||||
else:
|
else:
|
||||||
if movement == DROP_MOVEMENT:
|
if movement == DROP_MOVEMENT:
|
||||||
@ -125,16 +128,18 @@ func turn(direction):
|
|||||||
rotated_last = true
|
rotated_last = true
|
||||||
if i == 4:
|
if i == 4:
|
||||||
rotation_point_5_used = true
|
rotation_point_5_used = true
|
||||||
|
move_ghost()
|
||||||
return true
|
return true
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
func move_ghost():
|
||||||
|
ghost.set_translations(get_translations())
|
||||||
|
while grid_map.possible_positions(ghost.get_translations(), DROP_MOVEMENT):
|
||||||
|
ghost.translate(DROP_MOVEMENT)
|
||||||
|
|
||||||
func t_spin():
|
func t_spin():
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
func turn_light(on):
|
|
||||||
for mino in minoes:
|
|
||||||
mino.get_node("SpotLight").visible = on
|
|
||||||
|
|
||||||
func locking():
|
func locking():
|
||||||
if lock_delay.is_stopped():
|
if lock_delay.is_stopped():
|
||||||
lock_delay.start()
|
lock_delay.start()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user