Example #1
0
        private bool IsCollision(GameEntity ge1, GameEntity ge2)
        {
            var X1 = GlobalMethods.FromCornerXToMiddleXAxis(ge1.position.x);
            var Y1 = GlobalMethods.FromCornerYToMiddleYAxis(ge1.position.y);
            var X2 = GlobalMethods.FromCornerXToMiddleXAxis(ge2.position.x);
            var Y2 = GlobalMethods.FromCornerYToMiddleYAxis(ge2.position.y);

            var R1 = ge1.size.width / 2.0;
            var R2 = ge2.size.width / 2.0;
            var Radius = R1 + R2;

            var dX = X2 - X1;
            var dY = Y2 - Y1;

            return Math.Sqrt((dX * dX) + (dY * dY)) < Math.Sqrt(Radius * Radius);
        }
Example #2
0
 public static void RemoveEntity(GameEntity entity)
 {
     gameEntities.Remove(entity);
     mainGrid.Children.Remove(entity.image);
 }
Example #3
0
        private bool IsCollision(GameEntity ge1, GameEntity ge2)
        {
            var X1 = ge1.position.x;
            var Y1 = ge1.position.y;
            var X2 = ge2.position.x;
            var Y2 = ge2.position.y;

            var R1 = ge1.size.width / 2.0;
            var R2 = ge2.size.width / 2.0;
            var Radius = R1 + R2;

            var dX = X2 - X1;
            var dY = Y2 - Y1;

            return Math.Sqrt((dX * dX) + (dY * dY)) <= Math.Sqrt(Radius * Radius);
        }
Example #4
0
 public static void AddEntity(GameEntity entity)
 {
     gameEntities.Add(entity);
     entity.Paint();
 }