private QRect TargetRect() { QRect result = new QRect(0, 0, 20, 10); result.MoveCenter(new QPoint(target.X(), Height() - 1 - target.Y())); return(result); }
private void moveShot() { QRegion region = new QRegion(shotRect()); timerCount++; QRect shotR = shotRect(); if (shotR.Intersects(targetRect())) { autoShootTimer.Stop(); Emit.hit(); Emit.canShoot(true); } else if (shotR.X() > Width() || shotR.Y() > Height()) { autoShootTimer.Stop(); Emit.missed(); Emit.canShoot(true); } else { region = region.Unite(new QRegion(shotR)); } Update(region); }
public override void OnStart(QGetContent content) { Frames = Scene.MegaTexture["cavern_biome"].Split(16, 16); Tile = Frames[0]; Sprite = new QSprite(this, Tile); Sprite.Color = QColor.DarkKhaki; Sprite.Layer = 100f; Transform.Scale = new QVec(4); int random = QRandom.Range(1, 10); if (random == 1) { Mushroom = Frames[2]; } else if (random == 2) { Mushroom = Frames[3]; } else if (random == 3) { Mushroom = Frames[4]; } else { Mushroom = QRect.Empty; } body = World.CreateRectangle(this, 14 * 4, 14 * 4, 1f, Transform.Position, 0, QBodyType.Static); body.Friction = 6f; }
private void MoveShot() { QRegion region = new QRegion(ShotRect()); timerCount++; QRect shotR = ShotRect(); if (shotR.Intersects(TargetRect())) { autoShootTimer.Stop(); Emit.Hit(); Emit.CanShoot(true); } else if (shotR.X() > Width() || shotR.Y() > Height() || shotR.Intersects(BarrierRect())) { autoShootTimer.Stop(); Emit.Missed(); Emit.CanShoot(true); } else { region = region.Unite(shotR); } Update(region); }
public void OnStart(QGetContent content) { Sprite = new QSprite(this, "cavern_wall"); Sprite.Origin = new QVec(8); Sprite.Layer = 1f; Sprite.Color *= 0.4f; Transform.Scale = new QVec(4); QRect wall = Scene.MegaTexture["cavern_biome"].Split(16, 16)[1]; using (var layer2 = content.Texture("map1_3").GetPartialTexture(new QRect(0, 0, 128, 128))) { OutsideTiles = QMapTools.CreateSpriteLayer(layer2, Transform.Position, new QVec(16, 16) * Transform.Scale, color => { if (color == new QColor(60, 45, 30)) { return(wall); } return(QRect.Empty); }); InsideTiles = QMapTools.CreateSpriteLayer(layer2, Transform.Position, new QVec(16, 16) * Transform.Scale, color => { if (color == new QColor(134, 97, 61)) { return(wall); } return(QRect.Empty); }); } }
private QRect CannonRect() { QRect result = new QRect(0, 0, 50, 50); result.MoveBottomLeft(Rect.BottomLeft()); return(result); }
public void TestIntegerConstructor() { var s = new QRect(50, 100, 200, 150); Assert.AreEqual(50, s.Left); Assert.AreEqual(100, s.Top); Assert.AreEqual(200, s.Width); Assert.AreEqual(150, s.Height); }
void DrawShapes(QPainter painter) { painter.SetRenderHint(QPainter.RenderHint.Antialiasing); painter.Pen = new QPen(new QBrush(new QColor("Gray")), 1); painter.Brush = new QColor("Gray"); var path = new QPainterPath(); path.MoveTo(5, 5); path.CubicTo(40, 5, 50, 50, 99, 99); path.CubicTo(5, 99, 50, 50, 5, 5); painter.DrawPath(path); painter.DrawPie(130, 20, 90, 60, 30 * 16, 120 * 16); painter.DrawChord(240, 30, 90, 60, 0, 16 * 180); var rectangle = new QRect(new QPoint(20, 120), new QSize(80, 50)); painter.DrawRoundedRect(rect: rectangle, xRadius: 10, yRadius: 10); // to be implemented //var points = new List<QPoint>(); //points.Add ( new QPoint ( 130, 140 ) ); //points.Add ( new QPoint ( 180, 170 ) ); //points.Add ( new QPoint ( 180, 140 ) ); //points.Add ( new QPoint ( 220, 110 ) ); //points.Add ( new QPoint ( 140, 100 ) ); //// http://doc.qt.io/qt-5/qpolygon.html#QPolygon-2 , we should be able to pase point list //var polygon = new QPolygon(points); //painter.DrawPolygon ( polygon ); // this is workaround for DrawPolygon unsafe { var polygon = new QPolygon(); var points = new int[] { 130, 140, 180, 170, 180, 140, 220, 110, 140, 100 }; fixed(int *point = points) { polygon.SetPoints(points.Length / 2, ref *point); } painter.DrawPolygon(polygon); } painter.DrawRect(250, 110, 60, 60); var baseline = new QPointF(20, 250); var font = new QFont("Georgia", 55); var forntPath = new QPainterPath(); forntPath.AddText(baseline, font, "Q"); painter.DrawPath(forntPath); painter.DrawEllipse(140, 200, 60, 60); painter.DrawEllipse(240, 200, 90, 60); }
public void OnStart(QGetContent get) { Heart = get.TextureSource("BryanStuff1").Split(32, 32)[21]; EmptyHeart = get.TextureSource("BryanStuff1").Split(32, 32)[22]; p = GetBehavior <Player>(); GuiHeart = new QImage(this, Heart); GuiEmptyHeart = new QImage(this, EmptyHeart); GuiHeart.Scale = new QVec(4); GuiEmptyHeart.Scale = new QVec(4); }
public void TestY() { var s = new QRect(); s.X = 200; s.Y = 300; s.Width = 500; s.Height = 600; Assert.AreEqual(300, s.Y); }
public void TestLeft() { var s = new QRect(); s.X = 50; s.Y = 150; s.Width = 500; s.Height = 600; Assert.AreEqual(50, s.Left); }
public void TestWidth() { var s = new QRect(); s.X = 0; s.Y = 0; s.Width = 500; s.Height = 600; Assert.AreEqual(500, s.Width); }
public void TestPointSizeConstructor() { var p1 = new QPoint(50, 100); var p2 = new QSize(200, 150); var s = new QRect(p1, p2); Assert.AreEqual(50, s.Left); Assert.AreEqual(100, s.Top); Assert.AreEqual(200, s.Width); Assert.AreEqual(150, s.Height); }
public void TestIsEmpty() { var s1 = new QRect(); s1.Left = 500; s1.Right = 400; s1.Top = 700; s1.Bottom = 600; var inter = s1.IsEmpty; Assert.IsTrue(inter); }
public void TestIsNull() { var s1 = new QRect(); s1.X = 0; s1.Y = 0; s1.Width = 0; s1.Height = 0; var inter = s1.IsNull; Assert.IsTrue(inter); }
public void TestIsValid() { var s1 = new QRect(); s1.Left = 500; s1.Right = 400; s1.Top = 700; s1.Bottom = 600; var inter = s1.IsValid; Assert.IsFalse(inter); }
public void TestBottomRight() { var s = new QRect(); s.X = 50; s.Y = 150; s.Width = 500; s.Height = 600; var n = s.BottomRight; Assert.AreEqual(new QPoint(s.Left + s.Width - 1, s.Top + s.Height - 1), n); }
public void TestContainsWithIntegerValues() { var s = new QRect(); s.X = 50; s.Y = 150; s.Width = 500; s.Height = 600; var n = s.Contains(275, 375); Assert.IsTrue(n); }
public void TestTop() { var s = new QRect(); s.X = 50; s.Y = 80; s.Width = 500; s.Height = 600; var size = s.Top; Assert.AreEqual(s.Y, size); }
public void TestBottom() { var s = new QRect(); s.X = 50; s.Y = 150; s.Width = 500; s.Height = 600; var n = s.Bottom; Assert.AreEqual(s.Top + s.Height - 1, n); }
public void TestMoveBottom() { var s = new QRect(); s.Left = 50; s.Top = 150; s.Right = 600; s.Bottom = 500; s.MoveBottom(50); Assert.AreEqual(50, s.Bottom); }
public void TestSize() { var s = new QRect(); s.X = 50; s.Y = 80; s.Width = 500; s.Height = 600; var size = s.Size; Assert.AreEqual(500, size.Width); Assert.AreEqual(600, size.Height); }
public void TestTopRight() { var s = new QRect(); s.X = 50; s.Y = 80; s.Width = 500; s.Height = 600; var size = s.TopRight; Assert.AreEqual(s.Y, size.Y); Assert.AreEqual(s.X + s.Width - 1, size.X); }
public void TestTranslateInteger() { var s = new QRect(); s.X = 50; s.Y = 80; s.Width = 500; s.Height = 600; s.Translate(50, 20); Assert.AreEqual(100, s.X); Assert.AreEqual(100, s.Y); }
public void TestContainsWithQRect() { var s = new QRect(); s.X = 50; s.Y = 150; s.Width = 500; s.Height = 600; var p = new QRect(275, 375, 50, 50); var n = s.Contains(p, true); Assert.IsTrue(n); }
public void TestTranslatedQPoint() { var s = new QRect(); s.X = 50; s.Y = 80; s.Width = 500; s.Height = 600; var n = s.Translated(new QPoint(50, 20)); Assert.AreEqual(100, n.X); Assert.AreEqual(100, n.Y); }
public void TestCenter() { var s = new QRect(); s.X = 50; s.Y = 150; s.Width = 500; s.Height = 600; var n = s.Center; Assert.AreEqual(299, n.X); Assert.AreEqual(449, n.Y); }
public void TestRight() { var s = new QRect(); s.X = 50; s.Y = 80; s.Width = 500; s.Height = 600; Assert.AreEqual(500, s.Width); Assert.AreEqual(600, s.Height); Assert.AreEqual(s.Left + s.Width - 1, s.Right); Assert.AreEqual(80, s.Y); }
public void TestAdjusted() { var s = new QRect(); s.X = 50; s.Y = 150; s.Width = 500; s.Height = 600; var n = s.Adjusted(50, 100, 150, 200); Assert.AreEqual(100, n.X); Assert.AreEqual(250, n.Y); Assert.AreEqual(600, n.Width); Assert.AreEqual(700, n.Height); }
public void TestNormalized() { var s = new QRect(); s.X = 0; s.Y = 0; s.Width = -1; s.Height = -1; var n = s.Normalized; Assert.IsTrue(n.Width > 0); Assert.IsTrue(n.Height > 0); Assert.AreEqual(-2, n.X); Assert.AreEqual(-2, n.Y); }
public void TestAddMarginToNewRectOperator2() { var s1 = new QRect(); s1.X = 0; s1.Y = 0; s1.Width = 500; s1.Height = 600; var s2 = new QMargins(100, 100, 100, 100); var n = s2 + s1; Assert.AreEqual(-100, n.X); Assert.AreEqual(-100, n.Y); Assert.AreEqual(700, n.Width); Assert.AreEqual(800, n.Height); }
public void TestAddMarginOperator() { var s1 = new QRect(); s1.X = 0; s1.Y = 0; s1.Width = 500; s1.Height = 600; var s2 = new QMargins(100, 100, 100, 100); s1 += s2; Assert.AreEqual(-100, s1.X); Assert.AreEqual(-100, s1.Y); Assert.AreEqual(700, s1.Width); Assert.AreEqual(800, s1.Height); }
public void TestPipeOperator() { var s1 = new QRect(); s1.X = 0; s1.Y = 0; s1.Width = 500; s1.Height = 600; var s2 = new QRect(); s2.X = 100; s2.Y = 100; s2.Width = 500; s2.Height = 600; var n = s1 | s2; Assert.AreEqual(0, n.X); Assert.AreEqual(0, n.Y); Assert.AreEqual(600, n.Width); Assert.AreEqual(700, n.Height); }
public void TestNotEqualOperator() { var s1 = new QRect(); s1.X = 0; s1.Y = 0; s1.Width = 500; s1.Height = 600; var s2 = new QRect(); s2.X = 100; s2.Y = 100; s2.Width = 500; s2.Height = 600; Assert.AreNotEqual(s1, s2); }
public void TestMarginsRemoved() { var s = new QRect(); s.Left = 50; s.Top = 150; s.Right = 600; s.Bottom = 500; var mar = new QMargins(50, 100, 150, 200); var newR = s.MarginsRemoved(mar); Assert.AreEqual(100, newR.Left); Assert.AreEqual(250, newR.Top); Assert.AreEqual(450, newR.Right); Assert.AreEqual(300, newR.Bottom); }
public void TestMoveCenter() { var s = new QRect(); s.X = 50; s.Y = 100; s.Width = 500; s.Height = 600; s.MoveCenter(new QPoint(600, 600)); Assert.AreEqual(500, s.Width); Assert.AreEqual(600, s.Height); Assert.AreEqual(600 - 250 + 1, s.X); Assert.AreEqual(600 - 300 + 1, s.Y); }
public void TestSubMarginToNewRectOperator() { var s1 = new QRect(); s1.X = 100; s1.Y = 100; s1.Width = 500; s1.Height = 600; var s2 = new QMargins(100, 100, 100, 100); var n = s1 - s2; Assert.AreEqual(200, n.X); Assert.AreEqual(200, n.Y); Assert.AreEqual(300, n.Width); Assert.AreEqual(400, n.Height); }
public void TestIntersects() { var s1 = new QRect(); s1.X = 0; s1.Y = 0; s1.Width = 500; s1.Height = 600; var s2 = new QRect(); s2.X = 400; s2.Y = 500; s2.Width = 500; s2.Height = 600; var inter = s1.Intersects(s2); Assert.IsTrue(inter); }
public void TestAdjust() { var s = new QRect(); s.X = 50; s.Y = 150; s.Width = 500; s.Height = 600; s.Adjust(50, 100, 150, 200); Assert.AreEqual(100, s.X); Assert.AreEqual(250, s.Y); Assert.AreEqual(600, s.Width); Assert.AreEqual(700, s.Height); }
public void TestTranslatedInteger() { var s = new QRect(); s.X = 50; s.Y = 80; s.Width = 500; s.Height = 600; var n = s.Translated(50, 20); Assert.AreEqual(100, n.X); Assert.AreEqual(100, n.Y); }
public void TestMoveToQPoint() { var s = new QRect(); s.X = 50; s.Y = 80; s.Width = 500; s.Height = 600; s.MoveTo(new QPoint(100, 100)); Assert.AreEqual(500, s.Width); Assert.AreEqual(600, s.Height); Assert.AreEqual(100, s.X); Assert.AreEqual(100, s.Y); }
public void TestMoveRight() { var s = new QRect(); s.X = 50; s.Y = 100; s.Width = 500; s.Height = 600; s.MoveRight(50); Assert.AreEqual(500, s.Width); Assert.AreEqual(600, s.Height); Assert.AreEqual(-449, s.X); Assert.AreEqual(100, s.Y); }
public void TestSetRect() { var s = new QRect(); s.X = 50; s.Y = 150; s.Width = 500; s.Height = 600; s.SetRect(100, 100, 500, 500); Assert.AreEqual(100, s.X); Assert.AreEqual(100, s.Y); Assert.AreEqual(500, s.Width); Assert.AreEqual(500, s.Height); }
public void TestMoveBottomRight() { var s = new QRect(); s.X = 50; s.Y = 100; s.Width = 500; s.Height = 600; s.MoveBottomRight(new QPoint(600, 600)); Assert.AreEqual(500, s.Width); Assert.AreEqual(600, s.Height); Assert.AreEqual(101, s.X); Assert.AreEqual(1, s.Y); }
public void TestIntersected() { var s1 = new QRect(); s1.X = 0; s1.Y = 0; s1.Width = 500; s1.Height = 600; var s2 = new QRect(); s2.X = 400; s2.Y = 500; s2.Width = 500; s2.Height = 600; var inter = s1.Intersected(s2); Assert.AreEqual(400, inter.X); Assert.AreEqual(500, inter.Y); Assert.AreEqual(100, inter.Width); Assert.AreEqual(100, inter.Height); }
public unsafe void TestGetRect() { var s = new QRect(); s.X = 50; s.Y = 150; s.Width = 500; s.Height = 600; int x1 = 0; int y1 = 0; int width = 0; int height = 0; s.GetRect(ref x1, ref y1, ref width, ref height); Assert.AreEqual(50, x1); Assert.AreEqual(150, y1); Assert.AreEqual(500, width); Assert.AreEqual(600, height); }
public void TestTranslateQPoint() { var s = new QRect(); s.X = 50; s.Y = 80; s.Width = 500; s.Height = 600; s.Translate(new QPoint(50, 20)); Assert.AreEqual(100, s.X); Assert.AreEqual(100, s.Y); }
public void TestUnited() { var s1 = new QRect(); s1.X = 0; s1.Y = 0; s1.Width = 500; s1.Height = 600; var s2 = new QRect(); s2.X = 100; s2.Y = 100; s2.Width = 500; s2.Height = 600; var n = s1.United(s2); Assert.AreEqual(0, n.X); Assert.AreEqual(0, n.Y); Assert.AreEqual(600, n.Width); Assert.AreEqual(700, n.Height); }