IntersectsWith() private method

private IntersectsWith ( Rectangle rect ) : bool
rect Rectangle
return bool
Exemplo n.º 1
0
 private void SearchIntersections() // scans if the ball is intersecting with anything
 {
     for (int i = 0; i < 60; i++)
     {
         if (pingBall.IntersectsWith(bricks[i]) && brickExists[i] == true)
         {
             //rectangleGraphics.FillRectangle(blackBrush, bricks[i]);
             brickExists[i] = false;
             // write code to detect specific wall; WallRebound(0/1/2/3);
             System.Drawing.Rectangle leftSide = new System.Drawing.Rectangle(bricks[i].Left, bricks[i].Top, 1, 25);
         }
     }
     if (pingBall.Left < 0)
     {
         runningVelocity[1] *= -1;
     }
     if (pingBall.IntersectsWith(topWall))
     {
         runningVelocity[0] *= -1;
     }
     if (pingBall.Right > 450)
     {
         runningVelocity[1] *= -1;
     }
     if (pingBall.IntersectsWith(bottomWall))
     {
         YouDroppedTheBallOnThisOne();
     }
     if (pingBall.IntersectsWith(paddle))
     {
         CurryRebound();
     }
 }
Exemplo n.º 2
0
 void CropSelector_MouseDown(object sender, MouseEventArgs e)
 {
     mouse_state=1;
     Rectangle r=new Rectangle (MousePosition, new Size (10, 10));
     if (r.IntersectsWith (new Rectangle (button5.PointToScreen (Point.Empty), button5.Size)))
     {
         //v>
         mode=9;
         OldSize=this.Size;
     }
     else if (r.IntersectsWith (new Rectangle (button6.PointToScreen (Point.Empty), button6.Size)))
     {
         //vvv
         mode=2;
         OldSize=this.Size;
     }
     else if (r.IntersectsWith (new Rectangle (button8.PointToScreen (Point.Empty), button8.Size)))
     {
         //>>>
         mode=5;
         OldSize=this.Size;
     }
     else
     {
         mode=1;
         OldMouse=MousePosition;
         Dif=new Point (Absolute (OldMouse.X-this.Location.X), Absolute (OldMouse.Y-this.Location.Y));
     }
 }
Exemplo n.º 3
0
        public void MDown(MouseEventArgs e)
        {
            if (IsDraowing)
            {
                //paintSh.start = new Point(e.X, e.Y);
                paintSh.startX = e.X;
                paintSh.startY = e.Y;
            }

            if (selectedShape != null)
            {
                IsMovieng = true;
                deltaX    = Math.Abs(selectedShape.startX - e.X);
                deltaY    = Math.Abs(selectedShape.startY - e.Y);

                if (selectedShape.Path.GetBounds().Contains(e.X + 15, e.Y + 15) || selectedShape.Path.GetBounds().Contains(e.X - 15, e.Y - 15))
                {
                    System.Drawing.Rectangle mouse  = new System.Drawing.Rectangle(e.X - 10, e.Y - 10, 20, 20);
                    System.Drawing.Rectangle top    = new System.Drawing.Rectangle((selectedShape.getX() + selectedShape.getWidth() / 2) - 5, selectedShape.getY() - 15, 10, 10);
                    System.Drawing.Rectangle left   = new System.Drawing.Rectangle(selectedShape.getX() - 15, (selectedShape.getY() + selectedShape.getHight() / 2) - 5, 10, 10);
                    System.Drawing.Rectangle right  = new System.Drawing.Rectangle(selectedShape.getX() + selectedShape.getWidth() + 5, (selectedShape.getY() + selectedShape.getHight() / 2) - 5, 10, 10);
                    System.Drawing.Rectangle bottom = new System.Drawing.Rectangle((selectedShape.getX() + selectedShape.getWidth() / 2) - 5, selectedShape.getY() + selectedShape.getHight() + 5, 10, 10);

                    if (mouse.IntersectsWith(top))
                    {
                        isResizeing = true;
                        IsMovieng   = false;
                        resize      = "top";
                    }
                    else if (mouse.IntersectsWith(left))
                    {
                        isResizeing = true;
                        IsMovieng   = false;
                        resize      = "left";
                    }
                    else if (mouse.IntersectsWith(right))
                    {
                        isResizeing = true;
                        IsMovieng   = false;
                        resize      = "right";
                    }
                    else if (mouse.IntersectsWith(bottom))
                    {
                        isResizeing = true;
                        IsMovieng   = false;
                        resize      = "bottom";
                    }
                }
            }
        }
Exemplo n.º 4
0
        private void EnemyMMTimerCallback(IntPtr pWhat, bool success)
        {
            if (!_enemyOnScreen)
            {
                return;
            }

            if (!_enemyHiResTimer.ExecutingCallback())
            {
                Console.WriteLine("Aborting timer callback.");
                return;
            }

            if (EnemyCanvasTop < _windowHeight)
            {
                EnemyCanvasTop += _enemySpeed;
            }

            if (_enemyRectangle.IntersectsWith(_bulletRectangle) &&
                BulletVisibility == System.Windows.Visibility.Visible &&
                EnemyVisibility == System.Windows.Visibility.Visible)
            {
                EnemyVisibility  = System.Windows.Visibility.Hidden;
                BulletVisibility = System.Windows.Visibility.Hidden;
                Points          += 1;
                (new System.Media.SoundPlayer("../../sounds/death.wav")).Play();
                setEnemyStartPos();
            }

            if ((_enemyRectangle.IntersectsWith(_paddleRectangle) ||
                 EnemyCanvasTop >= _windowHeight) &&
                EnemyVisibility == System.Windows.Visibility.Visible)
            {
                EnemyVisibility = System.Windows.Visibility.Hidden;
                Gameover();
            }

            _enemyRectangle = new System.Drawing.Rectangle((int)EnemyCanvasLeft, (int)EnemyCanvasTop, (int)EnemyWidth, (int)EnemyHeight);

            try
            {
                _enemyHiResTimer.DoneExecutingCallback();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Exemplo n.º 5
0
        private bool CheckRectangle(Rectangle rectangle)
        {
            bool isCoordinatesNotIntersect = true;

            //получить координаты всех областей для текущего изображения
            List <Rectangle> rectangles = DB.GetAllHighlightedObjectsAsRectangle(this.imageNameList.SelectedIndex);

            //проверить координаты в цикле, пока не найдем пересечение
            if (rectangles.Count != 0)
            {
                //масштабируем rectangle к реальным размерам image.BackgroundImage
                float     xScale = (float)SystemInformation.VirtualScreen.Width / (float)image.Width;
                float     yScale = (float)SystemInformation.VirtualScreen.Height / (float)image.Height;
                Rectangle rec    = ScaleRectangle(rectangle, xScale, yScale);

                int i = 0;
                while (isCoordinatesNotIntersect && i < rectangles.Count)
                {
                    isCoordinatesNotIntersect = !rec.IntersectsWith(rectangles[i]);

                    i++;
                }
            }

            return(isCoordinatesNotIntersect);
        }
Exemplo n.º 6
0
        public bool checkLeft(MouseEventArgs mouse)
        {
            var rect1 = new System.Drawing.Rectangle((x - 10), (y + higth / 2 - 10), 50, 50);
            var rect2 = new System.Drawing.Rectangle(mouse.X, mouse.Y, 10, 10);

            return(rect1.IntersectsWith(rect2));
        }
Exemplo n.º 7
0
        public bool checkIntract(MouseEventArgs mouse)
        {
            var rect1 = new System.Drawing.Rectangle(this.x, this.y, this.width, this.higth);
            var rect2 = new System.Drawing.Rectangle(mouse.X, mouse.Y, 10, 10);

            return(rect1.IntersectsWith(rect2));
        }
Exemplo n.º 8
0
        public Direction? CharacterCollision(Rectangle entity, Rectangle anotherEntity)
        {
            // check if collision happened
            if (!entity.IntersectsWith(anotherEntity))
                return null;

            // get diagonals through anotherEntity
            Point center = new Point((entity.Right + entity.Left) / 2, (entity.Bottom + entity.Top) / 2);
            //Line a
            Point a1 = new Point(anotherEntity.Left, anotherEntity.Top);
            Point a2 = new Point(anotherEntity.Right, anotherEntity.Bottom);

            //Line b
            Point b1 = new Point(anotherEntity.Left, anotherEntity.Bottom);
            Point b2 = new Point(anotherEntity.Right, anotherEntity.Top);

            var abovea1 = !isLeft(center, a1, a2);
            var abovea2 = !isLeft(center, b1, b2);

            if (abovea1 && abovea2)
                return Direction.up;
            else if (abovea1 && !abovea2)
                return Direction.right;
            else if (!abovea1 && abovea2)
                return Direction.left;
            else
                return Direction.down;
        }
Exemplo n.º 9
0
        /// <summary>
        /// Draws the end node
        /// </summary>
        /// <param name="g">The graphics to draw the node with</param>
        /// <param name="f">The font to use</param>
        /// <param name="viewportRect">The viewport bounds</param>
        /// <param name="isSelected">The node selection state</param>
        protected internal override void Draw(System.Drawing.Graphics g, System.Drawing.Font f, System.Drawing.Rectangle viewportRect, bool isSelected)
        {
            Rectangle area      = Area;
            Rectangle innerArea = area;

            innerArea.Inflate(-5, -5);

            // if it is (partly) visible
            if (viewportRect.IntersectsWith(area))
            {
                Brush br;
                Pen   p;
                if (isSelected)
                {
                    br = Brushes.Red;
                    p  = Pens.Red;
                }
                else
                {
                    br = Brushes.Black;
                    p  = Pens.Black;
                }

                // draw outer ellipse
                g.DrawEllipse(p, area);

                // draw inner ellipse
                g.FillEllipse(br, innerArea);
            }
        }
Exemplo n.º 10
0
        public bool checkSnap()
        {
            var rect1 = new System.Drawing.Rectangle(xPath1 + 100, yPath1 + 100, 100, 100);
            var rect2 = new System.Drawing.Rectangle(xPath2 + 100, yPath2, 100, 100);

            return(rect1.IntersectsWith(rect2));
        }
Exemplo n.º 11
0
 //击中敌机
 public void shootEnemy(Graphics g, List<Bullet> bulletList, List<Enemy> enemyList, Player player)
 {
     for (int i = 0; i < bulletList.Count; i++)
     {
         //创建子弹的矩形变量
         Rectangle bues = new Rectangle(bulletList[i].BulX, bulletList[i].BulY, bulletList[i].BulletImage.Width, bulletList[i].BulletImage.Height);
         for (int j = 0; j < enemyList.Count; j++)
         {
             //创建敌机矩形变量
             Rectangle emes = new Rectangle(enemyList[j].ENEMY_X, enemyList[j].ENEMY_Y, enemyList[j].PLANE.Width, enemyList[j].PLANE.Height);
             if (emes.IntersectsWith(bues))//敌机碰撞测试
             {
                 bulletList.Remove(bulletList[i]);
                 if (1 == enemyList[j].Blood)//判断敌机血量是否会减为0
                 {
                     player.ChangeScore(enemyList[j].Score);
                     Bomb bomb = new Bomb(enemyList[j].ENEMY_X, enemyList[j].ENEMY_Y);
                     enemyList.Remove(enemyList[j]);
                     bomb.Draw(g);//画出爆炸效果
                     bomb.bombplay();//音效效果
                 }
                 else
                 {
                     enemyList[j].Blood = enemyList[j].Blood - 1;
                 }
             }
         }
     }
 }
Exemplo n.º 12
0
		public override void Paint(Graphics g, Rectangle rect)
		{
			if (rect.Width <= 0 || rect.Height <= 0) {
				return;
			}
			HighlightColor lineNumberPainterColor = textArea.Document.HighlightingStrategy.GetColorFor("LineNumbers");
			int fontHeight = textArea.TextView.FontHeight;
			Brush fillBrush = textArea.Enabled ? BrushRegistry.GetBrush(lineNumberPainterColor.BackgroundColor) : SystemBrushes.InactiveBorder;
			Brush drawBrush = BrushRegistry.GetBrush(lineNumberPainterColor.Color);
			for (int y = 0; y < (DrawingPosition.Height + textArea.TextView.VisibleLineDrawingRemainder) / fontHeight + 1; ++y) {
				int ypos = drawingPosition.Y + fontHeight * y  - textArea.TextView.VisibleLineDrawingRemainder;
				Rectangle backgroundRectangle = new Rectangle(drawingPosition.X, ypos, drawingPosition.Width, fontHeight);
				if (rect.IntersectsWith(backgroundRectangle)) {
					g.FillRectangle(fillBrush, backgroundRectangle);
					int curLine = textArea.Document.GetFirstLogicalLine(textArea.Document.GetVisibleLine(textArea.TextView.FirstVisibleLine) + y);
					
					if (curLine < textArea.Document.TotalNumberOfLines) {
						g.DrawString((curLine + 1).ToString(),
						             lineNumberPainterColor.GetFont(TextEditorProperties.FontContainer),
						             drawBrush,
						             backgroundRectangle,
						             numberStringFormat);
					}
				}
			}
		}
Exemplo n.º 13
0
        /* Checks whether this window is overlapping this object
         * if it is, and it's not our playing window, we need to hide ourselves */
        public virtual void CheckForWindowOverlay(String windowTitle, Rectangle windowRect)
        {
            if (windowTitle == this.Text) return;

            // Proceed only if this is not our table window and the hud is visible
            if (windowTitle != table.WindowTitle)
            {
                Rectangle ourRect = this.RectangleToScreen(this.ClientRectangle);

                if (windowRect.IntersectsWith(ourRect))
                {
                    Visible = false;
                }
                else
                {
                    Visible = true;
                }
            }

            // If the window is the our table window, make sure we are displaying it!
            else if (windowTitle == table.WindowTitle)
            {
                Visible = true;
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Thread A
        /// </summary>
        ///
        void ThreadAFunction()
        {
            try
            {
                while (_isThreadARunning)
                {
                    Thread.Sleep(2);
                    //if (_threadAIsSuspended) continue;

                    // below are all the things this thread needs to do
                    if (!_moveBall)
                    {
                        continue;
                    }

                    ballCanvasLeft += _ballXMove;
                    ballCanvasTop  += _ballYMove;

                    // check to see if ball has it the left or right side of the drawing element
                    if ((ballCanvasLeft + BallWidth >= _windowWidth) ||
                        (ballCanvasLeft <= 0))
                    {
                        _ballXMove = -_ballXMove;
                    }


                    // check to see if ball has it the top of the drawing element
                    if (ballCanvasTop <= 0)
                    {
                        _ballYMove = -_ballYMove;
                    }

                    if (ballCanvasTop + BallWidth >= _windowHeight)
                    {
                        // we hit bottom. stop moving the ball
                        _moveBall = false;
                    }

                    // see if we hit the paddle
                    _ballRectangle = new System.Drawing.Rectangle((int)ballCanvasLeft, (int)ballCanvasTop, (int)BallWidth, (int)BallHeight);
                    if (_ballRectangle.IntersectsWith(_paddleRectangle))
                    {
                        // hit paddle. reverse direction in Y direction
                        _ballYMove = -_ballYMove;

                        // move the ball away from the paddle so we don't intersect next time around and
                        // get stick in a loop where the ball is bouncing repeatedly on the paddle
                        ballCanvasTop += 2 * _ballYMove;

                        // add move the ball in X some small random value so that ball is not traveling in the same
                        // pattern
                        ballCanvasLeft += _randomNumber.Next(5);
                    }
                }
            }
            catch (ThreadAbortException)
            {
                Debug.Write("Thread A Aborted\n");
            }
        }
Exemplo n.º 15
0
        public void Removedirt( Player speler,Level level)
        {
            Rectangle onder = new Rectangle(speler.Position.X+10, speler.Position.Y + 50, 45, 4);
             Rectangle left = new Rectangle(speler.Position.X, speler.Position.Y + 10, 4, 35);
             if (speler.down == true && onder.IntersectsWith(level.SaveColDirt.Rect))
            {
             if(level.SaveColDirt.ID!=5)
             {
                 level.dirtobject.Remove(level.SaveColDirt);
                 saveLeeg = copyEigenschappen(level.SaveColDirt);
                 level.leegObject.Add(saveLeeg);
                 speler.MaxY = 600;
                 speler.MaxX = 750;
                 speler.MinX = 0;
                 score += level.SaveColDirt.ID * 10;
                 foreach (Dirt g in level.dirtobject)
                 {
                     g.Update();
                 }
                 foreach(Leeg L in level.leegObject)
                 {
                     L.Update();
                 }
                 level.SaveColDirt = new Dirt();
             }

            }
        }
Exemplo n.º 16
0
		public override void Paint(Graphics g, Rectangle rect)
		{
			if (rect.Width <= 0 || rect.Height <= 0) {
				return;
			}
			HighlightColor lineNumberPainterColor = textArea.Document.HighlightingStrategy.GetColorFor("LineNumbers");
			HighlightColor foldLineColor          = textArea.Document.HighlightingStrategy.GetColorFor("FoldLine");
			
			
			for (int y = 0; y < (DrawingPosition.Height + textArea.TextView.VisibleLineDrawingRemainder) / textArea.TextView.FontHeight + 1; ++y) {
				Rectangle markerRectangle = new Rectangle(DrawingPosition.X,
				                                          DrawingPosition.Top + y * textArea.TextView.FontHeight - textArea.TextView.VisibleLineDrawingRemainder,
				                                          DrawingPosition.Width,
				                                          textArea.TextView.FontHeight);
				
				if (rect.IntersectsWith(markerRectangle)) {
					// draw dotted separator line
					if (textArea.Document.TextEditorProperties.ShowLineNumbers) {
						g.FillRectangle(BrushRegistry.GetBrush(textArea.Enabled ? lineNumberPainterColor.BackgroundColor : SystemColors.InactiveBorder),
						                new Rectangle(markerRectangle.X + 1, markerRectangle.Y, markerRectangle.Width - 1, markerRectangle.Height));
						
						g.DrawLine(BrushRegistry.GetDotPen(lineNumberPainterColor.Color, lineNumberPainterColor.BackgroundColor),
						           base.drawingPosition.X,
						           markerRectangle.Y,
						           base.drawingPosition.X,
						           markerRectangle.Bottom);
					} else {
						g.FillRectangle(BrushRegistry.GetBrush(textArea.Enabled ? lineNumberPainterColor.BackgroundColor : SystemColors.InactiveBorder), markerRectangle);
					}
					
					int currentLine = textArea.Document.GetFirstLogicalLine(textArea.Document.GetVisibleLine(textArea.TextView.FirstVisibleLine) + y);
					PaintFoldMarker(g, currentLine, markerRectangle);
				}
			}
		}
        /// <summary>
        /// Draws the container node
        /// </summary>
        /// <param name="g">The graphics to use</param>
        /// <param name="font">The font to draw the text with</param>
        /// <param name="viewportRect">The viewport bounds</param>
        /// <param name="isSelected">True if the node is selected</param>
        protected internal override void Draw(System.Drawing.Graphics g, System.Drawing.Font font, System.Drawing.Rectangle viewportRect, bool isSelected)
        {
            Rectangle area = Area;

            if (viewportRect.IntersectsWith(area))
            {
                // draw the background
                using (LinearGradientBrush br = new LinearGradientBrush(area, Color.FromArgb(240, 240, 240), Color.FromArgb(200, 200, 200), LinearGradientMode.Vertical))
                    g.FillRectangle(br, area);

                // draw the border
                if (isSelected)
                {
                    g.DrawRectangle(Pens.Red, area);
                }
                else
                {
                    g.DrawRectangle(Pens.Black, area);
                }

                // draw the text as title
                g.DrawString((Text + ""), font, Brushes.Black, new RectangleF(area.Left, area.Top, area.Width, paddingForText), new StringFormat()
                {
                    Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center
                });

                // draw the line under the title
                g.DrawLine(Pens.Black, new Point(area.Left, area.Top + paddingForText), new Point(area.Right, area.Top + paddingForText));
            }
        }
Exemplo n.º 18
0
 private void validateIntersection(Slide slide, IList<JupiterWindow> list)
 {
     for (int i = 0; i < list.Count - 1; i++)
     {
         for (int j = i + 1; j < list.Count; j++)
         {
             Window current = list[i];
             Window other = list[j];
             Rectangle rect1 = new Rectangle(current.Left, current.Top, current.Width, current.Height);
             Rectangle rect2 = new Rectangle(other.Left, other.Top, other.Width, other.Height);
             string currentResourceInfoName = current.Source.ResourceDescriptor == null
                                                  ? string.Empty
                                                  : current.Source.ResourceDescriptor.ResourceInfo.Name;
             string otherResourceInfoName = other.Source.ResourceDescriptor == null
                              ? string.Empty
                              : other.Source.ResourceDescriptor.ResourceInfo.Name;
             if (rect1.IntersectsWith(rect2))
                 throw new Exception(String.Concat(
                     "Сохранение сцены ",
                     slide.Name,
                     " невозможно. На раскладке сцены окна с источниками ",
                     currentResourceInfoName,
                     " и ",
                     otherResourceInfoName,
                     " не должны перекрываться между собой"));
         }
     }
 }
Exemplo n.º 19
0
        public void Arrange(IExportColumn exportColumn)
        {
            if (exportColumn == null)
                throw new ArgumentNullException("exportColumn");
            var container = exportColumn as IExportContainer;
            if ((container != null) && (container.ExportedItems.Any())) {
                List<IExportColumn> canGrowItems = CreateCanGrowList(container);
                if (canGrowItems.Any()) {
                    var containerSize = ArrangeInternal(container);
                    if (containerSize.Height > container.DesiredSize.Height) {
                        container.DesiredSize = new Size(containerSize.Width,containerSize.Height + 15);
                    }
                }
            }

            var fixedElements = container.ExportedItems.Where(x => !x.CanGrow);
            var growables = container.ExportedItems.Where(x => x.CanGrow);

            foreach (var growable in growables) {
                var r = new Rectangle(growable.Location,growable.DesiredSize);
                foreach (var x in fixedElements) {
                    var xr = new Rectangle(x.Location,x.DesiredSize);
                    if (r.IntersectsWith(xr)) {
                        x.Location = new Point(x.Location.X, r.Bottom + 5);
                    }
                }
            }
        }
Exemplo n.º 20
0
        public IEnumerable <System.Drawing.Rectangle> iterPreventRects()
        {
            var transform = new System.Drawing.Drawing2D.Matrix();
            var pts       = new System.Drawing.Point[1];

            int   circleCount = 16;
            float angleDelta  = 360 / circleCount;
            float angle       = 0;

            for (int i = 0; i < circleCount; ++i)
            {
                transform.Reset();
                transform.Rotate(angle);

                pts[0] = new System.Drawing.Point(0, 96);

                transform.TransformPoints(pts);

                var pt = pts[0];

                var hitRect = new System.Drawing.Rectangle(this.x + pt.X - 48, this.y + pt.Y - 48, 96, 96);
                // bool isCollision = _gamePlay.scene.hitTestCollision(snake.headPreventCollisionRect);

                //Console.WriteLine("{0} Prevent angle={1} hit={2}", snake, angle, isCollision);

                if (_headPreventCollisionRect.IntersectsWith(hitRect) == false)
                {
                    yield return(hitRect);
                }



                angle += angleDelta;
            }
        }
Exemplo n.º 21
0
        private void BallMMTimerCallback(IntPtr pWhat, bool success)
        {
            if (!_moveBall)
            {
                return;
            }

            // start executing callback. this ensures we are synched correctly
            // if the form is abruptly closed
            // if this function returns false, we should exit the callback immediately
            // this means we did not get the mutex, and the timer is being deleted.
            if (!_ballHiResTimer.ExecutingCallback())
            {
                Console.WriteLine("Aborting timer callback.");
                return;
            }

            BallCanvasLeft += _ballXMove;
            BallCanvasTop  += _ballYMove;

            // check to see if ball has it the left or right side of the drawing element
            if ((BallCanvasLeft + BallWidth >= _windowWidth) ||
                (BallCanvasLeft <= 0))
            {
                _ballXMove = -_ballXMove;
            }


            // check to see if ball has it the top of the drawing element
            if (BallCanvasTop <= 0)
            {
                _ballYMove = -_ballYMove;
            }

            if (BallCanvasTop + BallWidth >= _windowHeight)
            {
                // we hit bottom. stop moving the ball
                _moveBall = false;
            }

            // see if we hit the paddle
            _ballRectangle = new System.Drawing.Rectangle((int)BallCanvasLeft, (int)BallCanvasTop, (int)BallWidth, (int)BallHeight);
            if (_ballRectangle.IntersectsWith(_paddelRectangle))
            {
                // hit paddle. reverse direction in Y direction
                _ballYMove = -_ballYMove;

                // move the ball away from the paddle so we don't intersect next time around and
                // get stick in a loop where the ball is bouncing repeatedly on the paddle
                BallCanvasTop += 2 * _ballYMove;

                // add move the ball in X some small random value so that ball is not traveling in the same
                // pattern
                BallCanvasLeft += _randomNumber.Next(5);
            }

            // done in callback. OK to delete timer
            _ballHiResTimer.DoneExecutingCallback();
        }
Exemplo n.º 22
0
 // added a small amount of allowed overlap so that
 // printing can always find a page break
 public override bool contains(System.Drawing.Rectangle rec)
 {
     System.Drawing.Rectangle my_rec =
         new System.Drawing.Rectangle(
             X - this.Diamond_Width() / 2 + 2, Y,
             this.Diamond_Width() - 4, H);
     return(rec.IntersectsWith(my_rec));
 }
Exemplo n.º 23
0
        public void caretHit(Rectangle caretRect)
        {
            if (caretRect.IntersectsWith(_rect))
            {
                speedY *= -1;

            }
        }
Exemplo n.º 24
0
        public static bool checkCollision(PictureBox collider, int x, int y, List<Rectangle> listObj)
        {
            Rectangle frame = new Rectangle(x, y, collider.Width, collider.Height);

            foreach (Rectangle obj in listObj)
                if (frame.IntersectsWith(obj))
                    return false;
            return true;
        }
Exemplo n.º 25
0
        public void Euler() //TODO Метод Euler как-то неправильно конструирует уровни. Быть может, слишком высока вероятность бракованного уровня?
        {
            int oddNumber = 0;

            List <GameElements.Stuff.ScenicObject> allDoorsNew = new List <GameElements.Stuff.ScenicObject>();

            allDoorsNew.AddRange(allDoors);

            Core.generateDoors(allDoors);
            Random rnd = new Random();
            int    r   = rnd.Next(101);

            foreach (GameElements.Stuff.BeautifulSquare sq in allRooms)
            {
                System.Drawing.Rectangle sqBounds = new System.Drawing.Rectangle(sq.posX1, sq.posY1, sq.posX2 - sq.posX1, sq.posY2 - sq.posY1);
                int power = 0;
                foreach (GameElements.Stuff.ScenicObject obct in allObjects)
                {
                    if (obct.image != Zamki.Properties.Resources.door_ultima)
                    {
                        if (sqBounds.IntersectsWith(new System.Drawing.Rectangle(obct.X, obct.Y, obct.Width, obct.Height)))
                        {
                            power++;
                        }
                    }
                }
                if (power % 2 != 0)
                {
                    allDoorsNew.Clear();
                    oddNumber++;
                }
            }
            if (oddNumber > 6) // Проблема с невидимыми полами-выходами
            {
                if (allDoorsNew.Count() < 10)
                {
                    //if (r > 10)
                    if (r > 0)
                    {
                        Euler();
                    }
                }
                else
                if (oddNumber > 10)
                {
                    //if (r > 10)
                    if (r > 0)
                    {
                        Euler();
                    }
                }
            }
            else
            {
                allObjects.AddRange(allDoors);
            }
        }
Exemplo n.º 26
0
        public void visibleTestWithRect(System.Drawing.Rectangle viewportRect)
        {
            int visibleCount = 0;

            var t1 = DateTime.Now;

            for (int i = 0; i < foods.children.Count; ++i)
            {
                var food = foods.children[i];

                var drawBounds = food.drawBounds;
                drawBounds.X += food.x;
                drawBounds.Y += food.y;
                // Console.WriteLine("{0} drawBounds={1}", food, drawBounds);
                if (viewportRect.IntersectsWith(drawBounds))
                {
                    food.visible = true;
                    visibleCount++;
                }
                else
                {
                    food.visible = false;
                }
            }

            var delta = DateTime.Now - t1;

            for (int i = 0; i < _playerContainer.children.Count; ++i)
            {
                var snake = (SnakeSprite)_playerContainer.children[i];

                var drawBounds = snake.calcHitBounds();
                if (viewportRect.IntersectsWith(drawBounds))
                {
                    snake.visible = true;
                }
                else
                {
                    snake.visible = false;
                }
            }

            //Console.WriteLine("food {0} visibleCount={1}/{2}", delta, visibleCount, _scene.foods.children.Count);
        }
Exemplo n.º 27
0
 public bool IsIntersectingRect(Rectangle rect)
 {
     foreach(BodyPart Part in m_SnakeParts)
     {
         Point PartPos = Part.GetPosition();
         if (rect.IntersectsWith(new Rectangle(PartPos.X, PartPos.Y, m_CircleRadius, m_CircleRadius)))
             return true;
     }
     return false;
 }
Exemplo n.º 28
0
 void timer_Elapsed(object sender, ElapsedEventArgs e)
 {
     if (NativeHelpers.ActiveApplTitle().Contains(appTitleToDisableOn))
     {
         var position = Cursor.Position;
         var rectangle = new Rectangle(position, new Size(1, 1));
         if (!rectangle.IntersectsWith(dockRootForm.Bounds))
             Cursor.Position = dockRootForm.Location;
     }
 }
Exemplo n.º 29
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="x1"></param>
 /// <param name="y1"></param>
 /// <param name="w1"></param>
 /// <param name="h1"></param>
 /// <param name="x2"></param>
 /// <param name="y2"></param>
 /// <param name="w2"></param>
 /// <param name="h2"></param>
 /// <returns></returns>
 public static bool RectsIntersect(int x1, int y1, int w1, int h1,
                                   int x2, int y2, int w2, int h2)
 {
     Rectangle rect = new Rectangle(x1, y1, w1, h1);
     Rectangle rect2 = new Rectangle(x2, y2, w2, h2);
     return rect.IntersectsWith(rect2);
     //if (x1 >= (x2 + w2) || (x1 + w1) <= x2) return false;
     //if (y1 >= (y2 + h2) || (y1 + h1) <= y2) return false;
     //return true;
 }
Exemplo n.º 30
0
        public static bool checkCollision()
        {
            Rectangle hBox = new Rectangle((int)Player.sprite.Position.X - 10, (int)Player.sprite.Position.Y - 30, 70, 100);
            Rectangle hBoxS1 = new Rectangle((int)Schaf1.sprite.Position.X + 20, (int)Schaf1.sprite.Position.Y, 35, 70);
            Rectangle hBoxS2 = new Rectangle((int)Schaf2.sprite.Position.X + 20, (int)Schaf2.sprite.Position.Y, 35, 70);
            // fix all sheeps in edge problem
            if (hBoxS1.IntersectsWith(hBoxS2))
                Schaf1.sprite.Position = new Vector2f(Schaf1.sprite.Position.X - 30, Schaf1.sprite.Position.Y);

            if (hBox.IntersectsWith(hBoxS1)||hBox.IntersectsWith(hBoxS2))
                {
                    Console.WriteLine("Game Over");
                    Console.WriteLine("You survived " + watch.Elapsed.Minutes +" minutes "+ watch.Elapsed.Seconds + " seconds " + watch.Elapsed.Milliseconds + " milliseconds");
                    Console.WriteLine("Press 'n' to restart or 'Esc' to close the game");
                    return true;
                }

            return false;
        }
Exemplo n.º 31
0
 // Ensure that the proposed window position intersects
 // at least one screen area.
 private static bool IsVisiblePosition(Point location, Size size)
 {
     Rectangle myArea = new Rectangle(location, size);
     bool intersect = false;
     foreach (System.Windows.Forms.Screen screen in System.Windows.Forms.Screen.AllScreens)
     {
         intersect |= myArea.IntersectsWith(screen.WorkingArea);
     }
     return intersect;
 }
Exemplo n.º 32
0
        protected override void OnPaint(PaintEventArgs e)
        {
            if (Parent != null)
            {
                float
                    tx = -Left,
                    ty = -Top;

                // make adjustments to tx and ty here if your control
                // has a non-client area, borders or similar

                e.Graphics.TranslateTransform(tx, ty);

                using (PaintEventArgs pea = new PaintEventArgs(e.Graphics, e.ClipRectangle))
                {
                    InvokePaintBackground(Parent, pea);
                    InvokePaint(Parent, pea);
                }

                e.Graphics.TranslateTransform(-tx, -ty);

                // loop through children of parent which are under ourselves
                int start = Parent.Controls.GetChildIndex(this);
                Rectangle rect = new Rectangle(Left, Top, Width, Height);
                for (int i = Parent.Controls.Count - 1; i > start; i--)
                {
                    Control c = Parent.Controls[i];

                    // skip ...
                    // ... invisible controls
                    // ... or controls that have zero width/height (Autosize Labels without content!)
                    // ... or controls that don't intersect with ourselves
                    if (!c.Visible || c.Width == 0 || c.Height == 0 || !rect.IntersectsWith(new Rectangle(c.Left, c.Top, c.Width, c.Height)))
                        continue;

                    using (Bitmap b = new Bitmap(c.Width, c.Height, e.Graphics))
                    {
                        c.DrawToBitmap(b, new Rectangle(0, 0, c.Width, c.Height));

                        tx = c.Left - Left;
                        ty = c.Top - Top;

                        // make adjustments to tx and ty here if your control
                        // has a non-client area, borders or similar

                        e.Graphics.TranslateTransform(tx, ty);
                        e.Graphics.DrawImageUnscaled(b, new Point(0, 0));
                        e.Graphics.TranslateTransform(-tx, -ty);
                    }
                }
            }
            for (int i = 5; i < 90; i += 10)
                e.Graphics.DrawEllipse(new Pen(Brushes.Red, 2), (this.Width / 2) - i / 2, (this.Width / 2) - i / 2, i, i);
            //e.Graphics.DrawEllipse(new Pen(new SolidBrush(this.Color), 5), 5, 5, 90, 90);
        }
Exemplo n.º 33
0
 public static bool RectangleInRectangle(System.Drawing.Rectangle rec, System.Drawing.Rectangle rec2)
 {
     if (rec.IntersectsWith(rec2) == true)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 34
0
        // added a small amount of allowed overlap so that
        // printing can always find a page break
        public override bool contains(System.Drawing.Rectangle rec)
        {
            int Diamond_bottom = diamond_top;

            System.Drawing.Rectangle my_rec;
            if (!Component.USMA_mode)
            {
                my_rec = new System.Drawing.Rectangle(X - W / 2 + 2, Y, W - 4, H);
            }
            else
            {
                my_rec = new System.Drawing.Rectangle(X - W / 8 + 1, Y, W / 4 - 2, H);
            }
            System.Drawing.Rectangle my_rec2 =
                new System.Drawing.Rectangle(
                    X - this.Diamond_Width() / 2 + 2,
                    Diamond_bottom,
                    this.Diamond_Width() - 4, H);
            return(rec.IntersectsWith(my_rec) || rec.IntersectsWith(my_rec2));
        }
Exemplo n.º 35
0
 private void MapPBox_MouseClick(object sender, MouseEventArgs e)
 {
     
     int index = 0;
     int tempX;
     int tempY;
     Rectangle tempRect = new Rectangle();
     foreach (FootHold.Foothold foothold in Footholds)
     {
         tempX= (int)(Footholds.ToArray()[index].Shape.X * scale);
         tempY= (int)(Footholds.ToArray()[index].Shape.Y * scale);
         tempRect = new Rectangle(tempX, tempY,(int)( foothold.Shape.Width * scale),(int) (foothold.Shape.Height * scale));
         if (tempRect.IntersectsWith(new Rectangle(e.X, e.Y, 1, 1)))
         {
             Edit editFoothold = new Edit();
             editFoothold.Text = "Foothold: "+ foothold.Data.Name;
             editFoothold.fh = Footholds.ToArray()[index];
             editFoothold.settings = settings;
             editFoothold.ShowDialog();
         }
         index++;
     }
     index = 0;
     foreach (Portals.Portal portal in thePortals)
     {
         tempX = (int)(thePortals.ToArray()[index].Shape.X * scale);
         tempY = (int)(thePortals.ToArray()[index].Shape.Y * scale);
         tempRect = new Rectangle(tempX, tempY, (int)(portal.Shape.Width * scale), (int)(portal.Shape.Height * scale));
         if (tempRect.IntersectsWith(new Rectangle(e.X, e.Y, 1, 1)))
         {
             EditPortals editPortals = new EditPortals();
             editPortals.Text = "Portal: " + portal.Data.Name;
             editPortals.portal = thePortals.ToArray()[index];
             editPortals.Settings = settings;
             editPortals.ShowDialog();
         }
         index++;
     }
     index = 0;
     foreach (SpawnPoint.Spawnpoint spawnpoint in MobSpawnPoints)
     {
         tempX = (int)(MobSpawnPoints.ToArray()[index].Shape.X * scale);
         tempY = (int)(MobSpawnPoints.ToArray()[index].Shape.Y * scale);
         tempRect = new Rectangle(tempX, tempY, (int)(spawnpoint.Shape.Width * scale), (int)(spawnpoint.Shape.Height * scale));
         if (tempRect.IntersectsWith(new Rectangle(e.X, e.Y, 1, 1)))
         {
             SpawnpointInfo spawnInfo = new SpawnpointInfo();
             spawnInfo.spawnpoint = spawnpoint;
             spawnInfo.Text = "Mob spawnpoint: " + spawnpoint.Data.Name;
             spawnInfo.ShowDialog();
         }
         index++;
     }
 }
Exemplo n.º 36
0
        public bool collidePlayer(arcanoid player)
        {
            Rectangle r1 = new Rectangle(player.x, player.y, player.size.Width, player.size.Height);
            Rectangle r2 = new Rectangle((int)x, (int)y, size.Width, size.Height);

            if(r1.IntersectsWith(r2))
            {
                return true;
            }

            return false;
        }
Exemplo n.º 37
0
        private InterectSide IntersectsAt(Rectangle brick, Rectangle ball)
        {
            if (brick.IntersectsWith(ball) == false)
            {
                return(InterectSide.NONE);
            }

            Rectangle r = Rectangle.Intersect(brick, ball);

            _ballRectangle = new System.Drawing.Rectangle((int)ballCanvasLeft, (int)ballCanvasTop, (int)BallWidth, (int)BallHeight);

            if (_ballRectangle.IntersectsWith(r))
            {
                // hit paddle. reverse direction in Y direction
                _ballYMove = -_ballYMove;

                // move the ball away from the paddle so we don't intersect next time around and
                // get stick in a loop where the ball is bouncing repeatedly on the paddle
                ballCanvasTop += 2 * _ballYMove;

                // add move the ball in X some small random value so that ball is not traveling in the same
                // pattern
                ballCanvasLeft += _randomNumber.Next(5);
            }

            // did we hit the top of the brick
            if (ball.Top + ball.Height - 1 == r.Top &&
                r.Height == 1)
            {
                return(InterectSide.TOP);
            }

            if (ball.Top == r.Top &&
                r.Height == 1)
            {
                return(InterectSide.BOTTOM);
            }

            if (ball.Left == r.Left &&
                r.Width == 1)
            {
                return(InterectSide.RIGHT);
            }

            if (ball.Left + ball.Width - 1 == r.Left &&
                r.Width == 1)
            {
                return(InterectSide.LEFT);
            }

            return(InterectSide.NONE);
        }
        private List<Character> getCharactersInRectangle(Rectangle rectangle)
        {
            List<Character> ret = new List<Character>();

            foreach (Character ch in this.selectableCharacters)
            {
                Rectangle characterRectangle = ch.BoundingCylinder.projectToScreen();
                if (rectangle.IntersectsWith(characterRectangle))
                    ret.Add(ch);
            }

            return ret;
        }
Exemplo n.º 39
0
        private bool HasColision(Rectangle rect)
        {
            foreach (PictureBox wall in this._wallsList)
            {
                if (rect.IntersectsWith(wall.Bounds))
                {
                    return true;
                }
            }
            this.player.Bounds = rect;

            return false;
        }
Exemplo n.º 40
0
		public override void Paint(Graphics g, Rectangle rect)
		{
            try
            {
                if (rect.Width <= 0 || rect.Height <= 0)
                {
                    return;
                }
                HighlightColor lineNumberPainterColor = textArea.Document.HighlightingStrategy.GetColorFor("LineNumbers");


                for (int y = 0; y < (DrawingPosition.Height + textArea.TextView.VisibleLineDrawingRemainder) / textArea.TextView.FontHeight + 1; ++y)
                {
                    Rectangle markerRectangle = new Rectangle(DrawingPosition.X,
                                                              DrawingPosition.Top + y * textArea.TextView.FontHeight - textArea.TextView.VisibleLineDrawingRemainder,
                                                              DrawingPosition.Width,
                                                              textArea.TextView.FontHeight);

                    if (rect.IntersectsWith(markerRectangle))
                    {
                        // draw dotted separator line
                        if (textArea.Document.TextEditorProperties.ShowLineNumbers)
                        {
                            g.FillRectangle(BrushRegistry.GetBrush(textArea.Enabled ? lineNumberPainterColor.BackgroundColor : SystemColors.InactiveBorder),
                                            markerRectangle);

                            g.DrawLine(BrushRegistry.GetDotPen(lineNumberPainterColor.Color),
                                       base.drawingPosition.X,
                                       markerRectangle.Y,
                                       base.drawingPosition.X,
                                       markerRectangle.Bottom);
                        }
                        else
                        {
                            g.FillRectangle(BrushRegistry.GetBrush(textArea.Enabled ? lineNumberPainterColor.BackgroundColor : SystemColors.InactiveBorder), markerRectangle);
                        }

                        int currentLine = textArea.Document.GetFirstLogicalLine(textArea.TextView.FirstPhysicalLine + y);
                        if (currentLine < textArea.Document.TotalNumberOfLines)
                        {
                            PaintFoldMarker(g, currentLine, markerRectangle);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("in FoldMargin " + ex.Message);
            }
		}
Exemplo n.º 41
0
		// added a small amount of allowed overlap so that
		// printing can always find a page break
		public virtual bool contains(System.Drawing.Rectangle rec)
		{
			int box_width;
			if (this.drawing_text_width>W)
			{
				box_width = this.drawing_text_width;
			}
			else
			{
				box_width = W;
			}
			System.Drawing.Rectangle my_rec = new System.Drawing.Rectangle(X-box_width/2+2,Y,box_width-4,H);
			return rec.IntersectsWith(my_rec);
		}
Exemplo n.º 42
0
        public bool Collision(Bullet b)
        {
            System.Drawing.Rectangle missileRec = new System.Drawing.Rectangle((int)x, (int)y, (int)missileSize, (int)size);
            System.Drawing.Rectangle bulletRec  = new System.Drawing.Rectangle((int)b.x, (int)b.y, b.size, b.size);

            if (bulletRec.IntersectsWith(missileRec))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 43
0
        public bool collideBrick(brick brick)
        {
            if (brick.alive)
            {
                Rectangle r1 = new Rectangle(brick.x, brick.y, brick.size.Width, brick.size.Height);
                Rectangle r2 = new Rectangle((int)x, (int)y, size.Width, size.Height);

                if (r1.IntersectsWith(r2))
                {
                    return true;
                }
            }

            return false;
        }
Exemplo n.º 44
0
 public void getBloodBox(Graphics g, Player player, BloodBox box)
 {
     Rectangle plaRec = new Rectangle(player.PLANEX, player.PLANEY, player.Myplane.Width, player.Myplane.Height);
     Rectangle boxRec = new Rectangle(box.BoxX, box.BoxY, box.Box.Width, box.Box.Height);
     if (boxRec.IntersectsWith(plaRec) && player.ChangeBlood(0) && box.Exist)
     {
         player.ChangeBlood(20);
         box.getBox();
         box.Exist = false;
     }
     else
     {
         box.Draw(g);
     }
 }
Exemplo n.º 45
0
        public static GameObject checkCollision(System.Drawing.Rectangle rec1, GameObject go2)
        {
            System.Drawing.Rectangle rec2 = new System.Drawing.Rectangle(go2.X, go2.Y, go2.Width, go2.Height);

            bool result = rec1.IntersectsWith(rec2);

            if (result)
            {
                return(go2);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 46
0
 public void getSuperGun(Graphics g, Player player, SuperGun gun)
 {
     Rectangle plaRec = new Rectangle(player.PLANEX, player.PLANEY, player.Myplane.Width, player.Myplane.Height);
     Rectangle gunRec = new Rectangle(gun.GunX, gun.GunY, gun.Gun.Width, gun.Gun.Height);
     if (gunRec.IntersectsWith(plaRec))
     {
         player.getSuperGun();
         gun.getGun();
         gun.Exist = false;
     }
     else
     {
         gun.Draw(g);
     }
 }
Exemplo n.º 47
0
 /// <summary>
 /// returns true if the mouse pointer is inside the shape
 /// </summary>
 /// <param name="pPoint"></param>
 /// <returns></returns>
 public bool IsCollision(Point pPoint)
 {
     // determine type of collision
     /*
     * For now just see if there is any kind of collision
     * with the mouse cursor
     */
     Rectangle lrectCursorRect = new Rectangle(pPoint, new Size(2, 2));
     Rectangle region = new Rectangle(Location, new Size(40, 40));
     if (region.IntersectsWith(lrectCursorRect))
     {
         //this.Cursor = Cursors.SizeAll;
         return true;
     }
     return false;
 }
Exemplo n.º 48
0
 public void Remove(Rectangle rect)
 {
     for (int i = this.m_Count - 1; i >= 0; i--)
     {
         Rectangle rectangle = this.m_Rects[i];
         if (rect.IntersectsWith(rectangle))
         {
             this.InternalRemove(i);
             Rectangle[] rectangleArray = Punch(rectangle, rect);
             for (int j = 0; j < rectangleArray.Length; j++)
             {
                 this.InternalAdd(rectangleArray[j]);
             }
         }
     }
 }
Exemplo n.º 49
0
        private void BallTimerCallback(object state)
        {
            if (!_moveBall)
            {
                return;
            }

            BallCanvasLeft += _ballXMove;
            BallCanvasTop  += _ballYMove;

            // check to see if ball has it the left or right side of the drawing element
            if ((BallCanvasLeft + BallWidth >= _windowWidth) ||
                (BallCanvasLeft <= 0))
            {
                _ballXMove = -_ballXMove;
            }


            // check to see if ball has it the top of the drawing element
            if (BallCanvasTop <= 0)
            {
                _ballYMove = -_ballYMove;
            }

            if (BallCanvasTop + BallWidth >= _windowHeight)
            {
                // we hit bottom. stop moving the ball
                _moveBall = false;
            }

            // see if we hit the paddle
            _ballRectangle = new System.Drawing.Rectangle((int)BallCanvasLeft, (int)BallCanvasTop, (int)BallWidth, (int)BallHeight);
            if (_ballRectangle.IntersectsWith(_paddelRectangle))
            {
                // hit paddle. reverse direction in Y direction
                _ballYMove = -_ballYMove;

                // move the ball away from the paddle so we don't intersect next time around and
                // get stick in a loop where the ball is bouncing repeatedly on the paddle
                BallCanvasTop += 2 * _ballYMove;

                // move the ball in X some small random value so that ball is not traveling in the same
                // pattern
                BallCanvasLeft += _randomNumber.Next(5);
            }
        }
Exemplo n.º 50
0
 public void Add(Rectangle rect)
 {
     for (int i = 0; i < this.m_Count; i++)
     {
         Rectangle rectangle = this.m_Rects[i];
         if (rect.IntersectsWith(rectangle))
         {
             Rectangle[] rectangleArray = Punch(rect, rectangle);
             for (int j = 0; j < rectangleArray.Length; j++)
             {
                 this.Add(rectangleArray[j]);
             }
             return;
         }
     }
     this.InternalAdd(rect);
 }
        private void placeShapesInCanvasBoundary(Shape aShape)
        {
            aShape.X = ShapeFactory.Randomizer.Next(this.canvas.Width - aShape.Width);
            aShape.Y = ShapeFactory.Randomizer.Next(this.canvas.Height - aShape.Height);

            var aRectangle = new Rectangle(aShape.X, aShape.Y, aShape.Width, aShape.Height);

            foreach (Shape theShape in this.shapes)
            {
                var comparatorRectangle = new Rectangle(theShape.X, theShape.Y, theShape.Width, theShape.Height);

                if (aRectangle.IntersectsWith(comparatorRectangle))
                {
                    this.placeShapesInCanvasBoundary(aShape);
                }
            }
        }
Exemplo n.º 52
0
        private static bool h_collidedWith(BaseActor actor1, BaseActor actor2)
        {
            Rectangle rectangle1;
              {
            int actorX = (int) actor1.Position.X;
            int actorY = (int) actor1.Position.Y;
            rectangle1 = new Rectangle(actorX, actorY, actor1.Width, actor1.Height);
              }

              Rectangle rectangle2;
              {
            int actorX = (int) actor2.Position.X;
            int actorY = (int) actor2.Position.Y;
            rectangle2 = new Rectangle(actorX, actorY, actor2.Width, actor2.Height);
              }

              return rectangle1.IntersectsWith(rectangle2);
        }
Exemplo n.º 53
0
 //Move the Boss rcokets on the screen
 public void moveBossRocket()
 {
     for (int i = 0; i < bossRockets.Count; i++)
     {
         Rectangle roc = new Rectangle(bossRockets[i].getX(),bossRockets[i].getY(),bossRockets[i].getImage().Width, bossRockets[i].getImage().Height);
         Rectangle r1 = new Rectangle(playerPlane.getX(), playerPlane.getY(), playerPlane.getImage().Width, playerPlane.getImage().Height);
         if (roc.IntersectsWith(r1))
         {
             playerPlane.loseLife();
             bossRockets.Remove(bossRockets[i]);
         }
         else if (bossRockets[i].getY() > 780)
         {
             bossRockets.Remove(bossRockets[i]);
         }
         else bossRockets[i].moveRocket();
     }
 }
        /// <summary>
        ///     Shapeses the bounce off each other.
        /// </summary>
        public void ShapesBounceOffEachOther(Shape firstShape)
        {
            var firstRectangle = new Rectangle(firstShape.X, firstShape.Y, firstShape.Width + 2, firstShape.Height + 2);

            foreach (Shape secondShape in this.shapes)
            {
                var secondRectangle = new Rectangle(secondShape.X, secondShape.Y, secondShape.Width + 2,
                                                    secondShape.Height + 2);
                if (firstRectangle == secondRectangle)
                {
                    break;
                }
                if (firstRectangle.IntersectsWith(secondRectangle) && secondRectangle.IntersectsWith(firstRectangle))
                {
                    this.changeDirections(firstShape);
                    this.changeDirections(secondShape);
                }
            }
        }
Exemplo n.º 55
0
        public static ICollidable CheckCollision(ICollidable objectToCheck, List <ICollidable> objectsToCollide)
        {
            ICollidable objectToReturn;

            objectToReturn = null; //bei keiner collision wird null zurückgegeben

            foreach (ICollidable objectToCollide in objectsToCollide)
            {
                System.Drawing.Rectangle rectangle1 = SizeToRectangle(objectToCheck.ObjectSize, objectToCheck.PositionForRectangle);
                System.Drawing.Rectangle rectangle2 = SizeToRectangle(objectToCollide.ObjectSize, objectToCollide.PositionForRectangle);

                if (rectangle1.IntersectsWith(rectangle2))
                {
                    objectToReturn = objectToCollide;
                }
            }

            return(objectToReturn);
        }
Exemplo n.º 56
0
        protected override object GetProviderPropertyValue(int propertyId)
        {
            if (propertyId == AEIds.ControlTypeProperty.Id)
            {
                return(ControlType.Edit.Id);
            }
            else if (propertyId == AEIds.IsOffscreenProperty.Id)
            {
                SD.Rectangle controlRect = view.Bounds;
                controlRect.X = controlRect.Y = 0;
                return(!controlRect.IntersectsWith(GetBounds()));
            }
            else if (propertyId == AEIds.NativeWindowHandleProperty.Id)
            {
                return(null);
            }

            return(base.GetProviderPropertyValue(propertyId));
        }
Exemplo n.º 57
0
        /// <summary>
        /// Draws the start node (a single black ellipse)
        /// </summary>
        /// <param name="g">The graphics to draw the node with</param>
        /// <param name="f">The font to use</param>
        /// <param name="viewportRect">The viewport bounds</param>
        /// <param name="isSelected">The node selection state</param>
        protected internal override void Draw(System.Drawing.Graphics g, System.Drawing.Font f, System.Drawing.Rectangle viewportRect, bool isSelected)
        {
            Rectangle area = Area;

            // if it's visible
            if (viewportRect.IntersectsWith(area))
            {
                Brush br;
                if (isSelected)
                {
                    br = Brushes.Red;
                }
                else
                {
                    br = Brushes.Black;
                }

                g.FillEllipse(br, area);
            }
        }
        public bool CheckUntriggered(System.Drawing.Rectangle triggerRectangle)
        {
            bool result  = false;
            int  counter = 0;

            foreach (Terrain terrain in CommonFunctions.ICollidableList.OfType <Terrain>().ToList())
            {
                if (triggerRectangle.IntersectsWith(CommonFunctions.SizeToRectangle(terrain.ObjectSize, terrain.PositionForRectangle)))
                {
                    counter++;
                }
            }

            if (counter == 0)
            {
                result = true;
            }

            return(result);
        }
Exemplo n.º 59
0
        public CVConnectedComp MeanShift(System.Drawing.Rectangle window, int termCriteria, int maxIterations, double eps)
        {
            System.Drawing.Rectangle realWindow = new System.Drawing.Rectangle(0, 0, Width, Height);
            if (!realWindow.IntersectsWith(window))
            {
                CVConnectedComp cc = new CVConnectedComp(window);
                return(cc);
            }

            realWindow.Intersect(window);

            __CvRect         wnd = new __CvRect(realWindow);
            __CvTermCriteria tc  = PInvoke.cvTermCriteria(termCriteria, maxIterations, eps);

            __CvConnectedComp comp = new __CvConnectedComp();

            PInvoke.cvMeanShift(Internal, wnd, tc, ref comp);
            CVUtils.CheckLastError();
            return(new CVConnectedComp(ref comp));
        }
Exemplo n.º 60
0
        protected void DrawPlotAreaStyle(Report rpt, Graphics g, System.Drawing.Rectangle crect)
        {
            if (_ChartDefn.PlotArea == null || _ChartDefn.PlotArea.Style == null)
            {
                return;
            }
            System.Drawing.Rectangle rect = Layout.PlotArea;
            Style s = _ChartDefn.PlotArea.Style;

            Row r = FirstChartRow(rpt);

            if (rect.IntersectsWith(crect))
            {
                // This occurs when the legend is drawn inside the plot area
                //    we don't want to draw in the legend
                Region rg = null;
                try
                {
                    //				rg = new Region(rect);	// TODO: this doesn't work; nothing draws
                    //				rg.Complement(crect);
                    //				Region saver = g.Clip;
                    //				g.Clip = rg;
                    s.DrawBackground(rpt, g, r, rect);
                    //				g.Clip = saver;
                }
                finally
                {
                    if (rg != null)
                    {
                        rg.Dispose();
                    }
                }
            }
            else
            {
                s.DrawBackground(rpt, g, r, rect);
            }

            return;
        }