more dialogue system stuff

This commit is contained in:
2023-02-03 13:02:49 +01:00
parent 0e3124430b
commit 2c804bb95e
9 changed files with 122 additions and 53 deletions

View File

@@ -5,7 +5,7 @@ public partial class player : CharacterBody2D
{
[Export] public string playerName;
[Export] public int speed = 200;
[Export] public int speed = 200;
public bool allowMovement = true;
public Vector2 movement;
public AnimatedSprite2D animatedSprite;
@@ -19,10 +19,10 @@ public partial class player : CharacterBody2D
dialogRayCast = GetNode<RayCast2D>("rotation_center/ray_cast_2d");
}
public override void _PhysicsProcess(double delta)
{
if(allowMovement) movement = Input.GetVector("move_left", "move_right", "move_up", "move_down");
else movement = Vector2.Zero;
if(movement.Length() != 0) rotCenter.Rotation = new Vector2((float)Math.Round(movement.X,0),(float)Math.Round(movement.Y,0)).Angle();
{
if (allowMovement) movement = Input.GetVector("move_left", "move_right", "move_up", "move_down");
else movement = Vector2.Zero;
if (movement.Length() != 0) rotCenter.Rotation = new Vector2((float)Math.Round(movement.X, 0), (float)Math.Round(movement.Y, 0)).Angle();
MoveAndCollide(movement * speed * (float)delta);
}
public override void _Process(double delta)
@@ -31,7 +31,7 @@ public partial class player : CharacterBody2D
GetNode<dialog_bubble>("dialog_bubble").GetDialog(dialogRayCast.GetCollider().Get("dialogFile").AsString());
//animation system (with controller support wich cant get normalized vector)
if(allowMovement == false)
if (allowMovement == false)
{
animatedSprite.Stop();
animatedSprite.Frame = 0;
@@ -47,14 +47,14 @@ public partial class player : CharacterBody2D
{
animatedSprite.Animation = "move_side";
animatedSprite.FlipH = movement.X < 0.5;
animatedSprite.SpeedScale = Math.Abs(movement.X * speed/150);
animatedSprite.SpeedScale = Math.Abs(movement.X * speed / 150);
}
else if (Math.Round(movement.Y, 0) != 0)
{
if (movement.Y > 0.05) animatedSprite.Animation = "move_down";
if (movement.Y < 0.05) animatedSprite.Animation = "move_up";
animatedSprite.FlipH = false;
animatedSprite.SpeedScale = Math.Abs(movement.Y * speed/150);
animatedSprite.SpeedScale = Math.Abs(movement.Y * speed / 150);
}
}
}