public static void Main(string[] args) { builder = new GameBuilder(); IGameWindowBuilder windowBuilder; #if netcoreapp31 windowBuilder = new AvaloniaWindowBuilder(); #endif #if net48 windowBuilder = new WinFormWindowBuilder(); #endif builder .GameEngine(new FixedTickEngine(TPS)) .GameView(new GameView2D(SCREENWIDTH, SCREENHEIGHT, scale, scale, Color.DarkSlateGray)) .GameFrame(new GameFrame(windowBuilder, 0, 0, 160, 144, scale, scale)) .Controller(new WindowsKeyController(keyMap.ToDictionary(kvp => (int)kvp.Key, kvp => (int)kvp.Value))) .Controller(new WindowsMouseController(mouseMap.ToDictionary(kvp => Convert(kvp.Key), kvp => (int)kvp.Value))) .StartingLocation(new Location(new Description2D(0, 0, 100, 100))) .Build(); Engine = builder.Engine; Frame = builder.Frame; SetupAnimations(); SetupSprites(); SetupSkills(); Entity marker = Marker.Create(new Marker(0, 0)); Engine.AddEntity(marker); Random r = new Random(0); for (int i = 0; i < 5; i++) { Entity enemy = Enemy.Create(new Enemy(r.Next(8, SCREENWIDTH - 8), r.Next(8, SCREENHEIGHT - 8))); Engine.AddEntity(enemy); } Entity player = Player.Create(new Player(50, 50, 0, 1)); Engine.AddEntity(player); Entity hud = Hud.Create(new Hud(0, 1, SCREENWIDTH * scale, SCREENHEIGHT * scale)); Engine.AddEntity(hud); Engine.Start(); while (true) { } ; }
public static void Main(string[] args) { GameBuilder builder = new GameBuilder(); Bitmap bmp = BitmapExtensions.CreateBitmap(320 * 4, 240 * 4); bmp.MakeTransparent(); Graphics gfx = Graphics.FromImage(bmp); gfx.Clear(Color.Transparent); VectorD[][] vectors = GenerateNoise(0, 20); double[][] val = new double[240 * 4][]; Func <double, int, int, int> step = (val, steps, max) => ((int)(val * steps) * max) / steps; for (int y = 0; y < 240 * 4; y++) { val[y] = new double[320 * 4]; for (int x = 0; x < 320 * 4; x++) { //val[y][x] = (Noise(vectors, x, y, 320 * 5, 240 * 5) * 0.2 + Noise(vectors, x, y, 320, 240) * 0.1 + Noise(vectors, x, y, 320 * 10, 240 * 10) * 0.7); double[] noises = new double[] { Noise(vectors, x, y, 10, 10) * 0.1, Noise(vectors, x, y, 20 * 5, 20 * 5) * 0.8, Noise(vectors, x, y, 5, 5) * 0.08, Noise(vectors, x, y, 3, 3) * 0.02, }; val[y][x] = noises.Aggregate((total, v) => total + v); int v = StepWithPercent(val[y][x], 255, 0.6, 0.65, 0.8, 1); bmp.SetPixel(x, y, Color.FromArgb(255, v, v, v)); } } MemoryStream stream = new MemoryStream(); bmp.Save(stream, ImageFormat.Bmp); stream.Position = 0; new Sprite("tilemap", "Sprites/SunnysideWorld_Tileset_V0.1.png", 16, 16); //new Sprite("player", "Sprites/player.png", 16, 16); TileMap map = new TileMap(Sprite.Sprites["tilemap"], 320 * 2, 240 * 2); map.BackgroundColor = Brushes.Bisque; Tile[,] mapTiles = new Tile[map.Width / 16, map.Height / 16]; for (int y = 0; y < map.Height / 16; y++) { for (int x = 0; x < map.Width / 16; x++) { double[] noises = new double[] { Noise(vectors, x * 16, y * 16, 10, 10) * 0.1, Noise(vectors, x * 16, y * 16, 20 * 5, 20 * 5) * 0.8, Noise(vectors, x * 16, y * 16, 5, 5) * 0.08, Noise(vectors, x * 16, y * 16, 3, 3) * 0.02, }; int v = 3 - StepWithPercent(noises.Aggregate((total, v) => total + v), 4, 0.5, 0.6, 0.8, 1); mapTiles[x, y] = new Tile((TileType)v); //map[x, y] = f(1 + ((x + y) % 2), 1); } } for (int y = 0; y < map.Height / 16; y++) { for (int x = 0; x < map.Width / 16; x++) { NeighborCalc(mapTiles, x, y); } } for (int y = 0; y < map.Height / 16; y++) { for (int x = 0; x < map.Width / 16; x++) { //NeighborCalc2(mapTiles, x, y); NeighborTransform(mapTiles, x, y); map[x, y] = mapTiles[x, y].Modifier; } } new Sprite("noise", stream, 0, 0); Description2D noiseImg = new Description2D(Sprite.Sprites["noise"], 0, 0, 320 * 4, 240 * 4); builder.GameEngine(new FixedTickEngine(60)) .GameView(new GameView2D(320 * 2, 240 * 2, 2, 2, Color.Bisque)) .GameFrame(new GameEngine.UI.GameFrame(new AvaloniaWindowBuilder(), 0, 0, 320 * 2, 240 * 2, 2, 2)) .StartingLocation(new Location(map)) .Build(); ////builder.Engine.AddEntity(new Entity(noiseImg)); ////builder.Engine.TickEnd += (sender, state) => { d2d.ChangeCoordsDelta(0.1, 0); }; builder.Engine.Start(); while (true) { } }