Lock improvement
This commit is contained in:
		| @ -135,10 +135,8 @@ func _on_DropTrailDelay_timeout(): | ||||
| 	$DropTrail.visible = false | ||||
|  | ||||
| func _on_DropTimer_timeout(): | ||||
| 	if not current_piece.move(movements["soft_drop"]): | ||||
| 		if $LockDelay.is_stopped(): | ||||
| 			lock() | ||||
| 		 | ||||
| 	current_piece.move(movements["soft_drop"]) | ||||
|  | ||||
| func lock(): | ||||
| 	if $Matrix/GridMap.lock(current_piece): | ||||
| 		var t_spin = current_piece.t_spin() | ||||
| @ -168,7 +166,6 @@ func hold(): | ||||
| func resume(): | ||||
| 	playing = true | ||||
| 	$DropTimer.start() | ||||
| 	$LockDelay.start() | ||||
| 	$Stats.time = OS.get_system_time_secs() - $Stats.time | ||||
| 	$Stats/Clock.start() | ||||
| 	$MidiPlayer.resume() | ||||
| @ -206,7 +203,6 @@ func pause(gui=null): | ||||
|  | ||||
| func game_over(): | ||||
| 	pause() | ||||
| 	current_piece.emit_trail(false) | ||||
| 	$FlashText.print("GAME\nOVER") | ||||
| 	$ReplayButton.visible = true | ||||
|  | ||||
|  | ||||
| @ -146,7 +146,7 @@ extra_spacing_bottom = 5 | ||||
| font_data = ExtResource( 13 ) | ||||
| _sections_unfolded = [ "Extra Spacing", "Font", "Settings" ] | ||||
|  | ||||
| [node name="Main" type="WorldEnvironment"] | ||||
| [node name="Main" type="WorldEnvironment" index="0"] | ||||
|  | ||||
| environment = ExtResource( 1 ) | ||||
| script = ExtResource( 2 ) | ||||
| @ -627,6 +627,8 @@ autostart = false | ||||
|  | ||||
| [connection signal="timeout" from="DropTimer" to="." method="_on_DropTimer_timeout"] | ||||
|  | ||||
| [connection signal="timeout" from="LockDelay" to="." method="lock"] | ||||
|  | ||||
| [connection signal="timeout" from="AutoShiftDelay" to="." method="_on_AutoShiftDelay_timeout"] | ||||
|  | ||||
| [connection signal="timeout" from="AutoShiftTimer" to="." method="_on_AutoShiftTimer_timeout"] | ||||
|  | ||||
| @ -1,9 +1,74 @@ | ||||
| [gd_scene load_steps=3 format=2] | ||||
| [gd_scene load_steps=5 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] | ||||
|  | ||||
| [node name="Mino" type="Spatial" index="0"] | ||||
| [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 | ||||
|  | ||||
| [sub_resource type="SpatialMaterial" id=2] | ||||
|  | ||||
| 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.755859, 1, 0.914169, 1 ) | ||||
| emission_energy = 1.0 | ||||
| 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" ] | ||||
|  | ||||
| [node name="Mino" type="Spatial"] | ||||
|  | ||||
| transform = Transform( 0.997027, 0, 0, 0, 0.997027, 0, 0, 0, 0.997027, 0, 0, 0 ) | ||||
| _sections_unfolded = [ "Pause", "Transform", "Visibility" ] | ||||
| @ -37,4 +102,21 @@ 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 | ||||
| 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 = SubResource( 2 ) | ||||
| _sections_unfolded = [ "Transform", "material" ] | ||||
|  | ||||
|  | ||||
|  | ||||
| @ -3,6 +3,7 @@ extends Spatial | ||||
| const NB_MINOES = 4 | ||||
| const CLOCKWISE = -1 | ||||
| const COUNTERCLOCKWISE = 1 | ||||
| const DROP_MOVEMENT = Vector3(0, -1, 0) | ||||
|  | ||||
| var super_rotation_system = [ | ||||
|     { | ||||
| @ -97,10 +98,16 @@ func get_translations(): | ||||
| func move(movement): | ||||
| 	if grid_map.possible_positions(get_translations(), movement): | ||||
| 		translate(movement) | ||||
| 		lock_delay.start() | ||||
| 		if movement == DROP_MOVEMENT: | ||||
| 			locking(false) | ||||
| 			lock_delay.stop() | ||||
| 		rotated_last = false | ||||
| 		return true | ||||
| 	return false | ||||
| 	else: | ||||
| 		if movement == DROP_MOVEMENT: | ||||
| 			locking(true) | ||||
| 			lock_delay.start() | ||||
| 		return false | ||||
| 	 | ||||
| func turn(direction): | ||||
| 	var translations = get_translations() | ||||
| @ -117,7 +124,8 @@ func turn(direction): | ||||
| 			orientation = (orientation - direction) % NB_MINOES | ||||
| 			set_translations(rotated_translations) | ||||
| 			translate(movements[i]) | ||||
| 			lock_delay.start() | ||||
| 			lock_delay.stop() | ||||
| 			locking(false) | ||||
| 			rotated_last = true | ||||
| 			if i == 4: | ||||
| 				rotation_point_5_used = true | ||||
| @ -131,3 +139,6 @@ func turn_light(on): | ||||
| 	for mino in minoes: | ||||
| 		mino.get_node("SpotLight").visible = on | ||||
| 		 | ||||
| func locking(visible): | ||||
| 	for mino in minoes: | ||||
| 		mino.get_node("LockingMesh").visible = visible | ||||
|  | ||||
		Reference in New Issue
	
	Block a user