mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 09:55:35 +00:00
initial commit
This commit is contained in:
commit
3e2b6c2c9c
42 changed files with 897 additions and 0 deletions
40
Scripts/PlayerMovement.cs
Normal file
40
Scripts/PlayerMovement.cs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
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 void GetInput()
|
||||
{
|
||||
|
||||
Vector2 inputDirection = Input.GetVector("left", "right", "up", "down");
|
||||
Velocity = inputDirection * Speed;
|
||||
}
|
||||
|
||||
public override void _PhysicsProcess(double delta)
|
||||
{
|
||||
GetInput();
|
||||
MoveAndSlide();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue