-feat: include rotational velocity in flight assist (now more newtonian). -fix: lasers actually despawn when they hit the border
This commit is contained in:
parent
cf500dc06e
commit
fbca225784
|
|
@ -10,7 +10,7 @@ height = 56.0
|
||||||
[node name="Laser" type="Area2D"]
|
[node name="Laser" type="Area2D"]
|
||||||
scale = Vector2(0.6, 0.6)
|
scale = Vector2(0.6, 0.6)
|
||||||
collision_layer = 8
|
collision_layer = 8
|
||||||
collision_mask = 5
|
collision_mask = 13
|
||||||
script = ExtResource("1_ctmji")
|
script = ExtResource("1_ctmji")
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
|
|
|
||||||
|
|
@ -17,15 +17,27 @@ public partial class player : ship // Inherits from base ship class
|
||||||
[Export]
|
[Export]
|
||||||
public float FlightAssistValue { get; set; } = 2.5f;
|
public float FlightAssistValue { get; set; } = 2.5f;
|
||||||
|
|
||||||
|
private float _angularVelocity;
|
||||||
|
private float _angularAccel = 0.3f;
|
||||||
|
|
||||||
|
|
||||||
private void GetInput()
|
private void GetInput()
|
||||||
{
|
{
|
||||||
/*LookAt(GetGlobalMousePosition()); //used for mouse-based rotation and movement
|
/*LookAt(GetGlobalMousePosition()); //used for mouse-based rotation and movement
|
||||||
Velocity = Transform.X * Input.GetAxis("down", "up") * Speed;
|
Velocity = Transform.X * Input.GetAxis("down", "up") * Speed;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Movement, could probably move into its own methods instead of GetInput()
|
// Movement, could probably move into its own methods instead of GetInput()
|
||||||
RotationDirection = (int)Input.GetAxis("left", "right");
|
RotationDirection = (int)Input.GetAxis("left", "right");
|
||||||
|
_angularVelocity += RotationDirection * _angularAccel;
|
||||||
|
_angularVelocity = Mathf.Clamp(_angularVelocity, -RotationSpeed, RotationSpeed);
|
||||||
|
|
||||||
|
if (RotationDirection == 0 && FlightAssistValue > 0f)
|
||||||
|
{
|
||||||
|
_angularVelocity = Mathf.MoveToward(_angularVelocity, 0f, FlightAssistValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
//GD.Print(RotationDirection);
|
||||||
Velocity += (Transform.X * Input.GetAxis("strafe_left", "strafe_right") * StrafeSpeed) + (Transform.Y * Input.GetAxis("up", "down") * MainSpeed);
|
Velocity += (Transform.X * Input.GetAxis("strafe_left", "strafe_right") * StrafeSpeed) + (Transform.Y * Input.GetAxis("up", "down") * MainSpeed);
|
||||||
Velocity = Velocity.LimitLength(MaxSpeed);
|
Velocity = Velocity.LimitLength(MaxSpeed);
|
||||||
|
|
||||||
|
|
@ -100,7 +112,7 @@ public partial class player : ship // Inherits from base ship class
|
||||||
public override void _PhysicsProcess(double delta)
|
public override void _PhysicsProcess(double delta)
|
||||||
{ // every frame
|
{ // every frame
|
||||||
GetInput();
|
GetInput();
|
||||||
Rotation += RotationDirection * RotationSpeed * (float)delta;
|
Rotation += _angularVelocity * (float)delta;
|
||||||
Velocity.LimitLength(MaxSpeed);
|
Velocity.LimitLength(MaxSpeed);
|
||||||
|
|
||||||
//GD.Print(MainSpeed);
|
//GD.Print(MainSpeed);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue