Skip to content

Commit

Permalink
Create new demo scene and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
20milliliter committed Oct 17, 2023
1 parent 6c532d7 commit 80ceeb7
Show file tree
Hide file tree
Showing 5 changed files with 748 additions and 124 deletions.
6 changes: 5 additions & 1 deletion project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@ config_version=5
[application]

config/name="Same Day Shipping"
run/main_scene="res://scenes/tests/playground.tscn"
run/main_scene="res://scenes/tests/farmlands_test.tscn"
config/features=PackedStringArray("4.1", "Forward Plus")
boot_splash/bg_color=Color(0.109804, 0.109804, 0.109804, 1)
boot_splash/image="res://assets/textures/ui/iconlarge.png"
config/icon="res://assets/textures/ui/icon.png"

[autoload]

AudioDispatcher="*res://scripts/audio/AudioDispatcher.gd"

[display]

window/size/viewport_width=1280
Expand Down
4 changes: 1 addition & 3 deletions scenes/objects/player.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ collide_with_areas = true
debug_shape_custom_color = Color(1, 1, 0, 1)

[node name="CameraBone" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.5, 0)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.5, -0.4)
script = ExtResource("2_w6une")

[node name="camera" type="Camera3D" parent="CameraBone"]
Expand All @@ -48,8 +48,6 @@ target_position = Vector3(-0.5, 0, -30)
collide_with_areas = true
debug_shape_custom_color = Color(1, 0, 1, 1)

[node name="AudioStreamPlayer3D" type="AudioStreamPlayer3D" parent="."]

[node name="DEBUG_VECTORS" type="Node3D" parent="." node_paths=PackedStringArray("velocity", "friction", "wish_dir")]
unique_name_in_owner = true
script = ExtResource("3_neyp5")
Expand Down
838 changes: 728 additions & 110 deletions scenes/tests/farmlands_test.tscn

Large diffs are not rendered by default.

23 changes: 13 additions & 10 deletions scripts/game/player/player.gd
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ var jump_velocity = -gravity_vec * sqrt(-2.0 * -gravity * jump_height) #vi = sqr

@onready var DEBUG_VECTORS : DEBUG_VECTORS = $"%DEBUG_VECTORS"

signal began_slide()
signal ended_slide()
signal started_grapple()
signal ended_grapple()

var look_dir : Vector3 :
get:
return Vector3.FORWARD\
Expand Down Expand Up @@ -112,7 +107,7 @@ func _horizontal_velocity():

var STANDING_FRICTION_COEFF = 0.01
var SLIDING_FRICTION_COEFF = 1.25
var SLIDING_TIME_TO_LERP_FRICTION = 3
var SLIDING_TIME_TO_LERP_FRICTION = 2
var current_friction_coeff : float = STANDING_FRICTION_COEFF
func _friction():
var vel = self.horizontal_velocity
Expand Down Expand Up @@ -148,6 +143,11 @@ var MAX_HOOK_SPEED = 3.5 * MAX_SPEED
var MAX_HOOK_ACCEL = MAX_HOOK_SPEED / 2
func _hook():
if not is_hooked: return

if Input.is_action_just_pressed("slide"):
detach_hook()
return

var target_dir : Vector3 = self.position.direction_to(hook_target)
HOOK_SPEED = self.velocity.dot(target_dir)
if look_dir.dot(target_dir) < -0.25 \
Expand Down Expand Up @@ -177,17 +177,20 @@ func _slide():
is_sliding = false
end_slide()


self.floor_stop_on_slope = not is_sliding
# self.floor_stop_on_slope = not is_sliding

func start_slide():
current_movement_coeff = SLIDING_MOVEMENT_COEFF
current_friction_coeff = SLIDING_FRICTION_COEFF
slide_friction_tween = get_tree().create_tween().set_trans(Tween.TRANS_QUAD).set_ease(Tween.EASE_OUT)
slide_friction_tween.tween_property(self, "current_friction_coeff", STANDING_FRICTION_COEFF, SLIDING_TIME_TO_LERP_FRICTION)
detach_hook()
slide_friction_tween.tween_callback(AudioDispatcher.dispatch_3d_audio.bind(self, "sounds/player/slide/grass/end"))
AudioDispatcher.dispatch_3d_audio(self, "sounds/player/slide/grass/start")
AudioDispatcher.end("sounds/player/slide/clothgear/end", 0.25)

func end_slide():
current_movement_coeff = STANDING_MOVEMENT_COEFF
current_friction_coeff = STANDING_FRICTION_COEFF
if slide_friction_tween: slide_friction_tween.kill()
if slide_friction_tween: slide_friction_tween.kill()
AudioDispatcher.end("sounds/player/slide/grass/start", 1)
AudioDispatcher.dispatch_3d_audio(self, "sounds/player/slide/clothgear/end")
1 change: 1 addition & 0 deletions scripts/game/player/spedometer.gd
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ func _process(_delta):
self.text += "SPEED: %3.3f\n" % [player.velocity.length()]
self.text += "HOOKSPEED: %3.3f\n" % [player.HOOK_SPEED]
self.text += "FRICTION_COEFF: %3.3f\n" % [player.current_friction_coeff]
self.text += "SLIDING: %s\n" % [player.is_sliding]

0 comments on commit 80ceeb7

Please sign in to comment.