コード例 #1
0
ファイル: ParticleTests.cs プロジェクト: mao47/393FSG
        public void TestHoldPlaceParticle()
        {
            var pm = new FakeMAOParticleManager(new Rectangle(0, 0, 800, 400), 100000, 1);
            int lastCount = 0;
            int lastAdd = 0;

            FSGGame.controller = new FakeController();
            var c = FSGGame.controller as FakeController;
            c.mousex = 50;
            c.mousey = 50;
            c.a = true;
            GameTime gt = new GameTime(new TimeSpan(0, 0, 0), new TimeSpan(0, 0, 0, 0, 100)); // one millisecond

            var screen = new ParticleTestScreen(new ScreenContainer());
            screen.pm = pm;
            for (int i = 0; i < 5; i++)
            {
                //create some movement to avoid clogging the screen
                c.mousex = 50 + 5*i;
                c.mousey = 50 + i;
                lastAdd = pm.numberParticlesToAdd();
                lastCount = pm.numberParticles();
                screen.Update(gt);
                Assert.Greater(pm.numberParticlesToAdd(), 0);
                /*
                 * total particles should be less than or equal the amount contained + added in the
                 * last step. (there may be overlap in random placement or particles drifting
                 * offscreen to decrease below this number)
                 */
                Assert.LessOrEqual( pm.numberParticles(),lastAdd+lastCount);

            }
        }
コード例 #2
0
ファイル: ParticleTests.cs プロジェクト: mao47/393FSG
        public void TestPlaceParticle()
        {
            var pm = new FakeMAOParticleManager(new Rectangle(0, 0, 800, 400), 100000, 1);

            FSGGame.controller = new FakeController();
            var c = FSGGame.controller as FakeController;
            c.mousex = 50;
            c.mousey = 50;
            c.a = true;
            GameTime gt = new GameTime(new TimeSpan(0, 0, 0), new TimeSpan(0,0,0,0,100)); // one millisecond

            var screen = new ParticleTestScreen(new ScreenContainer());
            screen.pm = pm;
            screen.Update(gt);  //update to put particles on add list
            Assert.Greater(pm.numberParticlesToAdd(), 0);
            c.a = false;
            screen.Update(gt);  //update to put particles in data structure
            //at least one particle was added (can be more from brush)
            Assert.Greater(pm.numberParticles(), 0);
            Assert.AreEqual(0, pm.numberParticlesToAdd());
        }