Exemple #1
0
        /// <summary>
        /// This tells whether or not the rectangle intersects with another rectangle
        /// </summary>
        /// <param name="other">The other rectangle</param>
        /// <returns>True if the intersect, false otherwise</returns>
        public bool Intersects(CircleEntity other)
        {
            int distance = (this.X - other.X) * (this.X - other.X) + (this.Y - other.Y) * (this.Y - other.Y);

            if (distance <= ((this.Radius + other.Radius) * (this.Radius + other.Radius)))
            {
                return(true);
            }
            return(false);
        }
Exemple #2
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here

            image = Content.Load <Texture2D>("square");

            squarePlayer = new SquareEntity(image, 50, 50);

            squareObsticles = new List <SquareEntity>();
            for (int i = 0; i < 10; i++)
            {
                SquareEntity obsticle = new SquareEntity(image,
                                                         ran.Next(GraphicsDevice.Viewport.Width),
                                                         ran.Next(GraphicsDevice.Viewport.Height),
                                                         ran.Next(5, 50),
                                                         ran.Next(5, 50));



                squareObsticles.Add(obsticle);
            }

            imageCircle = Content.Load <Texture2D>("circle");

            circlePlayer = new CircleEntity(imageCircle, 50, 50);

            circleObsticles = new List <CircleEntity>();
            for (int i = 0; i < 10; i++)
            {
                CircleEntity obsticle = new CircleEntity(imageCircle,
                                                         ran.Next(GraphicsDevice.Viewport.Width),
                                                         ran.Next(GraphicsDevice.Viewport.Height),
                                                         ran.Next(5, 50));



                circleObsticles.Add(obsticle);
            }

            arial20 = Content.Load <SpriteFont>("Arial20");
        }