public static void DefaultClient_Load() { _networkConnector = new JQueryAjaxNetworkConnector(); new jQuery(HtmlContext.document.body).append("Ready<br/>"); new jQuery(HtmlContext.document.body).keydown(DocumentKeyDown); new jQuery(HtmlContext.document.body).keyup(DocumentKeyUp); new jQuery(HtmlContext.document.body).mousedown(DocumentMouseDown); new jQuery(HtmlContext.document.body).mousedown(DocumentMouseUp); // Notify server of local player join ConnectToServer(); // On server response, create local player assets // CreateCharacter(); // Load remote player data HeartBeat.Initialize(); ClientRenderer.Initialize(); }
public static void MainLoop() { //get starting time DateTime start = DateTime.Now; // Input stuff // If key is down, change destination //perform calculations //perform renders ClientRenderer.Render(); //get frame interval millis double frameInterval = (1.0 / MaxFrameRate) * 1000; DateTime end = DateTime.Now; int frameTime = end.Subtract(start).Milliseconds; if (frameTime > frameInterval) { HtmlContext.window.setTimeout(MainLoop, 0); } else { HtmlContext.window.setTimeout(MainLoop, (int)frameInterval - frameTime); } }