public void Update(float delta) { world.Update(delta); if (Keyboard.GetState().IsKeyDown(Key.Space)) { world.Monster.Map.AddEntity(new NPC(new Vector2(0, 0))); } }
public void Update(float deltaTime) { EventManager.Tick(); if (IsRunning) { World.Update(deltaTime); ProcessManager.Update(deltaTime); CollisionManager.DetectAndResolveCollisions(); checkForVictoryConditions(); } }
static void Main(string[] args) { World world = new World(); using (var game = new GameWindow(400, 400)) { game.Load += (sender, e) => { game.VSync = VSyncMode.On; GL.MatrixMode(MatrixMode.Projection); GL.LoadIdentity(); GL.Ortho(0, game.Width, game.Height, 0, 0.0, 0.0); }; game.Resize += (sender, e) => { GL.Viewport(0, 0, game.Width, game.Height); }; game.UpdateFrame += (sender, e) => { if (game.Keyboard[Key.Escape]) { game.Exit(); } world.Update(); }; game.RenderFrame += (sender, e) => { GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); GL.Ortho(0, game.Width, game.Height, 0, -1, 1); GL.MatrixMode(MatrixMode.Modelview); GL.LoadIdentity(); GL.Begin(PrimitiveType.LineLoop); GL.Color3(Color.Pink); GL.Vertex2(0, 0); GL.Vertex2(400, 400); GL.End(); world.Render(); game.SwapBuffers(); }; game.Run(60.0); } }
void DrawGame(GameTime gameTime) { if (GameClass.GameActive && GameClass.HasFocus) { ////#if DEBUG // if (Keys.S.Pressed() && Keys.LeftControl.Down()) // { // World.SaveCurrentStateInBuffer(); // File.WriteAllBytes("TestDump", World.WorldBytes); // } // if (Keys.L.Pressed() && Keys.LeftControl.Down()) // { // //World.LoadStateFromBuffer(); // World.Reload(World.SimStep, World.WorldBytes); // } ////#endif // if (Keys.D.Pressed() && Keys.LeftControl.Down()) // { // World.SynchronizeNetwork(); // } if (World.MapEditorActive) { if (Keys.S.Pressed() && InputHelper.CtrlDown() && InputHelper.ShiftDown()) { SendCommand("save-as"); } else if (Keys.S.Pressed() && InputHelper.CtrlDown()) { SendCommand("save"); } else if (Keys.L.Pressed() && InputHelper.CtrlDown()) { SendCommand("load"); } } World.Update(); UpdateJsData(); UpdateParams(); } World.Draw(); }
public virtual void MakeStep() { if (!m_initialized) { Init(); } // Controls should be already set if (LuaScriptPath != "") { World.RunLuaScript(LuaScriptPath); LuaScriptPath = ""; } World.Update(); Renderer.ProcessRequests(); }