static void Main(string[] args) { using (new AgateWinForms(args) .AssetPath("Assets") .Initialize()) using (new DisplayWindowBuilder(args) .BackbufferSize(500, 400) .Build()) { // Load the resource file and initialize the resource manager. var resourceLoader = new ResourceDataLoader(); var resourceManager = new AgateResourceManager(resourceLoader.Load("resources.yaml")); // Create the object which will hold the UI. var facet = new MyFacet(); resourceManager.InitializeContainer(facet); // If the user hits escape or the B button on a game controller, // exit the program. facet.MainMenu.MenuCancel += (sender, e) => { AgateApp.IsAlive = false; }; // Attach a handler to each menu item if the user // hits enter, the A button on a game controller, or // clicks it with the mouse. facet.StartItem.PressAccept += (sender, e) => { facet.StartLabel.Text = "Thanks for starting the game!"; }; facet.QuitItem.PressAccept += (sender, e) => { AgateApp.IsAlive = false; }; // Install the user interface so that it captures input. Input.Handlers.Add(facet.InterfaceRoot); // Run the game loop while (AgateApp.IsAlive) { // Update the UI outside a BeginFrame..EndFrame section. facet.InterfaceRoot.OnUpdate(AgateApp.ApplicationClock.Elapsed, true); Display.BeginFrame(); Display.Clear(Color.Gray); // Draw the UI as the last thing before Display.EndFrame. facet.InterfaceRoot.Draw(); Display.EndFrame(); AgateApp.KeepAlive(); } } }
public void No_shots_no_bodies() { var cache = TtlCache<MyFacet, MyBody>.New(); var body = new MyBody(); var facet = new MyFacet(); cache.Store(facet, body); var bodies = cache.GetDeadBodies(1.Milliseconds()); Assert.Null(bodies); }
public void Item_should_be_removed_after_its_deatch() { var cache = TtlCache<MyFacet, MyBody>.New(); var body = new MyBody(); var facet = new MyFacet(); cache.Store(facet, body); facet = null; var bodies = shoot_dead_bodies(cache); Assert.That(bodies[0], Is.SameAs(body)); }
public void Double_reference_Item_should_be_removed_after_its_deatch() { var cache = TtlCache<MyFacet, MyBody>.New(); var body = new MyBody(); var facet = new MyFacet(); var facet2 = new MyFacet(); cache.Store(facet, body); cache.Store(facet2, body); cache.Store(facet, body); // should be ignored facet = null; var bodies = shoot_dead_bodies(cache); Assert.Null(bodies); facet2 = null; bodies = shoot_dead_bodies(cache); Assert.That(bodies[0], Is.SameAs(body)); }