Exemplo n.º 1
0
        protected override void Initialize()
        {
            entities = new List<GameEntity>();
            AIs = new List<AI>();
            removalQueue = new Queue<GameEntity>();
            spawnQueue = new Queue<Spawnable>();
            collisions = new HashSet<Collision>();
            currLevel = new Level(this);
            graphics.PreferredBackBufferHeight = Static.SCREEN_HEIGHT;
            graphics.PreferredBackBufferWidth = Static.SCREEN_WIDTH;
            this.players = new Player[4];

            //just for testing -- makes a rectangle
            //Texture2D playerRect = new Texture2D(GraphicsDevice, Static.PLAYER_HEIGHT, Static.PLAYER_WIDTH);
            Texture2D playerRect = Content.Load<Texture2D>("Sprites/player");

            Color[] data = new Color[Static.PLAYER_HEIGHT * Static.PLAYER_WIDTH];
            for (int i = 0; i < data.Length; ++i)
            {
                data[i] = Color.Aquamarine;
            }

            //playerRect.SetData(data);
            //will use real sprites eventually..

            players[0] = new Player(this,PlayerIndex.One,playerRect,0,0);

            Spawn(players[0]);
            Spawn(new BasicNPC(this, playerRect, 300, 100, 10, 10));

            base.Initialize();
        }
Exemplo n.º 2
0
        protected void handlePlayerInput(Player player)
        {
            if (GamePad.GetState(player.playerIndex).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }
            if (GamePad.GetState(player.playerIndex).ThumbSticks.Left.Y > .5 || Keyboard.GetState().IsKeyDown(Keys.Up))
            {
                player.MoveUp();
                player.rotateToAngle((float)Math.PI / 2);
            }
            if (GamePad.GetState(player.playerIndex).ThumbSticks.Left.X < -.5 || Keyboard.GetState().IsKeyDown(Keys.Left))
            {
                player.MoveLeft();
                player.rotateToAngle((float)Math.PI);

            }
            if (GamePad.GetState(player.playerIndex).ThumbSticks.Left.X > .5 || Keyboard.GetState().IsKeyDown(Keys.Right))
            {
                player.MoveRight();
                player.rotateToAngle((float)0);

            }
            if (GamePad.GetState(player.playerIndex).ThumbSticks.Left.Y < -.5 || Keyboard.GetState().IsKeyDown(Keys.Down))
            {
                player.MoveDown();
                player.rotateToAngle((float)(3 * Math.PI / 2));

            }

            if (GamePad.GetState(player.playerIndex).Buttons.LeftShoulder == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.D1))
            {
                player.L1Button();
            }
            if (GamePad.GetState(player.playerIndex).Triggers.Left > .5f || Keyboard.GetState().IsKeyDown(Keys.D2))
            {
                player.L2Button();
            }
            if (GamePad.GetState(player.playerIndex).Buttons.RightShoulder == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.D3))
            {
                player.R1Button();
            }
            if (GamePad.GetState(player.playerIndex).Triggers.Right > .5f || Keyboard.GetState().IsKeyDown(Keys.D4))
            {
                player.R2Button();
            }

            // ALEX
            MouseState mouse = Mouse.GetState();

            playerMouseDistance.X = mouse.X - player.x;	// distance between player and mouse
            playerMouseDistance.Y = mouse.Y - player.y;

            if (mouse.LeftButton == ButtonState.Pressed) {
                player.LeftClick();
            }

            //-ALEX
        }