protected override void Update(GameTime gameTime) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) { Exit(); } base.Update(gameTime); MouseInput.Update(); KeyboardInput.Update(); UI.Update(); Automata.Update(); if (!Paused) { Automata.SimulationStep(); } if (KeyboardInput.CheckPressed(Keys.Space)) { Paused = !Paused; Console.WriteLine(Paused ? "paused" : "unpaused"); } //speed up or slow down simulation if (KeyboardInput.CheckPressed(Keys.Up) && Automata.Refreshrate > 0) { Automata.Refreshrate--; } else if (KeyboardInput.CheckPressed(Keys.Down)) { Automata.Refreshrate++; } }
protected override void Initialize() { Render.Initialize(graphics.GraphicsDevice); MouseInput.Initialize(); KeyboardInput.Initialize(); base.Initialize(); Automata.Initialize(); UI = new UI(Automata.ColorMapping); Console.WriteLine("engine initialized"); Window.Title = "Cellular Automata : " + Automata.Name; }
public void Update() { foreach (Mapping mapping in Mappings) { if (KeyboardInput.CheckPressed(mapping.Key)) { Engine.Instance.Automata.LeftPlace = mapping.Value; color = mapping.Color; fade = 10; break; } } }