/// <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(SquareEntity other) { Rectangle otherRect = new Rectangle(other.X, other.Y, other.Width, other.Height); if (rect.Intersects(otherRect)) { return(true); } return(false); }
/// <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"); }