Skip to content

Commit

Permalink
Refactor movement system, add new movement types, fix virtual button …
Browse files Browse the repository at this point in the history
…issues
  • Loading branch information
Selgesel committed Mar 8, 2022
1 parent f1b8734 commit 6055aa5
Show file tree
Hide file tree
Showing 41 changed files with 702 additions and 113 deletions.
1 change: 1 addition & 0 deletions .import/.gdignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

3 changes: 3 additions & 0 deletions .import/crouch-icon.png-44778d4d61c7961fad8742c6b73bf0bc.md5
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source_md5="7db765754c8d8e6abf5dd52b1fea6314"
dest_md5="5ae458722db4ab8c3558d1ca382966e5"

Binary file not shown.
3 changes: 3 additions & 0 deletions .import/dash-icon.png-b98548bbc4f61545b9bcef5879a05bcf.md5
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source_md5="dac291539347bfff3b751e28f9d2de6d"
dest_md5="3dbd7e0c4120ea88d003c0417b21e7b2"

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
source_md5="905014702261f29c1a031d3c0e7095d5"
dest_md5="d1bf74c8fad2a9feee8d4f96e75b653a"
dest_md5="2dbd5296ba8c7a31f3f8dfb67f3c2258"

Binary file not shown.
2 changes: 1 addition & 1 deletion .import/jump-icon.png-287efcfab96b0f8f65c91ef610ba0e0f.md5
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
source_md5="d7164fcba5a20cbf2a2a49505d36eb50"
dest_md5="d15a3366e4630a9f96762eb3faeff1e9"
dest_md5="6df72873053be80be2b046251f45b810"

Binary file modified .import/jump-icon.png-287efcfab96b0f8f65c91ef610ba0e0f.stex
Binary file not shown.
3 changes: 3 additions & 0 deletions .import/sprint-icon.png-4396670f36c0acff0a2cf5c7b655fc16.md5
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source_md5="2b405ee11a3fb57d5256027c1896a36a"
dest_md5="cec589dfb0b41f5a14bdbd5dcd3718ef"

Binary file not shown.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

## 0.0.4
- Refactored movement system using state machines
- Added new movement types
- Dashing
- Allows player to slingshot themselves in the current movement direction
- Key binding: Q
- Sprinting
- Allows player to run faster
- Key binding: Shift
- Crouching
- Allows player to crouch and move slowly
- While crouching the player cannot dash or sprint
- Key binding: Ctrl

## 0.0.3
- Implemented touch screen controls
- Touchscreen mode is automatically enabled on Android and iOS devices
Expand Down
7 changes: 1 addition & 6 deletions Main.tscn
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[gd_scene load_steps=7 format=2]
[gd_scene load_steps=6 format=2]

[ext_resource path="res://player/Player.tscn" type="PackedScene" id=1]
[ext_resource path="res://ui/Debugger.tscn" type="PackedScene" id=2]

[sub_resource type="ProceduralSky" id=1]

Expand Down Expand Up @@ -57,7 +56,3 @@ depth = 4.0

[node name="Player" parent="." instance=ExtResource( 1 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 4.24706, 0, 4.67049 )

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

[node name="Debugger" parent="CanvasLayer" instance=ExtResource( 2 )]
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ For a list of changes you might want to see the [CHANGELOG.md](./CHANGELOG.md),
| `S` | `move_backwards` | Move character backwards |
| `A` | `move_left` | Move character to the left |
| `D` | `move_right` | Move character to the right |
| `Q` | `dash` | Have the character dash in their current movement direction (works both on the ground and mid-air) |
| `Shift` | `sprint` | Have the character run faster |
| `Ctrl` | `crouch` | Have the character crouch and move more slowly. While crouching the character can't jump or dash. |
| `Space` | `jump` | Have the character jump |
| `Esc` | `ui_cancel` | (Built-in) Toggle between captured and visible mouse modes |
| `Mouse Wheel Up` | `zoom_in` | Move the camera closer to the player |
Expand Down
Binary file added assets/crouch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions assets/crouch-icon.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[remap]

importer="texture"
type="StreamTexture"
path="res://.import/crouch-icon.png-44778d4d61c7961fad8742c6b73bf0bc.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/crouch-icon.png"
dest_files=[ "res://.import/crouch-icon.png-44778d4d61c7961fad8742c6b73bf0bc.stex" ]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
Binary file added assets/dash-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions assets/dash-icon.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[remap]

importer="texture"
type="StreamTexture"
path="res://.import/dash-icon.png-b98548bbc4f61545b9bcef5879a05bcf.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/dash-icon.png"
dest_files=[ "res://.import/dash-icon.png-b98548bbc4f61545b9bcef5879a05bcf.stex" ]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
1 change: 1 addition & 0 deletions assets/joystick-reticle.png.import
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=true
Expand Down
1 change: 1 addition & 0 deletions assets/jump-icon.png.import
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=true
Expand Down
Binary file added assets/sprint-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions assets/sprint-icon.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[remap]

importer="texture"
type="StreamTexture"
path="res://.import/sprint-icon.png-4396670f36c0acff0a2cf5c7b655fc16.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/sprint-icon.png"
dest_files=[ "res://.import/sprint-icon.png-4396670f36c0acff0a2cf5c7b655fc16.stex" ]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
18 changes: 17 additions & 1 deletion player/Controls.gd
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ var _move_vec: Vector2 = Vector2.ZERO
var _cam_rot: Vector2 = Vector2.ZERO
var _zoom_scale: float = 0
var _is_jumping: bool = false
var _is_sprinting: bool = false
var _is_dashing: bool = false
var _is_crouching: bool = false
var _is_capturing: bool = false
var _is_touchscreen: bool = false

Expand Down Expand Up @@ -53,12 +56,16 @@ func _process(delta):
_zoom_scale = _mobile_controls.get_zoom_scale()

# in both desktop and touch screen devices the jump flag can be determined via the jump action
# same goes for other actions
_is_jumping = Input.is_action_just_pressed("jump")
_is_sprinting = Input.is_action_pressed("sprint")
_is_dashing = Input.is_action_pressed("dash")
_is_crouching = Input.is_action_pressed("crouch")

func _input(event):
# on non-touchscreen devices toggle the mouse cursor's capture mode when the ui_cancel action is
# pressed (e.g. the Esc key)
if !_is_touchscreen && Input.is_action_just_pressed("ui_cancel"):
if Input.is_action_just_pressed("ui_cancel"):
_is_capturing = !_is_capturing

if _is_capturing:
Expand Down Expand Up @@ -88,6 +95,15 @@ func get_movement_vector():
func is_jumping():
return _is_jumping

func is_sprinting():
return _is_sprinting

func is_dashing():
return _is_dashing

func is_crouching():
return _is_crouching

func get_camera_rotation():
return _cam_rot

Expand Down
83 changes: 72 additions & 11 deletions player/Controls.tscn
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
[gd_scene load_steps=6 format=2]
[gd_scene load_steps=9 format=2]

[ext_resource path="res://player/Controls.gd" type="Script" id=1]
[ext_resource path="res://ui/VirtualThumbStick.tscn" type="PackedScene" id=2]
[ext_resource path="res://player/MobileControls.gd" type="Script" id=3]
[ext_resource path="res://ui/VirtualButton.tscn" type="PackedScene" id=4]
[ext_resource path="res://assets/jump-icon.png" type="Texture" id=5]
[ext_resource path="res://assets/dash-icon.png" type="Texture" id=6]
[ext_resource path="res://assets/sprint-icon.png" type="Texture" id=7]
[ext_resource path="res://assets/crouch-icon.png" type="Texture" id=8]

[node name="Controls" type="Node" groups=[
"controls",
]]
[node name="Controls" type="Node" groups=["controls"]]
script = ExtResource( 1 )

[node name="MobileControls" type="Control" parent="."]
visible = false
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 3 )
Expand All @@ -34,16 +34,77 @@ anchor_right = 1.0
anchor_bottom = 1.0
margin_left = -400.0
margin_top = -400.0
__meta__ = {
"_edit_use_anchors_": false
}

[node name="JumpButton" parent="MobileControls/Buttons" instance=ExtResource( 4 )]
modulate = Color( 0.6, 0.6, 0.6, 1 )
[node name="VBoxContainer" type="VBoxContainer" parent="MobileControls/Buttons"]
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
margin_left = -32.0
margin_top = -32.0
margin_right = 32.0
margin_bottom = 32.0
margin_left = -128.0
margin_top = -128.0
margin_right = 128.0
margin_bottom = 128.0
grow_horizontal = 2
grow_vertical = 2
custom_constants/separation = 32
alignment = 1
__meta__ = {
"_edit_use_anchors_": false
}

[node name="CenterContainer" type="CenterContainer" parent="MobileControls/Buttons/VBoxContainer"]
margin_right = 256.0
margin_bottom = 64.0

[node name="JumpButton2" parent="MobileControls/Buttons/VBoxContainer/CenterContainer" instance=ExtResource( 4 )]
modulate = Color( 0.6, 0.6, 0.6, 1 )
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 96.0
margin_right = 160.0
margin_bottom = 64.0
button_texture = ExtResource( 5 )
action = "jump"

[node name="HBoxContainer" type="HBoxContainer" parent="MobileControls/Buttons/VBoxContainer"]
margin_top = 96.0
margin_right = 256.0
margin_bottom = 160.0
custom_constants/separation = 128

[node name="SprintButton" parent="MobileControls/Buttons/VBoxContainer/HBoxContainer" instance=ExtResource( 4 )]
modulate = Color( 0.6, 0.6, 0.6, 1 )
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 64.0
margin_bottom = 64.0
button_texture = ExtResource( 7 )
action = "sprint"

[node name="DashButton" parent="MobileControls/Buttons/VBoxContainer/HBoxContainer" instance=ExtResource( 4 )]
modulate = Color( 0.6, 0.6, 0.6, 1 )
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 192.0
margin_right = 256.0
margin_bottom = 64.0
button_texture = ExtResource( 6 )
action = "dash"

[node name="CenterContainer2" type="CenterContainer" parent="MobileControls/Buttons/VBoxContainer"]
margin_top = 192.0
margin_right = 256.0
margin_bottom = 256.0

[node name="CrouchButton" parent="MobileControls/Buttons/VBoxContainer/CenterContainer2" instance=ExtResource( 4 )]
modulate = Color( 0.6, 0.6, 0.6, 1 )
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 96.0
margin_right = 160.0
margin_bottom = 64.0
button_texture = ExtResource( 8 )
action = "crouch"
Loading

0 comments on commit 6055aa5

Please sign in to comment.