public static void Run(Graphics g, int i) { Engine.Point cameraLocation = new Engine.Point(400 + i * 50, 400); Camera camera = new Camera(new Step(cameraLocation, 315, 45, 0)); var arena = new Polygon(new List <LineSegment> { new LineSegment(new Engine.Point(600, 100), new Engine.Point(1000, 100), Pens.Green), new LineSegment(new Engine.Point(1000, 100), new Engine.Point(1000, 300)), new LineSegment(new Engine.Point(1000, 300), new Engine.Point(1400, 300), Pens.Orange), new LineSegment(new Engine.Point(1400, 300), new Engine.Point(1400, 0)), new LineSegment(new Engine.Point(1400, 0), new Engine.Point(1800, 0), Pens.Red), new LineSegment(new Engine.Point(1800, 0), new Engine.Point(1800, 800), Pens.Red), new LineSegment(new Engine.Point(1800, 800), new Engine.Point(1400, 800), Pens.Red), new LineSegment(new Engine.Point(1400, 800), new Engine.Point(1400, 500)), new LineSegment(new Engine.Point(1400, 500), new Engine.Point(1000, 500), Pens.Orange), new LineSegment(new Engine.Point(1000, 500), new Engine.Point(1000, 700)), new LineSegment(new Engine.Point(1000, 700), new Engine.Point(600, 700), Pens.Green) }); var circle = new Circle(new Engine.Point(800, 600), 20); var sceneObjects = new List <SceneObject> { arena, circle }; Scene scene = new Scene(camera, g, sceneObjects); scene.Draw(); }
public void DrawHero(Point position, double angle, List <Point> wayList, bool isHorizontal) { _canvas.Children.Add(_visibleWay); _visWayCollection.Clear(); System.Windows.Point point = new System.Windows.Point(position.X, position.Y); _visWayCollection.Add(point); foreach (var wayPoint in wayList) {/* * if (weakReference.Target == null) * continue; */ point = new System.Windows.Point(wayPoint.X, wayPoint.Y); _visWayCollection.Add(point); } if (isHorizontal) { _canvas.Children.Add(_horizontalAppearance); Canvas.SetLeft(_horizontalAppearance, position.X - _dcenter); Canvas.SetTop(_horizontalAppearance, position.Y - _dcenter); } else { _canvas.Children.Add(_appearance); Canvas.SetLeft(_appearance, position.X - _dcenter); Canvas.SetTop(_appearance, position.Y - _dcenter); _t.Angle = angle; } }
private void G_TurtleStatusChanged(object sender, TurtleStatusChangedEventArg e) { CheckForIllegalCrossThreadCalls = false; lastState = e.Status; var oldPicx = GetCellByPoint(current); if (oldPicx != null) { oldPicx.Image = null; oldPicx.Update(); } var picX = GetCellByPoint(e.Position); if (picX != null) { switch (e.Status) { case TurtleState.Killed: picX.Image = Resources.Dead; AppendText(Color.Red, "Killed" + Environment.NewLine); break; case TurtleState.Escaped: picX.Image = Resources.Escaped; AppendText(Color.Green, "Escaped" + Environment.NewLine); break; case TurtleState.IsInDanger: switch (e.Direction) { case Engine.Direction.North: picX.Image = Resources.TNorth; break; case Engine.Direction.West: picX.Image = Resources.TWest; break; case Engine.Direction.East: picX.Image = Resources.Teast; break; case Engine.Direction.South: picX.Image = Resources.TSouth; break; } break; } } current = e.Position; picX.Update(); this.Invalidate(); this.Update(); this.Refresh(); Thread.Sleep(500); }
private void UpdateInput(double elapsedTime) { System.Drawing.Point mousePos = Cursor.Position; mousePos = simpleOpenGlControl1.PointToClient(mousePos); // Now use our point definition, Engine.Point adjustedMousePoint = new Engine.Point(); adjustedMousePoint.X = (float)mousePos.X - ((float)ClientSize.Width / 2); adjustedMousePoint.Y = ((float)ClientSize.Height / 2) - (float)mousePos.Y; // _input.MousePosition = adjustedMousePoint; _input.Mouse.Update(elapsedTime); }
protected override void OnMouseDown(MouseButtonEventArgs e) { t_cursorIsMovable = true; t_mousePoint = new Engine.Point((int)e.GetPosition(this).X, (int)e.GetPosition(this).Y); this.InvalidateVisual(); ConstraintMousePosition(); Engine.Color.Cell c = GetColorFromPosition(); OnColorChanged(new ColorChangedEventArgs(c)); base.OnMouseDown(e); }
public void DrawShaddow(Point innerPoint, Size innerSize) { var drawingGroup = new DrawingGroup(); // Create a DrawingBrush. DrawingBrush myDrawingBrush = new DrawingBrush(); // Create a drawing. GeometryDrawing myBlackDrawing = new GeometryDrawing(); // myGeometryDrawing.Brush myBlackDrawing.Brush = Brushes.Black; myBlackDrawing.Pen = new Pen(Brushes.Black, 1); GeometryGroup rectangle = new GeometryGroup(); rectangle.FillRule = FillRule.EvenOdd; rectangle.Children.Add(new RectangleGeometry(new Rect { Height = _canvas.Height, Width = _canvas.Width })); GeometryGroup rectangle11 = new GeometryGroup(); rectangle11.FillRule = FillRule.Nonzero; rectangle11.Children.Add( new RectangleGeometry(new Rect(new System.Windows.Point(innerPoint.X, innerPoint.Y), new System.Windows.Size(innerSize.Width * 20, innerSize.Height * 20)))); rectangle.Children.Add(rectangle11); var combined = new CombinedGeometry(GeometryCombineMode.Exclude, rectangle, rectangle11); myBlackDrawing.Geometry = combined; drawingGroup.Children.Add(myBlackDrawing); myDrawingBrush.Drawing = drawingGroup; Rectangle rec = new Rectangle { Fill = myDrawingBrush, Stroke = Brushes.Black, Height = _canvas.Height, Width = _canvas.Width, Opacity = 0.5, IsEnabled = false }; _canvas.Children.Add(rec); Canvas.SetLeft(rec, 0); Canvas.SetTop(rec, 0); }
protected override void OnMouseMove(System.Windows.Input.MouseEventArgs e) { t_mousePoint = new Engine.Point((int)e.GetPosition(this).X, (int)e.GetPosition(this).Y); if (t_cursorIsMovable) { this.InvalidateVisual(); ConstraintMousePosition(); Engine.Color.Cell c = GetColorFromPosition(); OnColorChanged(new ColorChangedEventArgs(c)); } base.OnMouseMove(e); }
private void CreateBoard(BoardSetting boardSetting) { for (int i = 0; i < boardSetting.BoardWithd; i++) { for (int j = 0; j < boardSetting.BoardHeight; j++) { Engine.Point pt = new Engine.Point { X = i, Y = j }; var ctl = CreateCell(pt); if (boardSetting.Mines.Any(m => m == pt)) { ctl.Image = Resources.MINE; } else if (boardSetting.ExitPoint == pt) { ctl.Image = Resources.Exit; } else if (boardSetting.StartPoint == pt) { switch (boardSetting.Direction) { case Engine.Direction.North: ctl.Image = Resources.TNorth; break; case Engine.Direction.West: ctl.Image = Resources.TWest; break; case Engine.Direction.East: ctl.Image = Resources.Teast; break; case Engine.Direction.South: ctl.Image = Resources.TSouth; break; } } panel2.Controls.Add(ctl); ctl.BringToFront(); } } }
public static void Run(Graphics g) { Engine.Point cameraLocation = new Engine.Point(400, 400); Camera camera = new Camera(new Step(cameraLocation, 315, 45, 0)); var arena = new Polygon(new List <LineSegment> { new LineSegment(new Engine.Point(600, 100), new Engine.Point(1000, 100)), new LineSegment(new Engine.Point(1000, 100), new Engine.Point(1000, 300)), new LineSegment(new Engine.Point(1000, 300), new Engine.Point(1400, 300)), new LineSegment(new Engine.Point(1400, 300), new Engine.Point(1400, 0)), new LineSegment(new Engine.Point(1400, 0), new Engine.Point(1800, 0)), new LineSegment(new Engine.Point(1800, 0), new Engine.Point(1800, 800)), new LineSegment(new Engine.Point(1800, 800), new Engine.Point(1400, 800)), new LineSegment(new Engine.Point(1400, 800), new Engine.Point(1400, 500)), new LineSegment(new Engine.Point(1400, 500), new Engine.Point(1000, 500)), new LineSegment(new Engine.Point(1000, 500), new Engine.Point(1000, 700)), new LineSegment(new Engine.Point(1000, 700), new Engine.Point(600, 700)) }); Scene scene = new Scene(camera, g, new List <SceneObject> { arena }); scene.Draw(); var fov = camera.GetFOVRays(); fov.ForEach(vp => { var pts = arena.Lines.Select(l => vp.RayLineSegmentIntersection(l)).Where(p => p != null); if (pts.Count() >= 1) { var pt = pts.Select(p => new Tuple <Engine.Point, double>(p, p.DistanceTo(camera.Location))).OrderBy(p => p.Item2).First(); pt.Item1.DrawWithRadius(g, 5, Pens.Green); vp.DrawWithEndPoint(g, pt.Item1, Pens.LightBlue); } else { vp.Draw(g, Pens.LightBlue); } }); }
private PictureBox CreateCell(Engine.Point pt) { PictureBox Cell = new PictureBox(); Cell.Tag = pt; Cell.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; Cell.Location = new System.Drawing.Point(0, 0); Cell.Name = "Cell_" + pt.X.ToString() + "_" + pt.Y.ToString(); Cell.Size = new System.Drawing.Size(52, 52); Cell.TabIndex = 0; Cell.TabStop = false; Cell.SizeMode = PictureBoxSizeMode.StretchImage; Cell.Top = pt.Y * 52; Cell.Left = pt.X * 52; Cell.BackColor = Color.Transparent; picXS.Add(pt, Cell); return(Cell); }
private void Button2_Click(object sender, EventArgs e) { try { movesSetting = new MovesSetting(moveFile); movesSetting.Load(); boardSetting = new BoardSetting(boardFile); boardSetting.Load(); current = boardSetting.StartPoint; CreateBoard(boardSetting); this.Width = boardSetting.BoardWithd * 52 + 220; this.Height = boardSetting.BoardHeight * 52 + 40 + panel1.Height; this.Update(); game = Engine.Game .Create(boardSetting.BoardWithd, boardSetting.BoardHeight) .LayMine(boardSetting.Mines) .SetExitPoint(boardSetting.ExitPoint) .AddTurtle(boardSetting.StartPoint, boardSetting.Direction, this.G_TurtleStatusChanged); ThreadPool.QueueUserWorkItem(s => Play()); } catch (InvalidSettingException ex) { StringBuilder strb = new StringBuilder(); strb.AppendLine(ex.Message); foreach (var item in ex.Errors) { strb.AppendLine(item.ToString()); } ShowError(strb.ToString()); } catch (Exception ex) { ShowError(ex.Message); } }
public static void Run(Graphics g) { Engine.Point cameraLocation = new Engine.Point(800, 300); Camera camera = new Camera(new Step(cameraLocation, 315, 45, 0)); List <SceneObject> cs = new List <SceneObject> { new Circle(new Engine.Point(800, 500), 20), new Circle(new Engine.Point(800, 700), 20), new Circle(new Engine.Point(1000, 500), 20), new Circle(new Engine.Point(700, 200), 20) }; Scene scene = new Scene(camera, g, cs); scene.Draw(); var fov = camera.GetFOVRays(); fov.ForEach(vp => { vp.Draw(g, Pens.LightBlue); cs.ForEach(c => { var pts = vp.RayCircleIntersections((Circle)c); if (pts.Item1 == 1) { pts.Item2.DrawWithRadius(g, 2, Pens.Green); } if (pts.Item1 == 2) { var it2St = pts.Item2.DistanceTo(vp.Start) < pts.Item3.DistanceTo(vp.Start); pts.Item2.DrawWithRadius(g, 2, it2St ? Pens.Green : Pens.Red); pts.Item3.DrawWithRadius(g, 2, it2St ? Pens.Red : Pens.Green); } }); }); }
public Fov(Ray ray, SceneObject intersectingObj, Engine.Point intersectingPoint) { Ray = ray; IntersectingObj = intersectingObj; IntersectingPoint = intersectingPoint; }
private static Planner GetPlanner() { var planner = new Planner(new Engine.Point(600, 475), 315, 45); // move to area between rooms var betweenRooms = new Engine.Point(825, 475); planner.AddCourse(betweenRooms, 5); // rotate to room 1 planner.AddRotation(-90, 10); // enter room 1 var inRoom1 = new Engine.Point(825, 200); planner.AddCourse(inRoom1, 5); // rotate in room1 planner.AddRotation(-180, 10); // enter room 2 var inRoom2 = new Engine.Point(825, 700); planner.AddCourse(inRoom2, 15); // rotate out of room planner.AddRotation(180, 10); // back to area between rooms planner.AddCourse(betweenRooms, 10); // rotate in hallway planner.AddRotation(90, 10); // move towards first toilet var firstToilet = new Engine.Point(975, 475); planner.AddCourse(firstToilet, 5); // scan both places planner.AddRotation(360, 15); // move towards second toilet var secondToilet = new Engine.Point(1125, 475); planner.AddCourse(secondToilet, 5); // scan both places planner.AddRotation(-270, 15); // enter second toilet var secondToiletInside = new Engine.Point(1125, 775); planner.AddCourse(secondToiletInside, 5); // rotate out of toilet planner.AddRotation(180, 15); // move to entrance of second toilet planner.AddCourse(secondToilet, 5); // rotate towards dinning area planner.AddRotation(90, 15); // enter dining area var diningArea = new Engine.Point(1275, 475); planner.AddCourse(diningArea, 5); // scan dining area planner.AddRotation(-90, 15); planner.AddRotation(180, 15); // enter living room var livingRoom = new Engine.Point(1275, 700); planner.AddCourse(livingRoom, 5); // scan living room planner.AddRotation(-90, 15); return(planner); }
public Point GetDestination(Point destination, FixedObject destObject, Hero hero) { return destination; }
public void DrawImmediateModeVertex(Vector position, Color color, Point uvs) { Gl.glColor4f(color.Red, color.Green, color.Blue, color.Alpha); Gl.glTexCoord2f(uvs.X, uvs.Y); Gl.glVertex3d(position.X, position.Y, position.Z); }
public void DrawHero(Point position, double angle, List<Point> wayList, bool isHorizontal) { _canvas.Children.Add(_visibleWay); _visWayCollection.Clear(); System.Windows.Point point = new System.Windows.Point(position.X, position.Y); _visWayCollection.Add(point); foreach (var wayPoint in wayList) {/* if (weakReference.Target == null) continue; */ point = new System.Windows.Point(wayPoint.X, wayPoint.Y); _visWayCollection.Add(point); } if (isHorizontal) { _canvas.Children.Add(_horizontalAppearance); Canvas.SetLeft(_horizontalAppearance, position.X - _dcenter); Canvas.SetTop(_horizontalAppearance, position.Y - _dcenter); } else { _canvas.Children.Add(_appearance); Canvas.SetLeft(_appearance, position.X - _dcenter); Canvas.SetTop(_appearance, position.Y - _dcenter); _t.Angle = angle; } }
private PictureBox GetCellByPoint(Engine.Point pt) { return(picXS[pt]); }