public static IEnumerable<Block> getAboveBlocks(BCBlockGameState gstate, RectangleF testrect)
 {
     var aboveblocks = from b in gstate.Blocks where b.BlockRectangle.IntersectsWith(testrect) select b;
     return from bb in aboveblocks
            where Math.Abs(bb.CenterPoint().Y - testrect.CenterPoint().Y) >
                Math.Abs(bb.CenterPoint().X - testrect.CenterPoint().Y)
            select bb;
 }
        /*
        public static IEnumerable<Block> GetRestingBlocks(BCBlockGameState gstate,Block blocktest)
        {
            var touchingblocks = from b in gstate.Blocks where b!=blocktest && b.BlockRectangle.IntersectsWith(blocktest.BlockRectangle) select b;
            return touchingblocks;
           // return from b in touchingblocks where b.CenterPoint().Y > blocktest.BlockRectangle.Bottom select b;

        }*/
        public static IEnumerable<Block> GetRestingBlocks(BCBlockGameState gstate,RectangleF testrect)
        {
            var touchingblocks = from b in gstate.Blocks where b.BlockRectangle.IntersectsWith(testrect) select b;

            return from bb in touchingblocks
                   where bb.CenterPoint().Y > testrect.CenterPoint().Y &&
                   Math.Abs(bb.CenterPoint().Y - testrect.CenterPoint().Y) >
                   Math.Abs(bb.CenterPoint().X-testrect.CenterPoint().X) select bb;
        }
Example #3
0
        private static void DrawRectangle(Graphics g, String prefixtext, RectangleF drawthis, Pen RectPen, Brush RectBrush,
            Brush TextBrush, Font usefont)
        {
            g.FillRectangle(RectBrush, drawthis);

            g.DrawRectangle(RectPen, drawthis.ToRectangle());

            //also paint coordinate information.
            //cachestate.Blocks.Count.ToString() + " Blocks;\n"
            String BlockInfotext = prefixtext +
                "(" + Math.Round(drawthis.Left, 1) + "," + Math.Round(drawthis.Top, 1) + ")-(" +
                "(" + Math.Round(drawthis.Right, 1) + "," + Math.Round(drawthis.Bottom, 1) + ")";

            Size measurestring = TextRenderer.MeasureText(g, BlockInfotext, usefont);

            Point getcenter = drawthis.CenterPoint().ToPoint();
            Point DrawHere = new Point(getcenter.X - measurestring.Width / 2, getcenter.Y - measurestring.Height / 2);
            g.DrawString(BlockInfotext, usefont, TextBrush, DrawHere.X, DrawHere.Y);
        }