Adjusted movement and included collider collisions as a constraint to the player
This commit is contained in:
+8
-10
@@ -291,7 +291,7 @@
|
||||
[ext_resource type="Texture2D" uid="uid://ci7uer5wecm2a" path="res://art/animation/vesna/Back/B02-Walk/0048.png" id="293_ltqas"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_ssqtd"]
|
||||
radius = 200.0
|
||||
radius = 167.672
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_4yiyq"]
|
||||
animations = [{
|
||||
@@ -1191,32 +1191,30 @@ animations = [{
|
||||
}]
|
||||
|
||||
[node name="Player2d" type="Node2D"]
|
||||
y_sort_enabled = true
|
||||
|
||||
[node name="RigidBody2D" type="RigidBody2D" parent="." node_paths=PackedStringArray("_sprite")]
|
||||
[node name="CharacterBody2D" type="CharacterBody2D" parent="." node_paths=PackedStringArray("_sprite")]
|
||||
position = Vector2(0, 374)
|
||||
mass = 0.001
|
||||
gravity_scale = 0.0
|
||||
lock_rotation = true
|
||||
script = ExtResource("1_ssqtd")
|
||||
_speed = 1000.0
|
||||
_speed = 750.0
|
||||
_sprite = NodePath("visuals/Animated Sprites")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBody2D"]
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="CharacterBody2D"]
|
||||
z_index = 1
|
||||
y_sort_enabled = true
|
||||
position = Vector2(-24, -116)
|
||||
shape = SubResource("CircleShape2D_ssqtd")
|
||||
debug_color = Color(0.923708, 0.202722, 0.475262, 0.42)
|
||||
|
||||
[node name="visuals" type="Node2D" parent="RigidBody2D"]
|
||||
[node name="visuals" type="Node2D" parent="CharacterBody2D"]
|
||||
position = Vector2(0, -374)
|
||||
|
||||
[node name="Animated Sprites" type="AnimatedSprite2D" parent="RigidBody2D/visuals"]
|
||||
[node name="Animated Sprites" type="AnimatedSprite2D" parent="CharacterBody2D/visuals"]
|
||||
position = Vector2(0, 450)
|
||||
sprite_frames = SubResource("SpriteFrames_4yiyq")
|
||||
animation = &"side_walking"
|
||||
offset = Vector2(0, -450)
|
||||
|
||||
[node name="Camera2D" type="Camera2D" parent="RigidBody2D"]
|
||||
[node name="Camera2D" type="Camera2D" parent="CharacterBody2D"]
|
||||
position = Vector2(26, -469)
|
||||
zoom = Vector2(0.3, 0.3)
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ config_version=5
|
||||
[application]
|
||||
|
||||
config/name="Babushka"
|
||||
run/main_scene="uid://br7yq757cawts"
|
||||
run/main_scene="uid://gigb28qk8t12"
|
||||
config/features=PackedStringArray("4.4", "C#", "Forward Plus")
|
||||
config/icon="res://icon.svg"
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=37 format=3 uid="uid://gigb28qk8t12"]
|
||||
[gd_scene load_steps=42 format=3 uid="uid://gigb28qk8t12"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://c25udixd5m6l0" path="res://prefabs/Player2D.tscn" id="1_7wfwe"]
|
||||
[ext_resource type="Texture2D" uid="uid://8sr11ex30n0m" path="res://art/mockups/Kenney_Backgrounds/Samples/uncolored_hills.png" id="2_7b2ri"]
|
||||
@@ -50,7 +50,7 @@ shader_parameter/noise = SubResource("NoiseTexture2D_d53cn")
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_eryax"]
|
||||
offsets = PackedFloat32Array(0, 0.743902, 1)
|
||||
colors = PackedColorArray(0.235294, 0.243137, 0.352941, 1, 0.443137, 0.4, 0.360784, 1, 0.686275, 0.556863, 0.47451, 1)
|
||||
colors = PackedColorArray(0.315758, 0.221537, 0.271709, 1, 0.443137, 0.4, 0.360784, 1, 0.686275, 0.556863, 0.47451, 1)
|
||||
|
||||
[sub_resource type="FastNoiseLite" id="FastNoiseLite_wgikv"]
|
||||
|
||||
@@ -64,17 +64,29 @@ resource_local_to_scene = true
|
||||
shader = ExtResource("13_kt1wx")
|
||||
shader_parameter/tiling_scale = Vector2(25, 1)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_2vojv"]
|
||||
size = Vector2(722.933, 456)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_vbdb2"]
|
||||
size = Vector2(727.467, 216)
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_ualyd"]
|
||||
shader = ExtResource("13_kt1wx")
|
||||
shader_parameter/tiling_scale = Vector2(10, 1)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_0qu0h"]
|
||||
size = Vector2(374, 295.995)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_klb81"]
|
||||
size = Vector2(353, 296)
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_lhtpe"]
|
||||
shader = ExtResource("13_7p0hq")
|
||||
shader_parameter/hue_shift = 0.0
|
||||
shader_parameter/saturation_mult = 0.83
|
||||
shader_parameter/saturation_mult = 1.0
|
||||
shader_parameter/value_mult = 1.068
|
||||
shader_parameter/brightness_add = 0.0
|
||||
shader_parameter/contrast_mult = 0.738
|
||||
shader_parameter/contrast_mult = 0.913
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_2vojv"]
|
||||
shader = ExtResource("13_7p0hq")
|
||||
@@ -84,13 +96,10 @@ shader_parameter/value_mult = 1.0
|
||||
shader_parameter/brightness_add = 0.0
|
||||
shader_parameter/contrast_mult = 1.398
|
||||
|
||||
[node name="BabushkaSceneFarmOutside2d" type="Node2D"]
|
||||
y_sort_enabled = true
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_0sfl7"]
|
||||
size = Vector2(728, 368)
|
||||
|
||||
[node name="Player2d" parent="." instance=ExtResource("1_7wfwe")]
|
||||
z_index = 1
|
||||
y_sort_enabled = true
|
||||
position = Vector2(1064, 2128)
|
||||
[node name="BabushkaSceneFarmOutside2d" type="Node2D"]
|
||||
|
||||
[node name="ParallaxBackground" type="ParallaxBackground" parent="."]
|
||||
|
||||
@@ -539,6 +548,12 @@ position = Vector2(5032, 1680)
|
||||
scale = Vector2(30, 1)
|
||||
texture = ExtResource("20_if5vh")
|
||||
|
||||
[node name="StaticBody2D" type="StaticBody2D" parent="Fence/Fence"]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Fence/Fence/StaticBody2D"]
|
||||
position = Vector2(0.666672, 76)
|
||||
shape = SubResource("RectangleShape2D_2vojv")
|
||||
|
||||
[node name="Fence2" type="Sprite2D" parent="Fence"]
|
||||
z_index = 100
|
||||
texture_repeat = 2
|
||||
@@ -547,43 +562,51 @@ position = Vector2(5040, 4056)
|
||||
scale = Vector2(30, 1)
|
||||
texture = ExtResource("20_if5vh")
|
||||
|
||||
[node name="StaticBody2D" type="StaticBody2D" parent="Fence/Fence2"]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Fence/Fence2/StaticBody2D"]
|
||||
position = Vector2(0.266632, 172)
|
||||
shape = SubResource("RectangleShape2D_vbdb2")
|
||||
|
||||
[node name="EndLeft" type="Sprite2D" parent="Fence"]
|
||||
texture_repeat = 2
|
||||
material = SubResource("ShaderMaterial_ualyd")
|
||||
position = Vector2(-5704, 4624)
|
||||
position = Vector2(-5816, 2880)
|
||||
rotation = 1.5708
|
||||
scale = Vector2(8, 1)
|
||||
skew = 1.0472
|
||||
scale = Vector2(3.25, 1)
|
||||
skew = 1.309
|
||||
texture = ExtResource("21_if5vh")
|
||||
|
||||
[node name="EndLeft2" type="Sprite2D" parent="Fence"]
|
||||
[node name="EndRight" type="Sprite2D" parent="Fence"]
|
||||
texture_repeat = 2
|
||||
material = SubResource("ShaderMaterial_ualyd")
|
||||
position = Vector2(15800, 4592)
|
||||
position = Vector2(15888, 2880)
|
||||
rotation = 1.5708
|
||||
scale = Vector2(8, 1)
|
||||
skew = -1.0472
|
||||
scale = Vector2(3.2, 1)
|
||||
skew = -1.309
|
||||
texture = ExtResource("21_if5vh")
|
||||
flip_h = true
|
||||
|
||||
[node name="EndLeftCollider" type="StaticBody2D" parent="Fence"]
|
||||
position = Vector2(-5888, 4624)
|
||||
rotation = 1.5708
|
||||
scale = Vector2(8, 1)
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Fence/EndLeftCollider"]
|
||||
position = Vector2(-218, -4.00146)
|
||||
shape = SubResource("RectangleShape2D_0qu0h")
|
||||
|
||||
[node name="EndRightCollider" type="StaticBody2D" parent="Fence"]
|
||||
position = Vector2(15952, 4592)
|
||||
rotation = 1.5708
|
||||
scale = Vector2(8, 1)
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Fence/EndRightCollider"]
|
||||
position = Vector2(-206.5, 12.001)
|
||||
shape = SubResource("RectangleShape2D_klb81")
|
||||
|
||||
[node name="Farm visuals" type="Node2D" parent="."]
|
||||
|
||||
[node name="House Mockup" type="Sprite2D" parent="Farm visuals"]
|
||||
z_index = 1
|
||||
y_sort_enabled = true
|
||||
material = SubResource("ShaderMaterial_lhtpe")
|
||||
position = Vector2(5280, 1600)
|
||||
scale = Vector2(5, 5)
|
||||
texture = ExtResource("2_lhtpe")
|
||||
|
||||
[node name="Brünnen" type="Sprite2D" parent="Farm visuals"]
|
||||
z_index = 1
|
||||
y_sort_enabled = true
|
||||
material = SubResource("ShaderMaterial_2vojv")
|
||||
position = Vector2(9376, 3296)
|
||||
texture = ExtResource("21_ualyd")
|
||||
offset = Vector2(0, -800)
|
||||
|
||||
[node name="feld" type="Sprite2D" parent="Farm visuals"]
|
||||
position = Vector2(11136, 2592)
|
||||
texture = ExtResource("23_0sfl7")
|
||||
@@ -615,3 +638,37 @@ texture = ExtResource("24_2vojv")
|
||||
[node name="TrockeneFarmingErde4" type="Sprite2D" parent="Farm visuals"]
|
||||
position = Vector2(14384, 2568)
|
||||
texture = ExtResource("24_2vojv")
|
||||
|
||||
[node name="House Mockup" type="Sprite2D" parent="Farm visuals"]
|
||||
material = SubResource("ShaderMaterial_lhtpe")
|
||||
position = Vector2(5280, 1600)
|
||||
scale = Vector2(5, 5)
|
||||
texture = ExtResource("2_lhtpe")
|
||||
|
||||
[node name="StaticBody2D" type="StaticBody2D" parent="Farm visuals/House Mockup"]
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Farm visuals/House Mockup/StaticBody2D"]
|
||||
position = Vector2(-257.6, 236.8)
|
||||
polygon = PackedVector2Array(232, -4.80005, 0, 0, 0, -96, -262.4, -97.6, -265.6, -260.8, -310.4, -260.8, -235.2, -321.6, -124.8, -323.2, -57.6, -424, 84.8, -436.8, 118.4, -452.8, 136, -436.8, 726.4, -452.8, 817.6, -299.2, 785.6, -291.2, 785.6, -108.8, 241.6, -94.4)
|
||||
|
||||
[node name="YSorted" type="Node2D" parent="."]
|
||||
z_index = 1
|
||||
y_sort_enabled = true
|
||||
|
||||
[node name="Player2d" parent="YSorted" instance=ExtResource("1_7wfwe")]
|
||||
z_index = 1
|
||||
position = Vector2(1064, 2128)
|
||||
|
||||
[node name="Brünnen" type="Sprite2D" parent="YSorted"]
|
||||
z_index = 1
|
||||
y_sort_enabled = true
|
||||
material = SubResource("ShaderMaterial_2vojv")
|
||||
position = Vector2(9376, 3296)
|
||||
texture = ExtResource("21_ualyd")
|
||||
offset = Vector2(0, -800)
|
||||
|
||||
[node name="StaticBody2D" type="StaticBody2D" parent="YSorted/Brünnen"]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="YSorted/Brünnen/StaticBody2D"]
|
||||
position = Vector2(116, -224)
|
||||
shape = SubResource("RectangleShape2D_0sfl7")
|
||||
|
||||
@@ -2,7 +2,7 @@ using Godot;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Common.CharacterControls;
|
||||
|
||||
public partial class Player2D : Node2D
|
||||
public partial class Player2D : CharacterBody2D
|
||||
{
|
||||
[Export] private float _speed = 100f;
|
||||
[Export] private AnimatedSprite2D _sprite;
|
||||
@@ -15,7 +15,8 @@ public partial class Player2D : Node2D
|
||||
|
||||
if (Input.IsActionPressed("move_right"))
|
||||
{
|
||||
Position = new Vector2(Position.X + (_speed * (float)delta), Position.Y);
|
||||
Velocity = new Vector2(_speed, 0);
|
||||
MoveAndSlide();
|
||||
_sprite.FlipH = false;
|
||||
_sprite.Animation = "side_walking";
|
||||
anyActionPressed = true;
|
||||
@@ -23,7 +24,8 @@ public partial class Player2D : Node2D
|
||||
|
||||
if (Input.IsActionPressed("move_left"))
|
||||
{
|
||||
Position = new Vector2(Position.X - (_speed * (float)delta), Position.Y);
|
||||
Velocity = new Vector2(-_speed, 0);
|
||||
MoveAndSlide();
|
||||
_sprite.FlipH = true;
|
||||
_sprite.Animation = "side_walking";
|
||||
anyActionPressed = true;
|
||||
@@ -31,14 +33,16 @@ public partial class Player2D : Node2D
|
||||
|
||||
if (Input.IsActionPressed("move_up"))
|
||||
{
|
||||
Position = new Vector2(Position.X, Position.Y - (_speed * (float)delta));
|
||||
Velocity = new Vector2(0, -_speed);
|
||||
MoveAndSlide();
|
||||
_sprite.Animation = "back walking";
|
||||
anyActionPressed = true;
|
||||
}
|
||||
|
||||
if (Input.IsActionPressed("move_down"))
|
||||
{
|
||||
Position = new Vector2(Position.X, Position.Y + (_speed * (float)delta));
|
||||
Velocity = new Vector2(0, _speed);
|
||||
MoveAndSlide();
|
||||
_sprite.Animation = "front walking";
|
||||
anyActionPressed = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user