private void RenderMaze(double z, BlockMaze w, Brush Fill, Canvas Content) { Action <double, double> fillRect = (_x, _y) => { new Rectangle { Fill = Fill, Width = z / 2, Height = z / 2 }.MoveTo(_x, _y).AttachTo(Content); }; for (int x = 0; x < w.Width; x++) { for (int y = 0; y < w.Height; y++) { var v = w.Walls[x][y]; if (v) { fillRect( (DefaultWidth / 2) + (x - w.Width / 2) * z / 2, (DefaultHeight / 2) + (y - w.Height / 2) * z / 2); } } } }
private void InitializeCanvasDrawing(Canvas c) { Action <int, int> fillRect = (_x, _y) => { new Rectangle { Fill = Brushes.GreenYellow, Width = z / 2, Height = z / 2 }.MoveTo(_x, _y).AttachTo(c); }; int x, y; var offset = 0; var w = new BlockMaze(maze); for (x = 0; x < w.Width; x++) { for (y = 0; y < w.Height; y++) { var v = w.Walls[x][y]; if (v) { fillRect(maze.Width * z + x * z / 2, z + y * z / 2); } } } for (x = 1; x < maze.Width - 1; x++) { for (y = 1; y < maze.Height - 1; y++) { var v = maze[x, y]; var IsTop = (v & 1) != 0; var IsLeft = (v & 4) != 0; var IsBottom = (v & 2) != 0; var IsRight = (v & 8) != 0; fillRect(offset + x * z + z / 4, y * z + z / 4); if (!IsTop) { fillRect(offset + x * z + z / 4, y * z - z / 4); } if (!IsBottom) { fillRect(offset + x * z + z / 4, y * z + z * 3 / 4); } if (!IsLeft) { fillRect(offset + x * z - z / 4, y * z + z / 4); } if (!IsRight) { fillRect(offset + x * z + z * 3 / 4, y * z + z / 4); } } } }
private void CreateMapFromMaze() { var Map = new Texture32(); #region safe map for (int i = 0; i < 32; i++) { for (int j = 0; j < 32; j++) { Map[i, j] = bluewall; } } #endregion maze = new BlockMaze(new MazeGenerator(MazeSize, MazeSize, null)); #region write walls to map var wall_counter = 0; for (int x = 1; x < maze.Width - 1; x++) { for (int y = 1; y < maze.Height - 1; y++) { if (maze.Walls[x][y]) { wall_counter++; var variant = graywall; if (y > maze.Height / 2) { variant = woodwall; if (wall_counter % 7 == 0) { variant = woodwall_books; } if (wall_counter % 11 == 0) { variant = woodwall_achtung; } else if (wall_counter % 13 == 0) { variant = woodwall_verboten; } } else { variant = graywall; if (wall_counter % 8 == 0) { variant = graywall_achtung; } else if (wall_counter % 9 == 0) { variant = graywall_verboten; } } Map[x, y] = variant; } else { Map[x, y] = 0; } } } #endregion #region maze is smaller than 31 for (int x = 1; x < maze.Width - 1; x++) { Map[x, maze.Height - 1] = greenwall; } for (int y = 1; y < maze.Height - 1; y++) { Map[maze.Width - 1, y] = greenwall; } #endregion EgoView.Map.WorldMap = Map; }
public OrcasAvalonApplicationCanvas() { Width = DefaultWidth; Height = DefaultHeight; this.ClipToBounds = true; Colors.Blue.ToGradient(Colors.Black, DefaultHeight / 4).Select( (c, i) => new Rectangle { Fill = new SolidColorBrush(c), Width = DefaultWidth, Height = 5, }.MoveTo(0, i * 4).AttachTo(this) ).ToArray(); var mouse = new Image { Source = (KnownAssets.Path.Assets + "/mouse.png").ToSource(), Width = 32, Height = 32 }.MoveTo(0, 0).AttachTo(this); var img = new Image { Source = (KnownAssets.Path.Assets + "/jsc.png").ToSource() }.MoveTo(DefaultWidth - 96, 0).AttachTo(this); var Content = new Canvas { Width = DefaultWidth, Height = DefaultHeight, }.AttachTo(this); var ContentY = new AnimatedDouble(0); ContentY.ValueChanged += y => Content.MoveTo(0, y); { var maze = new MazeGenerator(12, 8, null); var blocks = new BlockMaze(maze); var w = new BlockMaze(maze); Colors.Black.ToGradient(Colors.Yellow, 30).ForEach( (c, i) => RenderMaze(60 + i * 0.1, w, new SolidColorBrush(c), Content) ); } var TouchOverlay = new Rectangle { Fill = Brushes.Yellow, Opacity = 0, Width = DefaultWidth, Height = DefaultHeight }.AttachTo(this); TouchOverlay.MouseEnter += delegate { mouse.Show(); }; TouchOverlay.MouseLeave += delegate { mouse.Hide(); }; TouchOverlay.Cursor = Cursors.None; TouchOverlay.MouseMove += (s, args) => { var p = args.GetPosition(this); mouse.MoveTo(p.X - 4, p.Y - 4); }; TouchOverlay.MouseLeftButtonUp += (s, args) => { var p = args.GetPosition(this); ShowExplosion(Convert.ToInt32(p.X), Convert.ToInt32(p.Y), Content); ("assets/AvalonMouseMaze/explosion.mp3").PlaySound(); 150.AtDelay( delegate { ShowExplosion(Convert.ToInt32(p.X + 6), Convert.ToInt32(p.Y - 6), Content); } ); 300.AtDelay( delegate { ShowExplosion(Convert.ToInt32(p.X + 4), Convert.ToInt32(p.Y + 6), Content); ContentY.SetTarget(DefaultHeight); } ); 1500.AtDelay( delegate { ContentY.SetTarget(0); } ); }; new GameMenuWithGames(DefaultWidth, DefaultHeight, 32).AttachContainerTo(this).Hide(); }
public static void Main(string[] args) { // jsc needs to see args to make Main into main for javac.. // generic parameter needs to be moved.. //enumerable_10 = __Enumerable.AsEnumerable(__SZArrayEnumerator_1<String>.Of(stringArray3)); Console.WriteLine("hi!"); Console.WriteLine("maze..."); var maze = new MazeGenerator(20, 20, new Feedback()); var w = new BlockMaze(maze); for (int iy = 0; iy < w.Height; iy += 2) { for (int i = 0; i < w.Width; i++) { var v0 = w.Walls[i][iy]; var v1 = false; if (iy + 1 < w.Height) { v1 = w.Walls[i][iy + 1]; } //Console.Write("" + v.ToString("x2")); if (v0) { if (v1) { Console.Write("█"); } else { Console.Write("▀"); } } else { if (v1) { Console.Write("▄"); } else { Console.Write(" "); } } } Console.WriteLine(); } System.Console.WriteLine("done"); System.Console.WriteLine("jvm"); CLRProgram.XML = new XElement("hello", "world"); CLRProgram.CLRMain( ); }