Exemple #1
0
        /// <summary>
        /// Initialize the internal state of your game
        /// </summary>
        protected override void InitializeWorld()
        {
            mTarget       = new XNACS1Circle(new Vector2(50, 30), 1f);
            mTarget.Color = Color.Red;

            mSocccer = new MySoccer();
        }
Exemple #2
0
        // fire the weapon
        public virtual void fire()
        {
            XNACS1Circle bullet = new XNACS1Circle(hero.getPosition().Center, bulletSize);

            bullet.Color = hero.getColor();
            bullets.Enqueue(bullet);
        }
Exemple #3
0
 private void CreateBall(Vector2 pos)
 {
     mBall = new XNACS1Circle(pos, mBallRadius, "SoccerBall");
     mBall.VelocityDirection = mBallVelocity;
     mBall.Speed             = mBallSpeed;
     mBall.ShouldTravel      = true;
 }
Exemple #4
0
 public shot(Vector2 center, bool hit)
 {
     bullet   = new XNACS1Circle(center, 1f, "bullet");
     this.hit = hit;
     shotLife = 25;
     emitter  = new XNACS1ParticleEmitter.FireEmitter(center, 30, 0.5f, "bullet", Color.OrangeRed, 20f, 3f, new Vector2(-1, 0));
 }
 public shot(Vector2 center, bool hit)
 {
     bullet       = new XNACS1Circle(center, .75f, "wizardShot");
     bullet.Speed = 1f;
     this.hit     = hit;
     shotLife     = 40;
     emitter      = new XNACS1ParticleEmitter.FireEmitter(center, 10, 0.3f, "wizardShot", Color.Green, 1f, 3f, new Vector2(-1, 0));
 }
Exemple #6
0
        private XNACS1Circle starAt(float xPos)
        {
            Vector2      position = new Vector2(xPos, randomPosition());
            XNACS1Circle star     = new XNACS1Circle(position, size);

            star.Color = randomStarColor();
            return(star);
        }
 public void reflect(XNACS1Circle other)
 {
     if (other != null)
     {
         pushOutCircle(other);
         reflectHelper(other);
     }
 }
Exemple #8
0
 public shot(Vector2 center, bool hit)
 {
     bullet       = new XNACS1Circle(center, .75f, "violetlight");
     bullet.Speed = 1f;
     this.hit     = hit;
     shotLife     = 15;
     emitter      = new XNACS1ParticleEmitter.FireEmitter(center, 10, 0.3f, "violetlight", Color.Pink, 1f, 3f, new Vector2(-1, 0));
 }
Exemple #9
0
 public void reflect(XNACS1Circle other)
 {
     if (other != null)
     {
         reflectOutCircle(other);
         //pushOutCircle(other);
         //reflectionVelocityResolution(other);
     }
 }
Exemple #10
0
        private float kDrawSize = 8f; // draw size ...

        public VectorComponents()
        {
            // Create first to show on bottom!
            mStart        = new XNACS1Circle();
            mStart.Radius = 0.5f;
            mStart.Color  = Color.Black;

            mVec     = new XNACS1Rectangle();
            mTangent = new XNACS1Rectangle();
            mNormal  = new XNACS1Rectangle();
        }
Exemple #11
0
        public Bullet(Vector2 genaratePosition, Vector2 currentSpeed, float radius, Hero currentHero, List <Enemy> currentEnemy)
        {
            this.position       = new XNACS1Circle(genaratePosition, radius);
            this.position.Color = Game.randomColor();
            explosions          = new List <Explosion>();
            // set object into motion;

            this.alive   = true;
            this.hero    = currentHero;
            this.enemies = currentEnemy;
            this.speed   = currentSpeed;
        }
Exemple #12
0
        public Explosion(Hero h, Enemy e)
        {
            splash         = new XNACS1Circle(e.getPosition().Center, splashRadius);
            timer          = new Timer(duration);
            splash.Color   = h.getColor();
            splash.Visible = false;
            splash.RemoveFromAutoDrawSet();

            emitter = new ExplosionEmitter(e.getPosition().Center, duration, 0.6f, h.getColor());
            emitter.DrawHalo(20);
            emitter.AutoRemoveDeadParticles = true;
        }
Exemple #13
0
        /// <summary>
        /// You should initialize/allocate instance variables here!
        /// </summary>
        protected override void InitializeWorld()
        {
            World.SetWorldCoordinate(new Vector2(0, 0), 100);

            mBall              = new XNACS1Circle(new Vector2(20f, 20f), 1);
            mBall.Texture      = "SoccerBall";
            mBall.ShouldTravel = true;

            mCurrentSpeed = 0.1f;
            mCurrentDir   = new Vector2();

            SetRandomBallVelocityDir();
        }
Exemple #14
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();
        }
Exemple #15
0
        public override void fire()
        {
            base.fire();

            XNACS1Circle bullet = new XNACS1Circle(hero.getPosition().Center, bulletSize);

            bullet.Color = hero.getColor();
            angledBullets.Enqueue(bullet);

            bullet       = new XNACS1Circle(hero.getPosition().Center, bulletSize);
            bullet.Color = hero.getColor();
            angledBullets.Enqueue(bullet);
        }
Exemple #16
0
        public ShowVector(Vector2 startPos, Vector2 dir, float size)
        {
            mDir  = dir;
            mSize = size;

            mVec    = new XNACS1Rectangle();
            mVecInX = new XNACS1Rectangle();
            mVecInY = new XNACS1Rectangle();

            // Create last to show on top!
            mStart       = new XNACS1Circle(startPos, kVecWidth / 3);
            mStart.Color = Color.Red;

            UpdateEndPoints();
        }
Exemple #17
0
        protected override void InitializeWorld()
        {
            World.SetWorldCoordinate(new Vector2(0, 0), 100f);
            mPeriods = 2f;
            ComputeFrequencyScale();
            mAmplitude = 10f;

            mInitPos      = new Vector2(0, World.WorldDimension.Y / 2f);
            mTravel       = new XNACS1Circle(mInitPos, 2f);
            mTravel.Color = Color.Black;

            mPlotSet = new XNACS1PrimitiveSet();

            mConstantSpeed = false;

            PlotSineCurve();
        }
        protected void pushOutCircle(XNACS1Circle other)
        {
            if (other != null)
            {
                // pushout
                Vector2 dist = other.Center - Center;

                if (dist.Length() != 0)
                {
                    Vector2 direction = new Vector2(dist.X, dist.Y);
                    direction.Normalize();
                    float totalRadius = other.Radius + Radius;
                    other.CenterX += (totalRadius - dist.Length()) * direction.X;
                    other.CenterY += (totalRadius - dist.Length()) * direction.Y;
                }
            }
        }
Exemple #19
0
        protected override void InitializeWorld()
        {
            World.SetWorldCoordinate(new Vector2(-5f, 0f), kDistanceCovered + kUnits);

            // Create the road mile posts ...
            for (int i = 0; i < kUnits; i++)
            {
                int             centerX = (i * kUnits) + (kUnits / 2);
                XNACS1Rectangle r       = new XNACS1Rectangle(new Vector2((float)centerX, kRoadY), kUnits, 1);
                r.Color = kRoadColor[i];
                r.Label = centerX.ToString();
            }

            mBall = new XNACS1Circle(new Vector2(kDistanceCovered + 1f, kRoadY), 2f);
            mBall.ShouldTravel = true;
            mBall.RemoveFromAutoDrawSet();
        }
Exemple #20
0
        public void update()
        {
            // move stars, and redraw
            foreach (XNACS1Circle star in stars)
            {
                star.CenterX -= speed;
                star.TopOfAutoDrawSet();
            }

            // recycle stars to right edge of screen
            if (stars.First().CenterX <= GameWorld.leftEdge)
            {
                XNACS1Circle star = stars.Dequeue();
                star.CenterX = GameWorld.rightEdge;
                star.CenterY = randomPosition();
                stars.Enqueue(star);
            }
        }
Exemple #21
0
        protected override void InitializeWorld()
        {
            World.SetWorldCoordinate(new Vector2(-kWorldSize, -kWorldSize * (9f / 16f)), (2f * kWorldSize));

            mRoad = new XNACS1Rectangle[10];
            // Create the road mile posts ...
            for (int i = 0; i < kUnits; i++)
            {
                mRoad[i]       = new XNACS1Rectangle(kInitPosition, kUnits, kRoadWidth);
                mRoad[i].Color = kRoadColor[i];
                mRoad[i].Label = ((i * kUnits) + (kUnits / 2)).ToString();
            }

            mBall = new XNACS1Circle(kInitPosition, 2f);
            mBall.ShouldTravel = true;
            mBall.RemoveFromAutoDrawSet();
            mDistanceTravelled = kWorldSize * 2f;

            GenerateRandomBallVelocityDirection();
            ComputeBallSpeed();
        }
Exemple #22
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();
        }
Exemple #23
0
        public override void update()
        {
            // we have to maintain our own bullet queue because Weapon class will otherwise
            // just move bullet horizontally

            for (int i = 0; i < angledBullets.Count; i++)
            {
                XNACS1Circle b = angledBullets.ElementAt(i);
                b.CenterX += bulletSpeed;
                if (i % 2 == 0)
                {
                    b.CenterY -= bulletSpeed / 2;
                }
                else
                {
                    b.CenterY += bulletSpeed / 2;
                }
            }

            while (angledBullets.Count > 0 && (angledBullets.First().CenterX - angledBullets.First().Radius) > GameWorld.rightEdge)
            {
                angledBullets.Dequeue().RemoveFromAutoDrawSet();
            }

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

            base.update();
        }
Exemple #24
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();
     }
 }
Exemple #25
0
        // Pushes out a circle while reflecting it based on its velocity.
        protected void reflectOutCircle(XNACS1Circle other)
        {
            if (other != null)
            {
                float topD = 0f, bottomD = 0f, leftD = 0f, rightD = 0f;

                if (other.VelocityY > 0f)
                {   // flying upwards
                    // check for bottom penetration
                    topD = (other.CenterY + other.Radius) - MinBound.Y;
                }
                else
                {
                    // flying downwards
                    // check for top penetration
                    bottomD = MaxBound.Y - (other.CenterY - other.Radius);
                }

                if (other.VelocityX > 0)
                {   // flying towards right
                    // check for left penetration
                    leftD = (other.CenterX + other.Radius) - MinBound.X;
                }
                else
                {
                    // flying towards left
                    // check for right penetration
                    rightD = MaxBound.X - (other.CenterX - other.Radius);
                }

                if (topD > 0)
                {
                    if (leftD > 0)
                    {
                        if (topD < leftD)
                        {
                            other.CenterY    = CenterY - other.Radius - (Height / 2f); // push up from top
                            other.VelocityY *= -1f;
                        }
                        else
                        {
                            other.CenterX    = CenterX - other.Radius - (Width / 2f); // push towards left
                            other.VelocityX *= -1f;
                        }
                    }
                    else if (rightD > 0)
                    {
                        if (topD < rightD)
                        {
                            other.CenterY    = CenterY - other.Radius - (Height / 2f); // push up from top
                            other.VelocityY *= -1f;
                        }
                        else
                        {
                            other.CenterX    = CenterX + other.Radius + (Width / 2f); // push towards right
                            other.VelocityX *= -1f;
                        }
                    }
                }
                else if (bottomD > 0)
                {
                    if (leftD > 0)
                    {
                        if (bottomD < leftD)
                        {
                            other.CenterY    = CenterY + other.Radius + (Height / 2f); // push up from bottom
                            other.VelocityY *= -1f;
                        }
                        else
                        {
                            other.CenterX    = CenterX - other.Radius - (Width / 2f); // push towards left
                            other.VelocityX *= -1f;
                        }
                    }
                    else if (rightD > 0)
                    {
                        if (bottomD < rightD)
                        {
                            other.CenterY    = CenterY + other.Radius + (Height / 2f); // push up from bottom
                            other.VelocityY *= -1f;
                        }
                        else
                        {
                            other.CenterX    = CenterX + other.Radius + (Width / 2f); // push towards right
                            other.VelocityX *= -1f;
                        }
                    }
                }
            }
        }
Exemple #26
0
 public void CreateTarget()
 {
     m_Target = new XNACS1Circle(new Vector2(30f, 30f), 2f, "SoccerBall");
 }
Exemple #27
0
 public void DestroyTarget()
 {
     m_Target.RemoveFromAutoDrawSet();
     m_Target = null;
 }
Exemple #28
0
        protected void pushOutCircle(XNACS1Circle other)
        {
            if (other != null)
            {
                float topD = 0f, bottomD = 0f, leftD = 0f, rightD = 0f;

                if (other.VelocityY > 0f)
                {   // flying upwards
                    // check for bottom penetration
                    topD = (other.CenterY + other.Radius) - MinBound.Y;
                }
                else
                {
                    // flying downwards
                    // check for top penetration
                    bottomD = MaxBound.Y - (other.CenterY - other.Radius);
                }

                if (other.VelocityX > 0)
                {   // flying towards right
                    // check for left penetration
                    leftD = (other.CenterX + other.Radius) - MinBound.X;
                }
                else
                {
                    // flying towards left
                    // check for right penetration
                    rightD = MaxBound.X - (other.CenterX - other.Radius);
                }

                if (topD > 0)
                {
                    if (leftD > 0)
                    {
                        if (topD < leftD)
                        {
                            other.CenterY = CenterY - other.Radius - (Height / 2f); // push up from top
                        }
                        else
                        {
                            other.CenterX = CenterX - other.Radius - (Width / 2f); // push towards left
                        }
                    }
                    else if (rightD > 0)
                    {
                        if (topD < rightD)
                        {
                            other.CenterY = CenterY - other.Radius - (Height / 2f); // push up from top
                        }
                        else
                        {
                            other.CenterX = CenterX + other.Radius + (Width / 2f); // push towards right
                        }
                    }
                }
                else if (bottomD > 0)
                {
                    if (leftD > 0)
                    {
                        if (bottomD < leftD)
                        {
                            other.CenterY = CenterY + other.Radius + (Height / 2f); // push up from bottom
                        }
                        else
                        {
                            other.CenterX = CenterX - other.Radius - (Width / 2f); // push towards left
                        }
                    }
                    else if (rightD > 0)
                    {
                        if (bottomD < rightD)
                        {
                            other.CenterY = CenterY + other.Radius + (Height / 2f); // push up from bottom
                        }
                        else
                        {
                            other.CenterX = CenterX + other.Radius + (Width / 2f); // push towards right
                        }
                    }
                }

                /*
                 * Vector2 otherCenter = new Vector2(other.CenterX, other.CenterY);
                 * float left = CenterX - (Width / 2);
                 * float right = CenterX + (Width / 2);
                 * float top = CenterY + (Width / 2);
                 * float bottom = CenterY - (Width / 2);
                 * otherCenter.X = MathHelper.Clamp(otherCenter.X, left, right);
                 * otherCenter.Y = MathHelper.Clamp(otherCenter.Y, top, bottom);
                 * Vector2 direction = other.Center - otherCenter;
                 * float dist = other.Radius - direction.Length();
                 * direction.Normalize();
                 * other.Center += dist * direction;
                 */
            }
        }
Exemple #29
0
 public Cursor()
 {
     oHitbox       = new XNACS1Circle(new Vector2(), fCursorRadius);
     oHitbox.Color = Color.Red;
     //oHitbox.Visible = false;
 }
Exemple #30
0
 public void DestroyBall()
 {
     mBall.RemoveFromAutoDrawSet();
     mBall = null;
 }