static void Start() { const int Width = 1366; const int Height = 768; Raylib.InitWindow(Width, Height, "Harvesturr"); Raylib.SetTargetFPS(60); GUILoadStyle("jungle"); GUIPanelColor = Raylib.Fade(Color.BLACK, 0.8f); GameCamera = new Camera2D(new Vector2(Width, Height) / 2, Vector2.Zero, 0, 2); GameMap.Load("test"); if (DebugPerformance) { const float Dist = 50; Rectangle Rect = GameMap.GetBounds(); Vector2 Pos = new Vector2(Rect.x, Rect.y) + new Vector2(10); int XCount = (int)(Rect.width / Dist); int YCount = (int)(Rect.height / Dist); for (int X = 0; X < XCount; X++) { for (int Y = 0; Y < YCount; Y++) { Spawn(new UnitConduit(Pos + new Vector2(X, Y) * Dist)); } } } else { for (int i = 0; i < 100; i++) { Spawn(new UnitMineral(GameMap.RandomMineralPoint(), Utils.Random(0, 100) > 80)); } } Spawn(new UnitAlienUfo(Vector2.Zero)); GameTools.AddRange(IsGameToolAttribute.CreateAllGameTools()); Resources = 50; if (DebugView) { Resources = int.MaxValue; } // Test /*UnitConduit ConduitA = new UnitConduit(new Vector2(314.844f, 167.216f)); * UnitConduit ConduitB = new UnitConduit(new Vector2(380.955f, 166.661f)); * UnitConduit ConduitC = new UnitConduit(new Vector2(348.513f, 215.875f)); * * Spawn(ConduitA); * Spawn(ConduitB); * Spawn(ConduitC); * Spawn(new UnitEnergyPacket(ConduitA, ConduitB));*/ GameTimer.Restart(); while (!Raylib.WindowShouldClose()) { float FrameTime = Raylib.GetFrameTime(); Time = (float)GameTimer.Elapsed.TotalSeconds; ScreenWidth = Raylib.GetScreenWidth(); ScreenHeight = Raylib.GetScreenHeight(); Lockstep(Time, 1.0f / 60, 1.0f / 10); /*if (FrameTime < 0.5f) * Update(FrameTime); * else * Console.WriteLine("Skipping update, frame time {0} s", FrameTime);*/ Raylib.BeginDrawing(); Raylib.ClearBackground(Color.SKYBLUE); Raylib.BeginMode2D(GameCamera); CurrentDrawState = DrawState.WORLD; DrawWorld(); Raylib.EndMode2D(); CurrentDrawState = DrawState.SCREEN; DrawScreen(); Raylib.EndDrawing(); CurrentDrawState = DrawState.NONE; } Raylib.CloseWindow(); }