mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 10:55:35 +00:00
40 lines
718 B
C#
40 lines
718 B
C#
using Godot;
|
|
using System;
|
|
|
|
public partial class PlayerMovement : CharacterBody2D
|
|
{
|
|
[Export]
|
|
public int Speed { get; set; } = 400;
|
|
|
|
private AnimatedSprite2D _animatedSprite;
|
|
|
|
public override void _Ready()
|
|
{
|
|
_animatedSprite = GetNode<AnimatedSprite2D>("AnimatedSprite2D");
|
|
}
|
|
|
|
/*public override _Process(float _delta)
|
|
{
|
|
if (Input.IsActionPressed("ui_right"))
|
|
{
|
|
_animatedSprite.Play("run");
|
|
}
|
|
else
|
|
{
|
|
_animatedSprite.Stop();
|
|
}
|
|
}*/
|
|
|
|
public Vector2 GetInput()
|
|
{
|
|
return Input.GetVector("left", "right", "up", "down");
|
|
}
|
|
|
|
public override void _PhysicsProcess(double delta)
|
|
{
|
|
var inputDirection = GetInput();
|
|
Velocity = inputDirection * (float)(Speed * delta);
|
|
|
|
MoveAndSlide();
|
|
}
|
|
}
|