using System;
using System.Collections.Generic;
using System.Text;
using DxLibDLL;


namespace HH
{
    class Player : CBasic
    {
        public int Key;

        public Player()
        {
            this.position.x = 320;
            this.position.y = 400;
            this.graphicsHandle = DX.LoadGraph("Player.png");
        }

        public override void update()
        {
            // Value of input
            Key = DX.GetJoypadInputState(DX.DX_INPUT_KEY_PAD1);

            //  (bitwise, hit and positive)
            if ((Key & DX.PAD_INPUT_UP) > 0) this.position.y -= 3;
            if ((Key & DX.PAD_INPUT_DOWN) > 0) this.position.y += 3;
            if ((Key & DX.PAD_INPUT_RIGHT) > 0) this.position.x += 3;
            if ((Key & DX.PAD_INPUT_LEFT) > 0) this.position.x -= 3;

            if ( ((Key & DX.PAD_INPUT_A) > 0) && (this.timer == 5))
            {
                Program.game.newPlayerList.Add(new PlayerBulletA(this));
                timer = 0;
            }

            if (timer < 5) { timer++; }

            if (this.position.x < 0) this.position.x = 0;
            if (this.position.x > 640) this.position.x = 640;
            if (this.position.y < 0) this.position.y = 0;
            if (this.position.y > 480) this.position.y = 480;
            
        }
    }
}
