diff --git a/.gitignore b/.gitignore index bf83296..dd5ca34 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ .import/ export.cfg export_presets.cfg +addons # Imported translations (automatically generated from CSV files) *.translation diff --git a/Maps/Testing Purgatory.tscn b/Maps/Testing Purgatory.tscn index 9fe373b..d3bce56 100644 --- a/Maps/Testing Purgatory.tscn +++ b/Maps/Testing Purgatory.tscn @@ -40,4 +40,14 @@ tile_set = SubResource("TileSet_qp0ib") format = 2 layer_0/tile_data = PackedInt32Array(589824, 0, 0, 589825, 0, 0, 589826, 0, 0, 589827, 0, 0, 589828, 0, 0, 589829, 0, 0, 589830, 0, 0, 589831, 0, 0, 589832, 0, 0, 589833, 0, 0, 589834, 0, 0, 589835, 0, 0, 589836, 0, 0, 589837, 0, 0, 589838, 0, 0, 589839, 0, 0, 589840, 0, 0, 589841, 0, 0, 655359, 0, 0, 655358, 0, 0, 655357, 0, 0, 655356, 0, 0, 655355, 0, 0, 655354, 0, 0, 655353, 0, 0, 655352, 0, 0, 655351, 0, 0, 589815, 0, 0, 589816, 0, 0, 589817, 0, 0, 589818, 0, 0, 589819, 0, 0, 589820, 0, 0, 589821, 0, 0, 589822, 0, 0, 589823, 0, 0, 524288, 0, 0, 524289, 0, 0, 524299, 0, 0, 524292, 0, 0, 524291, 0, 0, 524290, 0, 0, 524298, 0, 0, 524297, 0, 0, 524296, 0, 0, 524295, 0, 0, 524293, 0, 0, 524294, 0, 0, 524300, 0, 0, 524301, 0, 0, 524302, 0, 0, 524303, 0, 0, 524304, 0, 0, 524305, 0, 0, 524306, 0, 0, 589842, 0, 0, 655350, 0, 0, 589814, 0, 0, 524278, 0, 0, 458742, 0, 0, 393206, 0, 0, 327670, 0, 0, 262134, 0, 0, 196598, 0, 0, 131062, 0, 0, 65526, 0, 0, -10, 0, 0, -65546, 0, 0, -131082, 0, 0, -196618, 0, 0, -262154, 0, 0, 655349, 0, 0, 589813, 0, 0, 524277, 0, 0, 458741, 0, 0, 393205, 0, 0, 327669, 0, 0, 262133, 0, 0, 196597, 0, 0, 131061, 0, 0, 65525, 0, 0, -11, 0, 0, -65547, 0, 0, -131083, 0, 0, -196619, 0, 0, -262155, 0, 0, 655348, 0, 0, 589812, 0, 0, 655347, 0, 0, 589811, 0, 0, 655346, 0, 0, 589810, 0, 0, 655345, 0, 0, 589809, 0, 0, 655344, 0, 0, 589808, 0, 0, 655343, 0, 0, 589807, 0, 0, 655342, 0, 0, 589806, 0, 0, 655341, 0, 0, 589805, 0, 0, 655340, 0, 0, 589804, 0, 0, 655339, 0, 0, 589803, 0, 0, 655338, 0, 0, 589802, 0, 0, 458764, 0, 0, 393228, 0, 0, 327692, 0, 0, 262156, 0, 0, 196620, 0, 0, 131084, 0, 0, 65548, 0, 0, 12, 0, 0, 458763, 0, 0, 393227, 0, 0, 327691, 0, 0, 262155, 0, 0, 196619, 0, 0, 131083, 0, 0, 65547, 0, 0, 11, 0, 0, 589852, 0, 0, 524316, 0, 0, 589851, 0, 0, 524315, 0, 0, 589850, 0, 0, 524314, 0, 0, 589849, 0, 0, 524313, 0, 0, 589848, 0, 0, 524312, 0, 0, 589847, 0, 0, 524311, 0, 0, 589846, 0, 0, 524310, 0, 0, 589845, 0, 0, 524309, 0, 0, 589844, 0, 0, 524308, 0, 0, 589843, 0, 0, 524307, 0, 0) +[node name="TileMap2" type="TileMap" parent="Map"] +modulate = Color(0, 0, 0.486275, 1) +position = Vector2(1607, 573) +rotation = 0.785398 +tile_set = SubResource("TileSet_qp0ib") +format = 2 +layer_0/tile_data = PackedInt32Array(589824, 0, 0, 589825, 0, 0, 589826, 0, 0, 589827, 0, 0, 589828, 0, 0, 589829, 0, 0, 589830, 0, 0, 589831, 0, 0, 589832, 0, 0, 589833, 0, 0, 589834, 0, 0, 589835, 0, 0, 589836, 0, 0, 589837, 0, 0, 589838, 0, 0, 589839, 0, 0, 589840, 0, 0, 589841, 0, 0, 655359, 0, 0, 655358, 0, 0, 655357, 0, 0, 655356, 0, 0, 655355, 0, 0, 655354, 0, 0, 655353, 0, 0, 655352, 0, 0, 655351, 0, 0, 589815, 0, 0, 589816, 0, 0, 589817, 0, 0, 589818, 0, 0, 589819, 0, 0, 589820, 0, 0, 589821, 0, 0, 589822, 0, 0, 589823, 0, 0, 524288, 0, 0, 524289, 0, 0, 524299, 0, 0, 524292, 0, 0, 524291, 0, 0, 524290, 0, 0, 524298, 0, 0, 524297, 0, 0, 524296, 0, 0, 524295, 0, 0, 524293, 0, 0, 524294, 0, 0, 524300, 0, 0, 524301, 0, 0, 524302, 0, 0, 524303, 0, 0, 524304, 0, 0, 524305, 0, 0, 524306, 0, 0, 589842, 0, 0, 655350, 0, 0, 589814, 0, 0, 524278, 0, 0, 458742, 0, 0, 393206, 0, 0, 327670, 0, 0, 262134, 0, 0, 196598, 0, 0, 131062, 0, 0, 65526, 0, 0, -10, 0, 0, -65546, 0, 0, -131082, 0, 0, -196618, 0, 0, -262154, 0, 0, 655349, 0, 0, 589813, 0, 0, 524277, 0, 0, 458741, 0, 0, 393205, 0, 0, 327669, 0, 0, 262133, 0, 0, 196597, 0, 0, 131061, 0, 0, 65525, 0, 0, -11, 0, 0, -65547, 0, 0, -131083, 0, 0, -196619, 0, 0, -262155, 0, 0, 655348, 0, 0, 589812, 0, 0, 655347, 0, 0, 589811, 0, 0, 655346, 0, 0, 589810, 0, 0, 655345, 0, 0, 589809, 0, 0, 655344, 0, 0, 589808, 0, 0, 655343, 0, 0, 589807, 0, 0, 655342, 0, 0, 589806, 0, 0, 655341, 0, 0, 589805, 0, 0, 655340, 0, 0, 589804, 0, 0, 655339, 0, 0, 589803, 0, 0, 655338, 0, 0, 589802, 0, 0, 458764, 0, 0, 393228, 0, 0, 327692, 0, 0, 262156, 0, 0, 196620, 0, 0, 131084, 0, 0, 65548, 0, 0, 12, 0, 0, 458763, 0, 0, 393227, 0, 0, 327691, 0, 0, 262155, 0, 0, 196619, 0, 0, 131083, 0, 0, 65547, 0, 0, 11, 0, 0, 589852, 0, 0, 524316, 0, 0, 589851, 0, 0, 524315, 0, 0, 589850, 0, 0, 524314, 0, 0, 589849, 0, 0, 524313, 0, 0, 589848, 0, 0, 524312, 0, 0, 589847, 0, 0, 524311, 0, 0, 589846, 0, 0, 524310, 0, 0, 589845, 0, 0, 524309, 0, 0, 589844, 0, 0, 524308, 0, 0, 589843, 0, 0, 524307, 0, 0) + [node name="Player" parent="." instance=ExtResource("1_jcngi")] +floor_constant_speed = true +floor_snap_length = 1.0 diff --git a/Player/BasicCharacter/AnimationController.gd b/Player/BasicCharacter/AnimationController.gd index 8273920..9fca59e 100644 --- a/Player/BasicCharacter/AnimationController.gd +++ b/Player/BasicCharacter/AnimationController.gd @@ -2,14 +2,16 @@ extends Sprite2D @onready var player = $"../" +@onready var wallSlidingParticles = $"WallslidingParticles" + func spin(veloc, delta): var vertSpinMult = abs(veloc.y) * clamp(veloc.x, -1, 1) / 1.5 - var spinFactor = (veloc.x + vertSpinMult) / 20 + var spinFactor = (veloc.x + vertSpinMult) / 30 if player.direction: rotation = lerp(rotation, rotation + (spinFactor), delta) else: - rotation = lerp(rotation, snappedf(rotation + (spinFactor * delta * 2), PI / 2), delta * 10) + rotation = lerp(rotation, snappedf(rotation, PI / 2), delta * 10) var landed = 0 @@ -18,22 +20,40 @@ func _process(delta): var floored = player.is_on_floor() - print(scale) + if player.is_on_wall_only() and velocity.y > 0: + wallSlidingParticles.emitting = true + wallSlidingParticles.global_position = player.position + (player.get_wall_normal() * -8) + wallSlidingParticles.global_rotation = player.get_wall_normal().x * deg_to_rad(45) + else: + wallSlidingParticles.emitting = false if not floored: spin(velocity, delta) landed = velocity.y scale = Vector2.ONE + + if player.is_on_wall(): + rotation = lerp(rotation, deg_to_rad(30) * player.get_wall_normal().x + snappedf(rotation, PI / 2), delta * 15) else: - rotation = 0 + var floorRot = player.get_floor_normal().angle() + (PI / 2) + + if abs(rotation - floorRot) > 0.9: + rotation = floorRot + + rotation = lerp(rotation, floorRot, delta * 10) if landed: + rotation = 0 scale.y = 1 - (landed / 800) scale.x = 1 + (landed / 800) landed = 0 - scale.y = lerp(scale.y, 1.0, delta * 10) - scale.x = lerp(scale.x, 1.0, delta * 10) - + scale.y = lerp(scale.y, 1.0, delta * 7) + scale.x = lerp(scale.x, 1.0, delta * 7) + + scale.y = clamp(scale.y, 0.1, INF) + scale.x = clamp(scale.x, 0.1, INF) + offset.y = (8 * pow(scale.y, -1) - 8) + offset.x = 0 diff --git a/Player/BasicCharacter/Character.tscn b/Player/BasicCharacter/Character.tscn index 7cdd255..ed4b993 100644 --- a/Player/BasicCharacter/Character.tscn +++ b/Player/BasicCharacter/Character.tscn @@ -1,26 +1,54 @@ -[gd_scene load_steps=6 format=3 uid="uid://cqcjan67wgkc1"] +[gd_scene load_steps=9 format=3 uid="uid://cqcjan67wgkc1"] [ext_resource type="Texture2D" uid="uid://dvx8lliqdi3dv" path="res://Player/Skins/Square/Square.png" id="1_3vfyw"] [ext_resource type="Script" path="res://Player/BasicCharacter/CharacterController.gd" id="1_c5ycp"] [ext_resource type="Script" path="res://Player/BasicCharacter/CameraController.gd" id="3_2bdku"] [ext_resource type="Script" path="res://Player/BasicCharacter/AnimationController.gd" id="3_6plye"] -[sub_resource type="RectangleShape2D" id="RectangleShape2D_42acf"] -size = Vector2(16, 16) +[sub_resource type="CircleShape2D" id="CircleShape2D_jbiem"] +radius = 8.0 + +[sub_resource type="Curve" id="Curve_ky2t4"] +_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(0.738916, 0), -1.78462, 0.0, 0, 0] +point_count = 2 + +[sub_resource type="CurveTexture" id="CurveTexture_d404m"] +curve = SubResource("Curve_ky2t4") + +[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_65t6y"] +particle_flag_align_y = true +particle_flag_disable_z = true +particle_flag_damping_as_friction = true +direction = Vector3(0, -1, 0) +initial_velocity_min = 34.78 +initial_velocity_max = 34.78 +gravity = Vector3(0, 250, 0) +scale_min = 2.0 +scale_max = 2.0 +scale_curve = SubResource("CurveTexture_d404m") [node name="Character" type="CharacterBody2D"] +floor_snap_length = 3.0 script = ExtResource("1_c5ycp") -[node name="BoxCollider" type="CollisionShape2D" parent="."] -shape = SubResource("RectangleShape2D_42acf") - [node name="Camera" type="Camera2D" parent="."] zoom = Vector2(3, 3) position_smoothing_enabled = true -position_smoothing_speed = 20.0 +position_smoothing_speed = 35.0 script = ExtResource("3_2bdku") +[node name="BoxCollider" type="CollisionShape2D" parent="."] +shape = SubResource("CircleShape2D_jbiem") + [node name="Sprite" type="Sprite2D" parent="."] self_modulate = Color(1, 0, 0, 1) +rotation = 0.0123838 texture = ExtResource("1_3vfyw") script = ExtResource("3_6plye") + +[node name="WallslidingParticles" type="GPUParticles2D" parent="Sprite"] +show_behind_parent = true +top_level = true +position = Vector2(-7.79423, 4.5) +rotation = 0.785398 +process_material = SubResource("ParticleProcessMaterial_65t6y") diff --git a/Player/BasicCharacter/CharacterController.gd b/Player/BasicCharacter/CharacterController.gd index e709e39..3232d1a 100644 --- a/Player/BasicCharacter/CharacterController.gd +++ b/Player/BasicCharacter/CharacterController.gd @@ -3,32 +3,71 @@ extends CharacterBody2D const SPEED = 400.0 const ACCEL = 7.0 -const JUMP_VELOCITY = -400.0 +const JUMP_VELOCITY = -450.0 -const FALL_SPEED = -JUMP_VELOCITY * 2 +const MAX_JUMPS = 2 +var jumps = MAX_JUMPS + +const FALL_SPEED = -JUMP_VELOCITY * 1.5 var falling = false var gravity = ProjectSettings.get_setting("physics/2d/default_gravity") -var direction = Vector2.ZERO +var direction = 0 + +var addedveloc = 0 + +var wallKayote = 0 + +func launch(veloc): + addedveloc = veloc + velocity.x = veloc func _physics_process(delta): + direction = round(Input.get_axis("left", "right")) + + wallKayote -= delta + if not is_on_floor(): var lowGrav = velocity.y < 0 and Input.is_action_pressed("jump") velocity.y += gravity * delta / gen.boolToNumb(lowGrav, 1) else: + jumps = MAX_JUMPS falling = false - - if Input.is_action_just_pressed("jump") and is_on_floor(): - velocity.y = JUMP_VELOCITY + + if is_on_wall_only() and direction: + wallKayote = 0.225 + + print(-get_wall_normal().x, direction) + + if Input.is_action_just_pressed("jump"): + if wallKayote > 0: + velocity.y = clamp(velocity.y + JUMP_VELOCITY, -INF, JUMP_VELOCITY) + launch(get_wall_normal().x * SPEED) + elif jumps > 0: + velocity.y = clamp(velocity.y + JUMP_VELOCITY, -INF, JUMP_VELOCITY) + jumps -= 1 + falling = false if Input.is_action_just_pressed("down") and not falling: falling = true - velocity.y = clamp(velocity.y + FALL_SPEED, -INF, FALL_SPEED) - - direction = round(Input.get_axis("left", "right")) + velocity.y = clamp(velocity.y + FALL_SPEED, FALL_SPEED, INF) - velocity.x = lerp(velocity.x, direction * SPEED, delta * ACCEL) + if is_on_wall_only(): + velocity.y = lerpf(velocity.y, clamp(velocity.y, JUMP_VELOCITY, 100), delta * 10) + + var finalSpeed = clamp(abs(velocity.x), SPEED, SPEED * 2) - abs(addedveloc) + + finalSpeed = clamp(lerp(finalSpeed, SPEED, delta * 10), SPEED, INF) + #print(finalSpeed) + + velocity.x = lerp(velocity.x, direction * finalSpeed, delta * ACCEL) + + #if abs(velocity.x) < abs(addedveloc): + #print("boiyoing") + velocity.x += addedveloc * delta * 10 + + addedveloc = lerpf(addedveloc, 0, delta * 5) move_and_slide() diff --git a/Player/Skins/Square/square.kra b/Player/Skins/Square/square.kra new file mode 100644 index 0000000..6264bab Binary files /dev/null and b/Player/Skins/Square/square.kra differ diff --git a/Tilemaps/BasicSquare/Texture.kra b/Tilemaps/BasicSquare/Texture.kra new file mode 100644 index 0000000..70c8cf7 Binary files /dev/null and b/Tilemaps/BasicSquare/Texture.kra differ diff --git a/project.godot b/project.godot index e58c602..e4ed4c5 100644 --- a/project.godot +++ b/project.godot @@ -13,6 +13,7 @@ config_version=5 config/name="Grapple Test" run/main_scene="res://Maps/Testing Purgatory.tscn" config/features=PackedStringArray("4.2", "Forward Plus") +run/max_fps=144 boot_splash/bg_color=Color(0, 0, 0, 1) config/icon="res://icon.svg"