public override void Update(GameTime gameTime)
        {
            timeSinceSpawn += gameTime.ElapsedGameTime;

            prevMouseState = mouseState;
            mouseState = Mouse.GetState();
            prevKBState = KBState;
            KBState = Keyboard.GetState();
            if (KBState.ClickPress(prevKBState,Keys.L))
            {
            }
            //
            //            if (mouseState.LeftButton == ButtonState.Pressed &&
            //                prevMouseState.LeftButton == ButtonState.Released)
            //            {
            //                if (KBState.ClickPress(lastKeyboardState,Keys.LeftShift))
            //                {
            //                    curveX.Keys.Clear();
            //                    curveY.Keys.Clear();
            //                    span = -1f;
            //                }
            //                span++;
            //                curveX.Keys.Add(new CurveKey(span,mouseState.X));
            //                curveY.Keys.Add(new CurveKey(span,mouseState.Y));
            //                InitializePoints();
            //            }

            Pos.X = curveX.Evaluate((float) timeSinceSpawn.TotalSeconds%span);
            Pos.Y = curveY.Evaluate((float) timeSinceSpawn.TotalSeconds%span);
            base.Update(gameTime);
        }
        public override void Update(GameTime gameTime)
        {
            someVect = new Vector2();

            prevKeyboard = keyboard;
            keyboard = Keyboard.GetState();

            distance = Vector2.Distance(pathNodes[currentNodeIndex], Pos);
            if (keyboard.ClickPress(prevKeyboard,Keys.Space) || distance < 60)
            {
                ++currentNodeIndex;
                currentNodeIndex %= pathNodes.Count;
            }

            //            MouseState mouse = Mouse.GetState();
            //            pathNodes[4] = new Vector2(mouse.X,mouse.Y);
            angleToTarget = MathHelper.ToDegrees((float) (Math.Atan2(
                pathNodes[currentNodeIndex].Y - Pos.Y,
                                                                         pathNodes[currentNodeIndex].X - Pos.X)));
            angleToTarget = angleToTarget-AngleInDeg;
            angleToTarget -= 90f;
            if (angleToTarget < -180f)
            {
                angleToTarget += 360f;
            }
            else if (angleToTarget > 180f)
            {
                angleToTarget -= 360f;
            }
            if (angleToTarget < 0f)
            {
                AngleInDeg -= 1f;
            }
            else if (angleToTarget > 0f)
            {
                AngleInDeg += 1f;
            }
            //            sqrtVelY = 1 - (0.5 * Math.Pow(Velocity.Y / 1000, 2));
            //            sqrtVelX = 1 - (0.5 * Math.Pow(Velocity.X / 1000, 2));
            //            var xCircle = Velocity.X * Math.Sqrt(sqrtVelY) * timeInSeconds;
            //            var yCircle = Velocity.Y * Math.Sqrt(sqrtVelX) * timeInSeconds;
            //            Pos.X += (float)(xCircle);
            //            Pos.Y += (float)(yCircle);
            var angle = AngleToVector(AngleInRad);
            Pos += angle*3;
            base.Update(gameTime);
        }
        public override void Update(GameTime gameTime)
        {
            prevKeyboard = keyboard;
            keyboard = Keyboard.GetState();

            if (keyboard.IsKeyDown(Keys.Left))
            {
                AngleInDeg = AngleInDeg + 1;
            }
            else if (keyboard.IsKeyDown(Keys.Right))
            {
                AngleInDeg = AngleInDeg - 1;
            }
            if (keyboard.ClickPress(prevKeyboard,Keys.H))
            {
                test = !test;
            }
            UtilityMethods.MoveVector2WASD(ref Pos, ref BoundingRect);

            currentCellsOccupied.Clear();
            currentCellsOccupiedString = "";
            grid = new List<int>[GridWide, GridHigh];
            rect = BoundingRect;
            for (int i = (int)Math.Floor((double)(rect.Top * 2) / framesize); i < (int)Math.Ceiling((double)(rect.Bottom * 2) / framesize); i++)
            {
                for (int j = (int)Math.Floor((double)(rect.Left * 2) / framesize); j < (int)Math.Ceiling((double)(rect.Right * 2) / framesize); j++)
                {
                    if (j >= 0 && j < GridWide && i >= 0 && i < GridHigh)
                    {
                        if (grid[j, i] == null)
                        {
                            grid[j, i] = new List<int>();
                        }
                        grid[j, i].Add(1);
                        //                        currentCellsOccupied.Add(new[]{j,i});
                        //                        currentCellsOccupiedString += "(" + j + "," + i + "), ";
                    }

                }
            }
            rect = new Rectangle((int)(WidthOfGame / 4 - Origin.X), (int)(HeightOfGame / 4 - Origin.Y), Frames[0].Width, Frames[0].Height);
            for (int i = (int)Math.Floor((double)(rect.Top * 2) / framesize); i < (int)Math.Ceiling((double)(rect.Bottom * 2) / framesize); i++)
            {
                for (int j = (int)Math.Floor((double)(rect.Left * 2) / framesize); j < (int)Math.Ceiling((double)(rect.Right * 2) / framesize); j++)
                {
                    if (j >= 0 && j < GridWide && i >= 0 && i < GridHigh)
                    {
                        if (grid[j, i] == null)
                        {
                            grid[j, i] = new List<int>();
                        }
                        grid[j, i].Add(2);
                    }
                    currentCellsOccupiedString += "(" + j + "," + i + "), ";
                    currentCellsOccupied.Add(new[] { j, i });
                }
            }

            someVect = new Vector2();
            isColliding = false;
            for (int i = 0; i < GridHigh; i++)
            {
                for (int j = 0; j < GridWide; j++)
                {
                    if (grid[j, i] == null)
                    {
                        grid[j, i] = new List<int>();
                    }
                    if (grid[j, i].Count < 2)
                    {
                        continue;
                    }
                    var mat1 = UtilityMethods.Get2DTransformationMatrix(-Origin, AngleInRad, 2f, Pos);
                    var mat2 = UtilityMethods.Get2DTransformationMatrix(-Origin, null, 2f,
                                                                        new Vector2(WidthOfGame / 2, HeightOfGame / 2));
            //                    Matrix mat1 =
            //                    Matrix.CreateTranslation(new Vector3(-Origin, 0.0f)) *
            //                         Matrix.CreateScale(2f) *//  would go here
            //                    Matrix.CreateRotationZ(AngleInRad) *
            //                    Matrix.CreateTranslation(new Vector3(Pos, 0.0f));
            //
            //                    Matrix mat2 =
            //                    Matrix.CreateTranslation(new Vector3(-Origin, 0.0f)) *
            //                         Matrix.CreateScale(2f) *// would go here
            ////                    Matrix.CreateRotationZ(AngleInRad) *
            //                    Matrix.CreateTranslation(new Vector3(new Vector2(WidthOfGame / 2, HeightOfGame / 2), 0.0f));
                    isColliding = UtilityMethods.TexturesCollide(ColorArrays[0], mat1, ColorArrays[0], mat2);
            //                    isColliding = IntersectPixels(mat1, 20, 25, ColorArrays[0], mat2, 20, 25, ColorArrays[0]);
            //                    isColliding = someVect != new Vector2(-1, -1);
                }
            }

            base.Update(gameTime);
        }
        public override void Update(GameTime gameTime)
        {
            timeSinceSpawn += gameTime.ElapsedGameTime;

            //            CheckGamePadInput();
            //            CheckKeyboardInput();

            prevMouseState = mouseState;
            mouseState = Mouse.GetState();
            prevKBState = KBState;
            KBState = Keyboard.GetState();
            if (KBState.ClickPress(prevKBState, Keys.L))
            {
                GetCurve("X.xml", out curveX);
                GetCurve("Y.xml", out curveY);
                timeSinceSpawn = new TimeSpan(0, 0, 0);
                var lastOrDefault = curveX.Keys.LastOrDefault();
                span = lastOrDefault != null ? lastOrDefault.Position : 1f;
                lastOrDefault = curveY.Keys.LastOrDefault();
                if (lastOrDefault != null && lastOrDefault.Position > span)
                {
                    span = lastOrDefault.Position;
                }
                InitializeTransform();
                InitializeEffect();
                InitializePoints();
                InitializeLineStrip();
            }
            //
            //            if (mouseState.LeftButton == ButtonState.Pressed &&
            //                prevMouseState.LeftButton == ButtonState.Released)
            //            {
            //                if (KBState.ClickPress(lastKeyboardState,Keys.LeftShift))
            //                {
            //                    curveX.Keys.Clear();
            //                    curveY.Keys.Clear();
            //                    span = -1f;
            //                }
            //                span++;
            //                curveX.Keys.Add(new CurveKey(span,mouseState.X));
            //                curveY.Keys.Add(new CurveKey(span,mouseState.Y));
            //                InitializePoints();
            //            }

            Pos.X = curveX.Evaluate((float)timeSinceSpawn.TotalSeconds % span);
            Pos.Y = curveY.Evaluate((float)timeSinceSpawn.TotalSeconds % span);
            base.Update(gameTime);
        }
        private void HandleInput(GameTime gameTime)
        {
            LastKBState = CurrentKBState;
            CurrentKBState = Keyboard.GetState();
            timeInSeconds = (float)gameTime.ElapsedGameTime.TotalSeconds;

            //buffMultiplierX = 5;// (Velocity.X / maxVelocity * 100) + 1;
            //if (buffMultiplierX < 1) buffMultiplierX = 1;
            if ((CurrentKBState.IsKeyDown(Keys.Left) ||
                CurrentKBState.IsKeyDown(Keys.A))&& Velocity.X >= -maxVelocity)
            {
                Velocity.X -= (Velocity.X > 0 ? increment*buffMultiplier : increment)*timeInSeconds;

            }

            else if ((CurrentKBState.IsKeyDown(Keys.Right) ||
                CurrentKBState.IsKeyDown(Keys.D))&& Velocity.X <= maxVelocity)
            {
                Velocity.X += (Velocity.X < 0 ? increment*buffMultiplier : increment)*timeInSeconds;
            }

            else if (Velocity.X > 0)
            {
                Velocity.X -= increment*timeInSeconds;
            }

            else if (Velocity.X < 0)
            {
                Velocity.X += increment*timeInSeconds;
            }

            //buffMultiplierY = (Velocity.Y / maxVelocity*100) + 1;
            //if (buffMultiplierY < 1) buffMultiplierY = 1;
            if ((CurrentKBState.IsKeyDown(Keys.Up) ||
                CurrentKBState.IsKeyDown(Keys.W)) && Velocity.Y >= -maxVelocity)
            {
                Velocity.Y -= (Velocity.Y > 0 ? increment*buffMultiplier : increment)*timeInSeconds;
            }

            else if ((CurrentKBState.IsKeyDown(Keys.Down) ||
                CurrentKBState.IsKeyDown(Keys.S)) && Velocity.Y <= maxVelocity)
            {
                Velocity.Y += (Velocity.Y < 0 ? increment*buffMultiplier : increment)*timeInSeconds;
            }

            else if (Velocity.Y > 0)
            {
                //if (Velocity.Y < 1) Velocity.Y = 1
                Velocity.Y -= increment * timeInSeconds;
            }

            else if (Velocity.Y < 0)
            {
                Velocity.Y += increment * timeInSeconds;
            }

            //			if (kbState.IsKeyDown(Keys.E))
            //			{
            //				mode = (mode + 1) % 3;
            //			}
            //			if (kbState.IsKeyDown(Keys.SPACE))
            //			{
            //				fireGun();
            //
            //			}
            //			if (kbState.IsKeyDown(Keys.L))
            //			{
            //				(FP.world.create(EnemyShip) as EnemyShip).setInit();
            //			}
            //
            //DEBUG
            if (CurrentKBState.ClickPress(LastKBState,Keys.D1))
            {
                maxVelocity -= 10;
            }
            if (CurrentKBState.ClickPress(LastKBState,Keys.D2))
            {
                maxVelocity += 10;
            }
            if (CurrentKBState.ClickPress(LastKBState,Keys.D3))
            {
                increment-=100;
            }
            if (CurrentKBState.ClickPress(LastKBState,Keys.D4))
            {
                increment+=100;
            }
            if (CurrentKBState.ClickPress(LastKBState,Keys.D5))
            {
                buffMultiplier -= 1;
            }
            if (CurrentKBState.ClickPress(LastKBState,Keys.D6))
            {
                buffMultiplier += 1;
            }
        }