private void test() { Point st = Point.Empty; Point en = Point.Empty; bool[,] m = load("paths/maze.astar", out st, out en); //st = new Point(200, 0); //en = new Point(999, 999); //st = new Point(3, 0); //en = new Point(7, 9); for (int x = 0; x < 1000; x++) { for (int y = 0; y < 1000; y++) { Block *b = translateToPointer(x, y); (*b).TypeID = (short)(m[x, y] ? Globals.RESOURCE_WOOD : Globals.TERRAIN_GRASS); } } updateConcreteMatrix(); IPathfinderContext ctx = Pathfinder.ASCreateContext(p_Width, p_Height); while (true) { int time = Environment.TickCount; List <Point> path = Pathfinder.ASSearch( ctx, st, en, p_ConcreteMatrix); Console.WriteLine((Environment.TickCount - time) + "ms for " + path.Count + " items"); for (int c = 0; c < path.Count; c++) { Point p = path[c]; Block *bl = translateToPointer(p.X, p.Y); (*bl).Selected = true; } break; } }
public Game(GameWindow wnd) { p_Window = wnd; /*hook crash events at the first opportunity.*/ Application.ThreadException += handleCrash; /*fullscreen*/ p_Window.Shown += delegate(object s, EventArgs e) { //p_Window.ToggleFullscreen(); p_Window.Focus(); p_Window.BringToFront(); cmd("warp 0 0"); cmd("zoom 0 0"); cmd("toggle debug"); cmd("toggle debug full"); cmd("toggle fog"); cmd("toggle los"); testCode(); }; /*initialize hotloader*/ p_Hotloader = new Hotloader(); /*initialize the camera*/ p_Camera = new Camera(this); /*initialize map*/ p_Map = new Map(this, 1000, 1000); p_MapRenderer = new MapRenderer(this, p_Map, p_Camera); /*setup camera position*/ p_Camera.ZoomAbs(32); p_Camera.MoveCenter(250, 250); /*init sub-systems*/ initUI(); initMouse(); initPlayers(); initLogic(); initDebug(); initDraw(); /*hook events*/ p_Cursor.HookEvents(); wnd.Click += handleMouseClick; wnd.MouseWheel += handleMouseScroll; wnd.MouseMove += handleMouseMove; wnd.MouseUp += handleMouseUp; wnd.KeyDown += handleKeyDown; wnd.KeyUp += handleKeyUp; wnd.Resize += handleResize; wnd.GotFocus += handleFocusChanged; wnd.LostFocus += handleFocusChanged; unsafe { IPathfinderContext ctx = Pathfinder.ASCreateContext(p_Map.Width, p_Map.Height); while (true) { break; int time = Environment.TickCount; //break; List <Point> lol = Pathfinder.ASSearch( ctx, Point.Empty, new Point(p_Map.Width - 1, p_Map.Height - 1), p_Map.GetConcreteMatrix(true)); Console.WriteLine((Environment.TickCount - time) + "ms for " + lol.Count + " items"); } } wnd.HookCoreEvents(); p_Camera.EnableMargin = true; p_Camera.SetMargin(10, 10); }