Esempio n. 1
0
        public void Update(InputObject ship, Viewport viewPort, GameTime time, Camera camera)
        {
            RegisterHitBox();
            mouse = Mouse.GetState();

            Position = new Vector2(mouse.X + ship.Position.X - (viewPort.Width / 2),
                mouse.Y + ship.Position.Y - (viewPort.Height / 2 ));

            Rotation += time.ElapsedGameTime.Milliseconds / 110f;
            AnimateSprite(time, 0);
        }
Esempio n. 2
0
        public void UpdateInput(KeyboardState t_keyState, GameTime t_time, Viewport t_viewPort, int t_switchFrame,
            Background backGround, GameMouse mouse, Camera camera)
        {
            ProccessInput(t_keyState, t_time, t_viewPort, mouse, camera);
            //CalculatePosition(t_viewPort, backGround);
            //ApplyConstraints();
            //RegisterHitBox();
            this.Update(t_time, t_viewPort, t_switchFrame, backGround);

            //if the object needs to animate on a timer do not pass 0 to t_switchFrame
            if (t_switchFrame != 0)
                AnimateSprite(t_time, t_switchFrame);

            Rotation = Force.X;
        }
Esempio n. 3
0
        // Proccess keyboard input
        private void ProccessInput(KeyboardState t_keyState, GameTime t_time, Viewport t_viewPort, GameMouse mouse, Camera camera)
        {
            // Protected KeyBoard Input Code
            ///////////////////////////////////////////////////////////////
            // Roation  Q / E
            if (t_keyState.IsKeyDown(Keys.Q))
                Force = new Vector2(Force.X - (TurnRate *
                    (float)t_time.ElapsedGameTime.TotalSeconds), Force.Y);
            if (t_keyState.IsKeyDown(Keys.E))
                Force = new Vector2(Force.X + (TurnRate *
                    (float)t_time.ElapsedGameTime.TotalSeconds), Force.Y);
            ////////////////////////////////////////////////////////////////

            // mouse input code
            ////////////////////////////////////////////////////////////////
            Vector2 direction = new Vector2();
            direction = mouse.Position - Position;
            Force = new Vector2((float)Math.Atan2(direction.Y,direction.X), Force.Y);
            ///////////////////////////////////////////////////////////////

            // Strafe A / D
            if (t_keyState.IsKeyDown(Keys.A))
            {
                Strafe = new Vector2((float)(Force.X + Math.PI / 2),
                    Strafe.Y - AccelerationRate * (float)t_time.ElapsedGameTime.TotalSeconds);
            }
            else if (t_keyState.IsKeyDown(Keys.D))
            {
                Strafe = new Vector2((float)(Force.X + Math.PI / 2),
                    Strafe.Y + AccelerationRate * (float)t_time.ElapsedGameTime.TotalSeconds);
            }
            else
                Strafe = new Vector2(Strafe.X, 0);

            // Accelerate forward W
            if (t_keyState.IsKeyDown(Keys.W))
                Force = new Vector2(Force.X,
                    Force.Y + AccelerationRate * (float)t_time.ElapsedGameTime.TotalSeconds);
            else
                Force = new Vector2(Force.X, 0);

            // Brake S
            if (t_keyState.IsKeyDown(Keys.S))
                Trajetory = new Vector2(Trajetory.X,
                     Trajetory.Y - (float)(1.90f * Trajetory.Y * t_time.ElapsedGameTime.TotalSeconds));
        }
Esempio n. 4
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: Add your initialization logic here
            mouse = new GameMouse(Content, "Art/mice", new Vector2(3,1));
            camera = new Camera();
            debug = new Debug(Content, spriteBatch, 0, 0);
            ship = new InputObject(Content, "Art/spaceShip", new Vector2(0, 0), new Vector2(0, 0), 6.0f, 30);
            backGround = new Background(Content, graphics, "Art/space");
            asteroid = new List<Asteroid>();

            blasters = new List<Blasters>();

            base.Initialize();
        }