add particules when winning
This commit is contained in:
		
							parent
							
								
									efb9a4e9d9
								
							
						
					
					
						commit
						d2c1aa044f
					
				
					 5 changed files with 51 additions and 7 deletions
				
			
		| 
						 | 
					@ -12,7 +12,7 @@ func _on_GameState_state_changed(previous, current):
 | 
				
			||||||
		GameState.State.WINNING:
 | 
							GameState.State.WINNING:
 | 
				
			||||||
			print("Solved!")
 | 
								print("Solved!")
 | 
				
			||||||
			# TODO: wait for the animation to finish before game over
 | 
								# TODO: wait for the animation to finish before game over
 | 
				
			||||||
			$GameState.transition_to(GameState.State.GAME_OVER)
 | 
								#$GameState.transition_to(GameState.State.GAME_OVER)
 | 
				
			||||||
		GameState.State.GAME_OVER:
 | 
							GameState.State.GAME_OVER:
 | 
				
			||||||
			$ColorRect.visible = true
 | 
								$ColorRect.visible = true
 | 
				
			||||||
			$ColorRect.material.set_shader_param("blur_amount", blur_amount)
 | 
								$ColorRect.material.set_shader_param("blur_amount", blur_amount)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -54,3 +54,4 @@ anchor_bottom = 1.0
 | 
				
			||||||
[node name="GameState" type="Node" parent="."]
 | 
					[node name="GameState" type="Node" parent="."]
 | 
				
			||||||
script = ExtResource( 3 )
 | 
					script = ExtResource( 3 )
 | 
				
			||||||
[connection signal="state_changed" from="GameState" to="." method="_on_GameState_state_changed"]
 | 
					[connection signal="state_changed" from="GameState" to="." method="_on_GameState_state_changed"]
 | 
				
			||||||
 | 
					[connection signal="state_changed" from="GameState" to="HSplitContainer/Taquin" method="_on_GameState_state_changed"]
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,6 +1,6 @@
 | 
				
			||||||
 | 
					tool
 | 
				
			||||||
extends Node2D
 | 
					extends Node2D
 | 
				
			||||||
class_name Piece
 | 
					class_name Piece
 | 
				
			||||||
tool
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
export var size: int = 160
 | 
					export var size: int = 160
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,6 +1,6 @@
 | 
				
			||||||
 | 
					tool
 | 
				
			||||||
extends Control
 | 
					extends Control
 | 
				
			||||||
class_name Taquin
 | 
					class_name Taquin
 | 
				
			||||||
tool
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
var Piece = preload("res://src/Piece.tscn")
 | 
					var Piece = preload("res://src/Piece.tscn")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -39,6 +39,7 @@ func compute_padding(piece_size: int) -> Vector2:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func _ready() -> void:
 | 
					func _ready() -> void:
 | 
				
			||||||
	$AnimationPlayer/MockPiece.visible = false
 | 
						$AnimationPlayer/MockPiece.visible = false
 | 
				
			||||||
 | 
						$Particles2D.emitting = false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	$Background.rect_size.x = width
 | 
						$Background.rect_size.x = width
 | 
				
			||||||
	$Background.rect_size.y = height
 | 
						$Background.rect_size.y = height
 | 
				
			||||||
| 
						 | 
					@ -148,8 +149,8 @@ func move_piece(direction) -> bool:
 | 
				
			||||||
	update()
 | 
						update()
 | 
				
			||||||
	if check_solved():
 | 
						if check_solved():
 | 
				
			||||||
		var game_state = get_node("/root/Main/GameState") as GameState
 | 
							var game_state = get_node("/root/Main/GameState") as GameState
 | 
				
			||||||
		game_state.transition_to(GameState.State.WINNING)
 | 
							if game_state != null:
 | 
				
			||||||
		emit_signal("solved")
 | 
								game_state.transition_to(GameState.State.WINNING)
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	return true
 | 
						return true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -171,4 +172,9 @@ func check_solved() -> bool:
 | 
				
			||||||
		for r in range(rows):
 | 
							for r in range(rows):
 | 
				
			||||||
			if pieces[c][r].number != 1 + c + r * columns:
 | 
								if pieces[c][r].number != 1 + c + r * columns:
 | 
				
			||||||
				return false
 | 
									return false
 | 
				
			||||||
	return true
 | 
						return true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func _on_GameState_state_changed(previous, current):
 | 
				
			||||||
 | 
						match current:
 | 
				
			||||||
 | 
							GameState.State.WINNING:
 | 
				
			||||||
 | 
								$Particles2D.emitting = true
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,4 @@
 | 
				
			||||||
[gd_scene load_steps=4 format=2]
 | 
					[gd_scene load_steps=7 format=2]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[ext_resource path="res://src/Taquin.gd" type="Script" id=1]
 | 
					[ext_resource path="res://src/Taquin.gd" type="Script" id=1]
 | 
				
			||||||
[ext_resource path="res://src/Piece.tscn" type="PackedScene" id=2]
 | 
					[ext_resource path="res://src/Piece.tscn" type="PackedScene" id=2]
 | 
				
			||||||
| 
						 | 
					@ -20,6 +20,28 @@ tracks/0/keys = {
 | 
				
			||||||
"values": [ Vector2( 15, 15 ), Vector2( 175, 15 ) ]
 | 
					"values": [ Vector2( 15, 15 ), Vector2( 175, 15 ) ]
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[sub_resource type="Gradient" id=3]
 | 
				
			||||||
 | 
					colors = PoolColorArray( 1, 1, 1, 1, 1, 0.140625, 0.140625, 1 )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[sub_resource type="GradientTexture" id=4]
 | 
				
			||||||
 | 
					gradient = SubResource( 3 )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[sub_resource type="ParticlesMaterial" id=2]
 | 
				
			||||||
 | 
					emission_shape = 2
 | 
				
			||||||
 | 
					emission_box_extents = Vector3( 10, 5, 1 )
 | 
				
			||||||
 | 
					flag_disable_z = true
 | 
				
			||||||
 | 
					spread = 180.0
 | 
				
			||||||
 | 
					gravity = Vector3( 0, 10, 0 )
 | 
				
			||||||
 | 
					initial_velocity = 50.0
 | 
				
			||||||
 | 
					angular_velocity = 28.0
 | 
				
			||||||
 | 
					orbit_velocity = 0.0
 | 
				
			||||||
 | 
					orbit_velocity_random = 0.0
 | 
				
			||||||
 | 
					linear_accel = 1.0
 | 
				
			||||||
 | 
					damping = 22.0
 | 
				
			||||||
 | 
					angle = 45.0
 | 
				
			||||||
 | 
					angle_random = 1.0
 | 
				
			||||||
 | 
					color_ramp = SubResource( 4 )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[node name="Taquin" type="Control"]
 | 
					[node name="Taquin" type="Control"]
 | 
				
			||||||
rect_min_size = Vector2( 540, 540 )
 | 
					rect_min_size = Vector2( 540, 540 )
 | 
				
			||||||
script = ExtResource( 1 )
 | 
					script = ExtResource( 1 )
 | 
				
			||||||
| 
						 | 
					@ -44,3 +66,18 @@ size = 160
 | 
				
			||||||
margin_right = 160.0
 | 
					margin_right = 160.0
 | 
				
			||||||
margin_bottom = 160.0
 | 
					margin_bottom = 160.0
 | 
				
			||||||
color = Color( 0.137255, 0.976471, 0.0196078, 1 )
 | 
					color = Color( 0.137255, 0.976471, 0.0196078, 1 )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[node name="Particles2D" type="Particles2D" parent="."]
 | 
				
			||||||
 | 
					position = Vector2( 253, 262 )
 | 
				
			||||||
 | 
					rotation = -1.5708
 | 
				
			||||||
 | 
					amount = 30
 | 
				
			||||||
 | 
					lifetime = 1.6
 | 
				
			||||||
 | 
					preprocess = 0.25
 | 
				
			||||||
 | 
					speed_scale = 1.25
 | 
				
			||||||
 | 
					explosiveness = 1.0
 | 
				
			||||||
 | 
					local_coords = false
 | 
				
			||||||
 | 
					process_material = SubResource( 2 )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[node name="Timer" type="Timer" parent="."]
 | 
				
			||||||
 | 
					wait_time = 2.0
 | 
				
			||||||
 | 
					one_shot = true
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue