diff --git a/MB_FYP/script/player.cs b/MB_FYP/script/player.cs new file mode 100644 index 0000000..78d3048 --- /dev/null +++ b/MB_FYP/script/player.cs @@ -0,0 +1,36 @@ +using Godot; +using System; + +public partial class player : CharacterBody2D +{ + [Export] + public Vector2 ScreenSize; + + [Export] + public int Speed { get; set; } = 10; + + [Export] + public float RotationSpeed { get; set; } = 2f; + + private int _rotationDirection; + + public void GetInput(){ + /*LookAt(GetGlobalMousePosition()); //used for mouse-based rotation and movement + Velocity = Transform.X * Input.GetAxis("down", "up") * Speed; + */ + + _rotationDirection = (int)Input.GetAxis("left", "right"); + Velocity += (Transform.Y * Input.GetAxis("strafe_left", "strafe_right") + Transform.X * Input.GetAxis("down", "up")) * Speed; + } + + public override void _Ready(){ // on init + GD.Print("afa"); + ScreenSize = GetViewportRect().Size; + } + + public override void _PhysicsProcess(double delta){ // every frame + GetInput(); + Rotation += _rotationDirection * RotationSpeed * (float)delta; + MoveAndSlide(); + } +} \ No newline at end of file