| [gd_resource type="GradientTexture" load_steps=2 format=2] | |||||
| [sub_resource type="Gradient" id=2] | |||||
| offsets = PoolRealArray( 0, 0.311111, 0.496296, 0.62963, 1 ) | |||||
| colors = PoolColorArray( 0.420845, 0.474609, 0, 1, 0.419535, 0.525651, 0, 1, 0.474609, 0.399068, 0.157585, 1, 0.418193, 0.577908, 0, 1, 0.416634, 0.638672, 0, 1 ) | |||||
| [resource] | |||||
| gradient = SubResource( 2 ) |
| [gd_scene load_steps=8 format=2] | |||||
| [gd_scene load_steps=7 format=2] | |||||
| [ext_resource path="res://Data/Scripts/Controller.gd" type="Script" id=1] | [ext_resource path="res://Data/Scripts/Controller.gd" type="Script" id=1] | ||||
| [ext_resource path="res://Data/Colors/GooGradient.tres" type="Texture" id=2] | |||||
| [sub_resource type="CircleShape2D" id=1] | [sub_resource type="CircleShape2D" id=1] | ||||
| [sub_resource type="Gradient" id=2] | |||||
| offsets = PoolRealArray( 0, 0.311111, 0.496296, 0.62963, 1 ) | |||||
| colors = PoolColorArray( 0.420845, 0.474609, 0, 1, 0.419535, 0.525651, 0, 1, 0.474609, 0.399068, 0.157585, 1, 0.418193, 0.577908, 0, 1, 0.416634, 0.638672, 0, 1 ) | |||||
| [sub_resource type="GradientTexture" id=3] | |||||
| gradient = SubResource( 2 ) | |||||
| [sub_resource type="Curve" id=4] | [sub_resource type="Curve" id=4] | ||||
| _data = [ Vector2( 0, 1 ), 0.0, 0.219234, 0, 0, Vector2( 1, 0.559091 ), -0.228985, 0.0, 0, 0 ] | _data = [ Vector2( 0, 1 ), 0.0, 0.219234, 0, 0, Vector2( 1, 0.559091 ), -0.228985, 0.0, 0, 0 ] | ||||
| damping_random = 0.41 | damping_random = 0.41 | ||||
| scale = 4.0 | scale = 4.0 | ||||
| scale_curve = SubResource( 5 ) | scale_curve = SubResource( 5 ) | ||||
| color_ramp = SubResource( 3 ) | |||||
| color_ramp = ExtResource( 2 ) | |||||
| [node name="Player" type="RigidBody2D"] | [node name="Player" type="RigidBody2D"] | ||||
| collision_mask = 3 | |||||
| contacts_reported = 1 | |||||
| contact_monitor = true | |||||
| script = ExtResource( 1 ) | script = ExtResource( 1 ) | ||||
| [node name="CollisionShape2D" type="CollisionShape2D" parent="."] | [node name="CollisionShape2D" type="CollisionShape2D" parent="."] | ||||
| [node name="Particles" type="Particles2D" parent="."] | [node name="Particles" type="Particles2D" parent="."] | ||||
| amount = 100 | amount = 100 | ||||
| process_material = SubResource( 6 ) | process_material = SubResource( 6 ) | ||||
| [node name="Joint" type="PinJoint2D" parent="."] | |||||
| bias = 0.9 | |||||
| softness = 0.1 | |||||
| [node name="Camera" type="Camera2D" parent="."] | |||||
| current = true | |||||
| smoothing_enabled = true | |||||
| [connection signal="body_entered" from="." to="." method="_on_Player_body_entered"] | |||||
| [connection signal="body_exited" from="." to="." method="_on_Player_body_exited"] |
| [node name="StaticBody2D" type="StaticBody2D" parent="Ground"] | [node name="StaticBody2D" type="StaticBody2D" parent="Ground"] | ||||
| position = Vector2( 60.061, 218.684 ) | position = Vector2( 60.061, 218.684 ) | ||||
| collision_layer = 2 | |||||
| collision_mask = 5 | |||||
| [node name="CollisionShape2D" type="CollisionShape2D" parent="Ground/StaticBody2D"] | [node name="CollisionShape2D" type="CollisionShape2D" parent="Ground/StaticBody2D"] | ||||
| shape = SubResource( 1 ) | shape = SubResource( 1 ) | ||||
| [node name="StaticBody2D2" type="StaticBody2D" parent="Ground"] | [node name="StaticBody2D2" type="StaticBody2D" parent="Ground"] | ||||
| position = Vector2( 117.555, 225.357 ) | position = Vector2( 117.555, 225.357 ) | ||||
| collision_layer = 2 | |||||
| collision_mask = 5 | |||||
| [node name="CollisionShape2D" type="CollisionShape2D" parent="Ground/StaticBody2D2"] | [node name="CollisionShape2D" type="CollisionShape2D" parent="Ground/StaticBody2D2"] | ||||
| shape = SubResource( 1 ) | shape = SubResource( 1 ) | ||||
| [node name="StaticBody2D3" type="StaticBody2D" parent="Ground"] | [node name="StaticBody2D3" type="StaticBody2D" parent="Ground"] | ||||
| position = Vector2( 165.809, 209.444 ) | position = Vector2( 165.809, 209.444 ) | ||||
| collision_layer = 2 | |||||
| collision_mask = 5 | |||||
| [node name="CollisionShape2D" type="CollisionShape2D" parent="Ground/StaticBody2D3"] | [node name="CollisionShape2D" type="CollisionShape2D" parent="Ground/StaticBody2D3"] | ||||
| shape = SubResource( 1 ) | shape = SubResource( 1 ) | ||||
| [node name="StaticBody2D4" type="StaticBody2D" parent="Ground"] | [node name="StaticBody2D4" type="StaticBody2D" parent="Ground"] | ||||
| position = Vector2( 352.586, 167.485 ) | position = Vector2( 352.586, 167.485 ) | ||||
| collision_layer = 2 | |||||
| collision_mask = 5 | |||||
| [node name="CollisionShape2D" type="CollisionShape2D" parent="Ground/StaticBody2D4"] | [node name="CollisionShape2D" type="CollisionShape2D" parent="Ground/StaticBody2D4"] | ||||
| shape = SubResource( 1 ) | shape = SubResource( 1 ) | ||||
| position = Vector2( 258.724, 168.376 ) | position = Vector2( 258.724, 168.376 ) | ||||
| rotation = -0.303533 | rotation = -0.303533 | ||||
| scale = Vector2( 2.16, 0.400001 ) | scale = Vector2( 2.16, 0.400001 ) | ||||
| collision_layer = 2 | |||||
| collision_mask = 5 | |||||
| [node name="CollisionShape2D" type="CollisionShape2D" parent="Ground/StaticBody2D5"] | [node name="CollisionShape2D" type="CollisionShape2D" parent="Ground/StaticBody2D5"] | ||||
| shape = SubResource( 1 ) | shape = SubResource( 1 ) |
| export var max_tangential_accel = 32 | export var max_tangential_accel = 32 | ||||
| export var max_travel_time = 2.0 | export var max_travel_time = 2.0 | ||||
| export var push_force = 128 | export var push_force = 128 | ||||
| export var collision_minor_speed_threshold = 16 | |||||
| export var collision_major_speed_threshold = 56 | |||||
| export var collision_timedt_threshold = 0.1 | |||||
| var body_radius = 0 | var body_radius = 0 | ||||
| var mouse_position = Vector2.ZERO | var mouse_position = Vector2.ZERO | ||||
| var push = false | var push = false | ||||
| var traveling = 0; | var traveling = 0; | ||||
| var in_air = true | |||||
| var air_time = 0 | |||||
| # Called when the node enters the scene tree for the first time. | # Called when the node enters the scene tree for the first time. | ||||
| func _ready(): | func _ready(): | ||||
| func _input(event): | func _input(event): | ||||
| if event is InputEventMouseMotion: | if event is InputEventMouseMotion: | ||||
| mouse_position = event.position | |||||
| mouse_position = get_global_mouse_position() | |||||
| if Input.is_action_just_pressed("ButtonA"): | if Input.is_action_just_pressed("ButtonA"): | ||||
| mouse_down = true | mouse_down = true | ||||
| elif Input.is_action_just_released("ButtonA"): | elif Input.is_action_just_released("ButtonA"): | ||||
| return # We don't follow the mouse or move the squiq when mouse is down. | return # We don't follow the mouse or move the squiq when mouse is down. | ||||
| var distance = clamp(mouse_position.x - position.x, -max_distance, max_distance) | var distance = clamp(mouse_position.x - position.x, -max_distance, max_distance) | ||||
| var dpercent = abs(distance / max_distance) | |||||
| var dpercent = distance / max_distance | |||||
| if push: | if push: | ||||
| push = false | push = false | ||||
| traveling = max_travel_time | traveling = max_travel_time | ||||
| var v_direction = (position - mouse_position).normalized() | var v_direction = (position - mouse_position).normalized() | ||||
| apply_central_impulse(v_direction * dpercent * push_force) | |||||
| elif traveling > 0: | |||||
| traveling -= delta | |||||
| apply_central_impulse(v_direction * abs(dpercent) * push_force) | |||||
| elif in_air: | |||||
| air_time += delta | |||||
| else: | else: | ||||
| if abs(distance) > body_radius: | if abs(distance) > body_radius: | ||||
| var v_horizontal = Physics2DServer.area_get_param(get_world_2d().get_space(), Physics2DServer.AREA_PARAM_GRAVITY_VECTOR).rotated(deg2rad(-90)) | |||||
| $Particles.process_material.tangential_accel = dpercent * max_tangential_accel; | $Particles.process_material.tangential_accel = dpercent * max_tangential_accel; | ||||
| apply_central_impulse(Vector2(distance * delta, 0)) | |||||
| apply_central_impulse(v_horizontal * distance * delta) | |||||
| else: | else: | ||||
| $Particles.process_material.tangential_accel = 0 | $Particles.process_material.tangential_accel = 0 | ||||
| func _process(delta): | func _process(delta): | ||||
| draw_line(v_start, v_end, c_line) | draw_line(v_start, v_end, c_line) | ||||
| draw_line(v_end, v_tipA, c_line) | draw_line(v_end, v_tipA, c_line) | ||||
| draw_line(v_end, v_tipB, c_line) | draw_line(v_end, v_tipB, c_line) | ||||
| func _on_Player_body_entered(body): | |||||
| in_air = false | |||||
| print(linear_velocity) | |||||
| if air_time > collision_timedt_threshold: | |||||
| var lvlen = linear_velocity.length() | |||||
| if lvlen >= collision_minor_speed_threshold and lvlen < collision_major_speed_threshold: | |||||
| print("ooOF") | |||||
| elif lvlen >= collision_major_speed_threshold: | |||||
| print("Oooooch!") | |||||
| air_time = 0 | |||||
| func _on_Player_body_exited(body): | |||||
| in_air = true | |||||
| print("I'm flying!") |
| run/main_scene="res://Data/Scenes/World.tscn" | run/main_scene="res://Data/Scenes/World.tscn" | ||||
| config/icon="res://icon.png" | config/icon="res://icon.png" | ||||
| [display] | |||||
| window/size/width=800 | |||||
| window/stretch/mode="viewport" | |||||
| window/stretch/aspect="keep" | |||||
| [input] | [input] | ||||
| ButtonA={ | ButtonA={ |