public bool Initialize(AppWindow Window, int WorldRows, int WorldColumns) { WorldInst = new World(); if (!WorldInst.Initialize(WorldRows, WorldColumns)) { return(false); } ItemSpawnerInst = new ItemSpawner(); if (!ItemSpawnerInst.Initialize(WorldInst)) { return(false); } SnakeInst = new Snake(); if (!SnakeInst.Initialize(WorldInst, ItemSpawnerInst)) { return(false); } InputInst = new Input(); if (!InputInst.Initialize(Window)) { return(false); } return(true); }
public void Initialize(double GameUpdateRate, int WorldRows, int WorldColumns, string WindowTitle, Size WindowSize) { UpdateRate = GameUpdateRate; Rows = WorldRows; Columns = WorldColumns; Thread WindowThread = new Thread(() => { Window = new AppWindow(); Window.Title = WindowTitle; Window.Size = WindowSize; Window.TargetUpdateFrequency = 1.0d; if (!Window.Initialize(Rows, Columns)) { throw new Exception("Failed to Initialize Window"); } Window.Run(1.0d, 60.0d); }); WindowThread.Start(); // Wait Until Window's Memory is Initialized. while (Window == null) { Thread.Yield(); } // Wait Until Window is Ready for Usage. while (!Window.Ready) { Thread.Yield(); } // Wait Until the User has Entered a Username. while (Window.ActiveScreen != Screen.Menu) { Thread.Yield(); } Window.SessionEndCallback( () => { InSession = false; SessionReady = false; }); Window.GetScoresCallback( () => { if (ScoreServiceOnline) { Window.FillHighscores(Scoring.GetHighscores()); } }); ScoreServiceOnline = true; Scoring = new ScoreService(); if (!Scoring.Initialize()) { ScoreServiceOnline = false; } IPEndPoint ScoringServiceEndPoint = new IPEndPoint(IPAddress.Parse("10.16.1.100"), 6710); if (ScoreServiceOnline) { if (!Scoring.Connect(ScoringServiceEndPoint)) { ScoreServiceOnline = false; Scoring.DisposeFromInitializationError(); } } }
public bool Initialize(AppWindow WindowInst) { WindowInst.KeyPress += KeyPress; return(true); }