using Godot; using System; public partial class player : ship // Inherits from base ship class { public enum ShipColor{RED, GREEN, BLUE} [Export] public ShipColor color; public Sprite2D Sprite = new Sprite2D(); public void GetInput() { /*LookAt(GetGlobalMousePosition()); //used for mouse-based rotation and movement Velocity = Transform.X * Input.GetAxis("down", "up") * Speed; */ // Movement, could probably move into its own methods instead of GetInput() _rotationDirection = (int)Input.GetAxis("left", "right"); Velocity += (Transform.X * Input.GetAxis("strafe_left", "strafe_right") * StrafeSpeed) + (Transform.Y * Input.GetAxis("up", "down") * MainSpeed); Velocity = Velocity.LimitLength(MaxSpeed); //move into selection statement for toggling between fa off and on if(Input.GetAxis("strafe_left", "strafe_right") == 0){ Velocity = Velocity.MoveToward(Vector2.Zero, 1.5f); } else if(Input.GetAxis("down", "up") == 0){ Velocity = Velocity.MoveToward(Vector2.Zero, 1.5f); } } public override void _Ready() { Sprite = GetNode("ShipSprite"); string spritePath = ""; switch (type) { case ShipType.FIGHTER: spritePath = "res://assets/Player/Fighter/"; break; case ShipType.INTERCEPTOR: spritePath = "res://assets/Player/Interceptor/"; break; case ShipType.GUARDIAN: spritePath = "res://assets/Player/Guardian/"; break; } switch(color) { case ShipColor.RED: spritePath = spritePath + "ShipRed.png"; break; case ShipColor.GREEN: spritePath = spritePath + "ShipGreen.png"; break; case ShipColor.BLUE: spritePath = spritePath + "ShipBlue.png"; break; } GD.Print(spritePath); Sprite.Texture = GD.Load(spritePath); LaserSpawn = GetNode("LaserSpawn"); } public override void _Process(double delta) { if(Input.IsActionJustPressed("shoot")) { ShootLaser(); } } public override void _PhysicsProcess(double delta) { // every frame GetInput(); Rotation += _rotationDirection * RotationSpeed * (float)delta; Velocity.LimitLength(MaxSpeed); MoveAndSlide(); /* if (Position.Y < 0) {Position = new Vector2(Position.X, ScreenSize.Y);} if (Position.Y > ScreenSize.Y) {Position = new Vector2(Position.X, 0);} if (Position.X < 0) { Position = new Vector2(ScreenSize.X, Position.Y);} if (Position.X > ScreenSize.X) { Position = new Vector2(0, Position.Y);} */ } }