export class Player {
    constructor(scene) {
        this.scene = scene;
        this.sprite = null;
        this.cursors = null;
    }

    create() {
        // Create player ship
        this.sprite = this.scene.physics.add.sprite(300, 700, 'player-sprite', 0);
        this.sprite.setCollideWorldBounds(true);
        
        // Setup controls
        this.cursors = this.scene.input.keyboard.createCursorKeys();
        
        // Replace cursor keys with A/D keys for movement
        const aKey = this.scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.A);
        const dKey = this.scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.D);
        
        return { aKey, dKey };
    }

    update(aKey, dKey) {
        // Player movement with A/D keys
        if (aKey.isDown) {
            this.sprite.setVelocityX(-200);
            this.sprite.setFrame(1);
        } else if (dKey.isDown) {
            this.sprite.setVelocityX(200);
            this.sprite.setFrame(2);
        } else {
            this.sprite.setVelocityX(0);
            this.sprite.setFrame(0);
        }
    }

    shoot() {
        // Shooting functionality will be handled in GameScene
    }
}