Esempio n. 1
0
        public void update()
        {
            position.CenterX = position.CenterX + speed.X;
            position.CenterY = position.CenterY + speed.Y;
            position.TopOfAutoDrawSet();

            foreach (Enemy e in enemies)
            {
                if (e.getPosition().Collided(position) && position.Visible)
                {
                    e.gotShot(position.Color);
                    position.Visible = false;
                    explosions.Add(new Explosion(hero, e));
                }
            }

            foreach (Explosion e in explosions)
            {
                e.update();
                e.interactEnemy(enemies);
            }

            explosions.RemoveAll(explosion => explosion.isDone());

            //if bullet is out off screen or some situation
            //bullet . alive = false
            // let bullet manager remove it
        }
Esempio n. 2
0
        protected override void UpdateWorld()
        {
            if (GamePad.ButtonBackClicked())
            {
                Exit();
            }

            #region change speed by inc/dec time for travelling
            mSecondsToTravel += GamePad.ThumbSticks.Right.Y;
            if (mSecondsToTravel <= 0f)
            {
                mSecondsToTravel = 0.1f;
            }
            #endregion

            #region recompute new speed for ball
            if (GamePad.ButtonAClicked())
            {
                ComputeBallSpeed();
                mBall.AddToAutoDrawSet();
                ResetBallShootInfo();
            }
            #endregion

            #region recompute new velocity direction for ball
            if (GamePad.ButtonBClicked())
            {
                GenerateRandomBallVelocityDirection();
                ResetBallShootInfo();
                mBall.TopOfAutoDrawSet();
            }
            #endregion

            #region determine if should contiune to draw the ball
            if (mBall.IsInAutoDrawSet())
            {
                Vector2 delta = mBall.Center - kInitPosition;
                mDistanceTravelled = delta.Length();

                if (mDistanceTravelled > kDistanceCovered)
                {
                    mBall.RemoveFromAutoDrawSet();
                }
                else
                {
                    mUpdatesSinceShoot++;
                }
            }
            #endregion

            EchoToTopStatus("Ball velocity:" + mBall.Velocity + "  position:" + mBall.Center);
            EchoToBottomStatus("Travel across " + kDistanceCovered + " units in: " + mSecondsToTravel + " seconds"
                               + " UpdatesSinceShoot(" + mUpdatesSinceShoot + ")");
        }
Esempio n. 3
0
        private void PlotSineCurve()
        {
            mPlotSet.RemoveAllFromSet();
            ComputeFrequencyScale();

            for (int x = 0; x < World.WorldDimension.X; x++)
            {
                float        y = mInitPos.Y + GetYValue(x);
                XNACS1Circle c = new XNACS1Circle(new Vector2(x, y), 0.2f);
                mPlotSet.AddToSet(c);
            }
            mTravel.TopOfAutoDrawSet();
        }
Esempio n. 4
0
        public FunctionPath(Vector2 origin, float w, float h, float xCoverage, float yCoverage)
        {
            mShowPlots = true;

            mPlotBox = new PlotBox(origin, w, h);

            mFunctionXCoverage = xCoverage;
            mFunctionYCoverage = yCoverage;
            mPlotDist          = mPlotBox.Width / kNumPlotPoints;

            mXTravelDistance = 0f;
            mTravel          = new XNACS1Circle(Vector2.Zero, kTravelRatio * mPlotDist);
            mTravel.Center   = mPlotBox.GetBoxPosition(mXTravelDistance, GetYValue(mXTravelDistance));
            mTravel.Color    = Color.Black;

            mConstantSpeed = false;

            mPlotSet = new XNACS1PrimitiveSet();
            PlotFunction();
            mTravel.TopOfAutoDrawSet();
        }
Esempio n. 5
0
 protected void PlotFunction()
 {
     mPlotSet.RemoveAllFromSet();
     mPlotDist = mPlotBox.Width / kNumPlotPoints;
     for (float xDist = 0f; xDist < mPlotBox.Width; xDist += mPlotDist)
     {
         float        nextY = GetYValue(xDist);
         Vector2      p     = mPlotBox.GetBoxPosition(xDist, nextY);
         XNACS1Circle c     = new XNACS1Circle(p, kPlotPtRatio * mPlotDist);
         if (mPlotBox.Collided(c))
         {
             mPlotSet.AddToSet(c);
         }
         else
         {
             c.RemoveFromAutoDrawSet();
         }
     }
     mTravel.TopOfAutoDrawSet();
     if (!mShowPlots)
     {
         mPlotSet.RemoveAllFromAutoDrawSet();
     }
 }