@@ -0,0 +1,8 @@ | |||
[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 ) |
@@ -1,16 +1,10 @@ | |||
[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/Colors/GooGradient.tres" type="Texture" id=2] | |||
[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] | |||
_data = [ Vector2( 0, 1 ), 0.0, 0.219234, 0, 0, Vector2( 1, 0.559091 ), -0.228985, 0.0, 0, 0 ] | |||
@@ -33,9 +27,12 @@ damping = 12.0 | |||
damping_random = 0.41 | |||
scale = 4.0 | |||
scale_curve = SubResource( 5 ) | |||
color_ramp = SubResource( 3 ) | |||
color_ramp = ExtResource( 2 ) | |||
[node name="Player" type="RigidBody2D"] | |||
collision_mask = 3 | |||
contacts_reported = 1 | |||
contact_monitor = true | |||
script = ExtResource( 1 ) | |||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] | |||
@@ -44,3 +41,13 @@ shape = SubResource( 1 ) | |||
[node name="Particles" type="Particles2D" parent="."] | |||
amount = 100 | |||
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"] |
@@ -12,6 +12,8 @@ extents = Vector2( 32, 32 ) | |||
[node name="StaticBody2D" type="StaticBody2D" parent="Ground"] | |||
position = Vector2( 60.061, 218.684 ) | |||
collision_layer = 2 | |||
collision_mask = 5 | |||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Ground/StaticBody2D"] | |||
shape = SubResource( 1 ) | |||
@@ -22,6 +24,8 @@ texture = ExtResource( 1 ) | |||
[node name="StaticBody2D2" type="StaticBody2D" parent="Ground"] | |||
position = Vector2( 117.555, 225.357 ) | |||
collision_layer = 2 | |||
collision_mask = 5 | |||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Ground/StaticBody2D2"] | |||
shape = SubResource( 1 ) | |||
@@ -32,6 +36,8 @@ texture = ExtResource( 1 ) | |||
[node name="StaticBody2D3" type="StaticBody2D" parent="Ground"] | |||
position = Vector2( 165.809, 209.444 ) | |||
collision_layer = 2 | |||
collision_mask = 5 | |||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Ground/StaticBody2D3"] | |||
shape = SubResource( 1 ) | |||
@@ -42,6 +48,8 @@ texture = ExtResource( 1 ) | |||
[node name="StaticBody2D4" type="StaticBody2D" parent="Ground"] | |||
position = Vector2( 352.586, 167.485 ) | |||
collision_layer = 2 | |||
collision_mask = 5 | |||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Ground/StaticBody2D4"] | |||
shape = SubResource( 1 ) | |||
@@ -54,6 +62,8 @@ texture = ExtResource( 1 ) | |||
position = Vector2( 258.724, 168.376 ) | |||
rotation = -0.303533 | |||
scale = Vector2( 2.16, 0.400001 ) | |||
collision_layer = 2 | |||
collision_mask = 5 | |||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Ground/StaticBody2D5"] | |||
shape = SubResource( 1 ) |
@@ -4,6 +4,10 @@ export var max_distance = 64 | |||
export var max_tangential_accel = 32 | |||
export var max_travel_time = 2.0 | |||
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 mouse_position = Vector2.ZERO | |||
@@ -11,6 +15,9 @@ var mouse_down = false | |||
var push = false | |||
var traveling = 0; | |||
var in_air = true | |||
var air_time = 0 | |||
# Called when the node enters the scene tree for the first time. | |||
func _ready(): | |||
@@ -22,7 +29,7 @@ func _ready(): | |||
func _input(event): | |||
if event is InputEventMouseMotion: | |||
mouse_position = event.position | |||
mouse_position = get_global_mouse_position() | |||
if Input.is_action_just_pressed("ButtonA"): | |||
mouse_down = true | |||
elif Input.is_action_just_released("ButtonA"): | |||
@@ -35,20 +42,22 @@ func _physics_process(delta): | |||
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 dpercent = abs(distance / max_distance) | |||
var dpercent = distance / max_distance | |||
if push: | |||
push = false | |||
traveling = max_travel_time | |||
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: | |||
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; | |||
apply_central_impulse(Vector2(distance * delta, 0)) | |||
apply_central_impulse(v_horizontal * distance * delta) | |||
else: | |||
$Particles.process_material.tangential_accel = 0 | |||
func _process(delta): | |||
@@ -66,3 +75,21 @@ func _draw(): | |||
draw_line(v_start, v_end, c_line) | |||
draw_line(v_end, v_tipA, 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!") |
@@ -19,6 +19,12 @@ config/name="Anchored" | |||
run/main_scene="res://Data/Scenes/World.tscn" | |||
config/icon="res://icon.png" | |||
[display] | |||
window/size/width=800 | |||
window/stretch/mode="viewport" | |||
window/stretch/aspect="keep" | |||
[input] | |||
ButtonA={ |