Skip to content

Commit

Permalink
feat/mid-air-dash (#61)
Browse files Browse the repository at this point in the history
* Made custom icon for game

* Implemented a portal text animation

* Implementing a mid-air dash

* Dash resets of floor hit

* Toggling Mid-Air Dash on Pause

* Made mid-air dash shorter; Added variables to easily play with dash parameters

* Adjusted portal label animations

Co-authored-by: Telmo Valverde <[email protected]>
  • Loading branch information
telmotrooper and telmotrooper authored May 27, 2022
1 parent b1e74c0 commit fa91551
Show file tree
Hide file tree
Showing 9 changed files with 171 additions and 14 deletions.
3 changes: 3 additions & 0 deletions autoload/configuration.gd
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ func _ready():

if not config.has_section_key("graphics", "grass_amount"):
config.set_value("graphics", "grass_amount", 0)

if not config.has_section_key("debug", "mid_air_dash"):
config.set_value("debug", "mid_air_dash", false)

# Handle fullscreen
if config.get_value("graphics", "fullscreen") == true:
Expand Down
4 changes: 4 additions & 0 deletions autoload/game_state.gd
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ var MapName: String
var UserInterface: Control
var RetryCamera: Camera # Camera to be used when player dies.

var upgrades = {
"mid_air_dash": false
}

# This variable is used to work around a bug in Scatter on which,
# after "test_map" is reloaded, the modifiers are not re-inserted
# and we end up without any grass.
Expand Down
22 changes: 22 additions & 0 deletions entities/player/player.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,17 @@ export var speed := 14.0
export var jump_impulse := 25.0
export var fall_acceleration := 75.0
export var bounce_impulse := 16.0
export var dash_duration := 0.2
export var dash_speed := 150

var velocity = Vector3.ZERO

var dash_available := true
var is_dashing := false

func _ready():
GameState.Player = self
$DashDurationTimer.wait_time = dash_duration

func _physics_process(delta):
if not $AnimationPlayer.is_playing():
Expand Down Expand Up @@ -52,6 +58,19 @@ func _physics_process(delta):
speed = 14
$AnimationPlayer.playback_speed = 1.0

if GameState.upgrades["mid_air_dash"]:
if is_on_floor():
dash_available = true

if dash_available and !is_on_floor() and Input.is_action_just_pressed("ui_sprint"):
if $DashDurationTimer.is_stopped():
is_dashing = true
dash_available = false
$DashDurationTimer.start()

if is_dashing:
speed = dash_speed

velocity.x = direction.x * speed
velocity.z = direction.z * speed

Expand Down Expand Up @@ -101,3 +120,6 @@ func _on_EnemyDetector_body_entered(_body):

func set_draw_distance(value: int):
$CameraPivot/Horizontal/Vertical/ClippedCamera.far = value

func _on_DashDurationTimer_timeout():
is_dashing = false
25 changes: 23 additions & 2 deletions entities/player/player.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=11 format=2]
[gd_scene load_steps=12 format=2]

[ext_resource path="res://entities/player/player.glb" type="PackedScene" id=1]
[ext_resource path="res://entities/player/player.gd" type="Script" id=2]
Expand All @@ -10,6 +10,21 @@ height = 0.25
[sub_resource type="CylinderShape" id=2]
radius = 1.4

[sub_resource type="Animation" id=8]
length = 0.001
tracks/0/type = "value"
tracks/0/path = NodePath(".:translation")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 0,
"values": [ Vector3( 0, 0, 0 ) ]
}

[sub_resource type="Animation" id=3]
resource_name = "float"
loop = true
Expand Down Expand Up @@ -93,7 +108,7 @@ script = ExtResource( 2 )
[node name="Pivot" type="Spatial" parent="."]

[node name="Character" parent="Pivot" instance=ExtResource( 1 )]
transform = Transform( 0.999737, 0.00211386, 0.0228296, -0.00598565, 0.985271, 0.17089, -0.0221321, -0.170982, 0.985025, 0.0239411, 0.734308, -0.00194665 )
transform = Transform( 0.999737, 0.00211385, 0.0228296, -0.00598565, 0.985271, 0.17089, -0.0221321, -0.170982, 0.985025, 0.0239411, 0.734308, -0.00194665 )

[node name="CollisionShape" type="CollisionShape" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1.425, 0, 0.785568, 0.44 )
Expand All @@ -111,6 +126,7 @@ shape = SubResource( 2 )

[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
autoplay = "float"
anims/RESET = SubResource( 8 )
anims/float = SubResource( 3 )
anims/spin-y = SubResource( 4 )

Expand Down Expand Up @@ -139,4 +155,9 @@ monitorable = false
transform = Transform( 2, 0, 0, 0, 0.25, 0, 0, 0, 2, 0, 0.8, 0 )
shape = SubResource( 5 )

[node name="DashDurationTimer" type="Timer" parent="."]
wait_time = 0.2
one_shot = true

[connection signal="body_entered" from="EnemyDetector" to="." method="_on_EnemyDetector_body_entered"]
[connection signal="timeout" from="DashDurationTimer" to="." method="_on_DashDurationTimer_timeout"]
Binary file modified icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions props/portal/portal_placeholder.gd
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ func _ready():
$Label3D.text = map_name

func _on_Portal_entered(_body):
$AnimationPlayer.play("shrink")
#$AudioStreamPlayer.play()
GameState.Player.get_node("EffectsAnimationPlayer").play("shrink")
GameState.change_map(map_name)
81 changes: 79 additions & 2 deletions props/portal/portal_placeholder.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=5 format=2]
[gd_scene load_steps=8 format=2]

[ext_resource path="res://props/portal/portal_placeholder.gd" type="Script" id=1]
[ext_resource path="res://fonts/montserrat_extra_bold_48.tres" type="DynamicFont" id=2]
Expand All @@ -9,6 +9,77 @@ albedo_color = Color( 0.639216, 0.141176, 0.141176, 1 )
[sub_resource type="CylinderShape" id=20]
height = 1.0

[sub_resource type="Animation" id=21]
length = 0.001
tracks/0/type = "value"
tracks/0/path = NodePath("Label3D:scale")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 0,
"values": [ Vector3( 1, 1, 1 ) ]
}
tracks/1/type = "value"
tracks/1/path = NodePath("Label3D:translation")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 0,
"values": [ Vector3( 0, 6, 0 ) ]
}

[sub_resource type="Animation" id=22]
resource_name = "shrink"
tracks/0/type = "value"
tracks/0/path = NodePath("Label3D:scale")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 1 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ Vector3( 1, 1, 1 ), Vector3( 0, 0, 0 ) ]
}
tracks/1/type = "value"
tracks/1/path = NodePath("Label3D:translation")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 0, 1 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ Vector3( 0, 6, 0 ), Vector3( 0, 4, 0 ) ]
}

[sub_resource type="Animation" id=23]
resource_name = "up_and_down"
length = 4.0
loop = true
tracks/0/type = "value"
tracks/0/path = NodePath("Label3D:translation")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 1, 2, 3, 4 ),
"transitions": PoolRealArray( 1, 1, 1, 1, 1 ),
"update": 0,
"values": [ Vector3( 0, 6, 0 ), Vector3( 0, 6.2, 0 ), Vector3( 0, 6, 0 ), Vector3( 0, 5.8, 0 ), Vector3( 0, 6, 0 ) ]
}

[node name="PortalPlaceholder" type="CSGCylinder"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0670445, 0, -135.074 )
radius = 3.0
Expand All @@ -29,10 +100,16 @@ shape = SubResource( 20 )
bus = "Sound"

[node name="Label3D" type="Label3D" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 6.2, 0 )
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 6, 0 )
pixel_size = 0.025
billboard = 2
text = "Portal"
font = ExtResource( 2 )

[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
autoplay = "up_and_down"
anims/RESET = SubResource( 21 )
anims/shrink = SubResource( 22 )
anims/up_and_down = SubResource( 23 )

[connection signal="body_entered" from="Area" to="." method="_on_Portal_entered"]
8 changes: 8 additions & 0 deletions ui/pause.gd
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ func _ready():
$MainPause/HBoxContainer/RightContainer/SoundVolumeLabel.text = sound_volume_text % Configuration.get_value("audio", "sound_volume")
$MainPause/HBoxContainer/RightContainer/SoundVolumeSlider.value = Configuration.get_value("audio", "sound_volume")

$MainPause/UpgradesContainer/HBoxContainer/MidAirDashCheckButton.pressed = Configuration.get_value("debug", "mid_air_dash")
GameState.upgrades["mid_air_dash"] = Configuration.get_value("debug", "mid_air_dash")

func _on_DrawDistanceSlider_value_changed(value):
Configuration.update_setting("graphics", "draw_distance", value)
$MainPause/HBoxContainer/LeftContainer/DrawDistanceLabel.text = draw_distance_text % value
Expand Down Expand Up @@ -107,3 +110,8 @@ func _on_ControlsBackButton_pressed():
func _on_ReloadMapButton_pressed():
GameState.reload_current_scene()
pause()


func _on_MidAirDashCheckButton_toggled(button_pressed: bool):
Configuration.update_setting("debug", "mid_air_dash", button_pressed)
GameState.upgrades["mid_air_dash"] = button_pressed
41 changes: 31 additions & 10 deletions ui/user_interface.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ custom_constants/separation = 10
alignment = 1

[node name="ResumeButton" type="Button" parent="Pause/MainPause"]
margin_top = 58.0
margin_top = 33.0
margin_right = 570.0
margin_bottom = 95.0
margin_bottom = 70.0
text = "Resume"

[node name="HBoxContainer3" type="HBoxContainer" parent="Pause/MainPause"]
margin_top = 105.0
margin_top = 80.0
margin_right = 570.0
margin_bottom = 142.0
margin_bottom = 117.0
size_flags_horizontal = 3

[node name="ToggleFullscreenButton" type="Button" parent="Pause/MainPause/HBoxContainer3"]
Expand All @@ -89,9 +89,9 @@ size_flags_horizontal = 3
text = "Controls"

[node name="HBoxContainer" type="HBoxContainer" parent="Pause/MainPause"]
margin_top = 152.0
margin_top = 127.0
margin_right = 570.0
margin_bottom = 334.0
margin_bottom = 309.0
custom_constants/separation = 10

[node name="LeftContainer" type="VBoxContainer" parent="Pause/MainPause/HBoxContainer"]
Expand Down Expand Up @@ -190,16 +190,36 @@ text = "mountain_map"
items = [ "mountain_map", null, false, 0, null, "test_map", null, false, 1, null ]
selected = 0

[node name="UpgradesContainer" type="VBoxContainer" parent="Pause/MainPause"]
margin_top = 319.0
margin_right = 570.0
margin_bottom = 359.0

[node name="HBoxContainer" type="HBoxContainer" parent="Pause/MainPause/UpgradesContainer"]
margin_right = 570.0
margin_bottom = 40.0

[node name="MidAirDashCheckButton" type="CheckButton" parent="Pause/MainPause/UpgradesContainer/HBoxContainer"]
margin_right = 76.0
margin_bottom = 40.0

[node name="MidAirDashLabel" type="Label" parent="Pause/MainPause/UpgradesContainer/HBoxContainer"]
margin_left = 80.0
margin_top = 4.0
margin_right = 238.0
margin_bottom = 35.0
text = "Mid-Air Dash"

[node name="ReloadMapButton" type="Button" parent="Pause/MainPause"]
margin_top = 344.0
margin_top = 369.0
margin_right = 570.0
margin_bottom = 381.0
margin_bottom = 406.0
text = "Reload Map"

[node name="HBoxContainer2" type="HBoxContainer" parent="Pause/MainPause"]
margin_top = 391.0
margin_top = 416.0
margin_right = 570.0
margin_bottom = 428.0
margin_bottom = 453.0
size_flags_horizontal = 3
custom_constants/separation = 10
alignment = 1
Expand Down Expand Up @@ -263,6 +283,7 @@ text = "Back"
[connection signal="value_changed" from="Pause/MainPause/HBoxContainer/RightContainer/MusicVolumeSlider" to="Pause" method="_on_MusicVolumeSlider_value_changed"]
[connection signal="value_changed" from="Pause/MainPause/HBoxContainer/RightContainer/SoundVolumeSlider" to="Pause" method="_on_SoundVolumeSlider_value_changed"]
[connection signal="item_selected" from="Pause/MainPause/HBoxContainer/RightContainer/MapOptionButton" to="Pause" method="_on_MapOptionButton_item_selected"]
[connection signal="toggled" from="Pause/MainPause/UpgradesContainer/HBoxContainer/MidAirDashCheckButton" to="Pause" method="_on_MidAirDashCheckButton_toggled"]
[connection signal="pressed" from="Pause/MainPause/ReloadMapButton" to="Pause" method="_on_ReloadMapButton_pressed"]
[connection signal="pressed" from="Pause/MainPause/HBoxContainer2/TitleScreenButton" to="Pause" method="_on_MainMenuButton_pressed"]
[connection signal="pressed" from="Pause/MainPause/HBoxContainer2/ExitButton" to="Pause" method="_on_ExitButton_pressed"]
Expand Down

0 comments on commit fa91551

Please sign in to comment.