当前位置: 首页>>代码示例>>C#>>正文


C# Game.Update方法代码示例

本文整理汇总了C#中Game.Update方法的典型用法代码示例。如果您正苦于以下问题:C# Game.Update方法的具体用法?C# Game.Update怎么用?C# Game.Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Game的用法示例。


在下文中一共展示了Game.Update方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main(string[] args)
        {
            Game g1 = new Game();
            Game g2 = new Game();
            Game g3 = new Game();
            Game g4 = new Game();

            g1.InitGrid(TestData.StillLife.Pond.Cells);
            g2.InitGrid(TestData.Oscillator.Blinker.Cells1);
            g3.InitGrid(TestData.Spaceship.Glider.Cells);
            g4.InitGrid(TestData.Spaceship.HammerHead.RCells);

            while (true)
            {
                Console.Clear();

                //g1.Render();
                //g2.Render();
                //g3.Render();
                g4.Render();

                System.Threading.Thread.Sleep(500);

                //g1.Update();
                //g2.Update();
                //g3.Update();
                g4.Update();
            }
        }
开发者ID:bosonix,项目名称:conway,代码行数:29,代码来源:Program.cs

示例2: Main

        static void Main(string[] args)
        {
            while (true)
            {
                Game game = new Game();
                //initialize
                game.ShowUI();

                GameState state = GameState.InProcess;
                while (state == GameState.InProcess)
                {
                    state = game.Update(Console.ReadLine());
                }

                if (state == GameState.Won)
                    Console.WriteLine("YOU WON!");
                else
                {
                    Console.WriteLine("YOU LOST! The word was '"+game.word+"'");
                }

                if (!WantToPlayAgain())
                    break;

            }
        }
开发者ID:C0DK,项目名称:HangMon,代码行数:26,代码来源:Program.cs

示例3: Main

 public static void Main()
 {
     Game Wumpus = new Game(1366, 768, 60, "Hunt the Wumpus"); //Create a new Game
     GameStateManager.CurrentState = new MainMenu(); //Starting the actual game up :D
     while(!Game.Quit) //The game loop!
     {
         Wumpus.Update(); //Update the game
     }
     Wumpus.Dispose(); //Denitialize everything when the program ends
 }
开发者ID:shloak,项目名称:Hunt-The-Wumpus,代码行数:10,代码来源:HuntTheWumpus.cs

示例4: Test

        public void Test()
        {
            var game = new Game();

            while (true)
            {
                game.Update();
                game.Draw();
                Thread.Sleep(1000);
            }
        }
开发者ID:iivchenko,项目名称:SandBox,代码行数:11,代码来源:Tests.cs

示例5: Form1

        public Form1()
        {
            InitializeComponent();
            Surface surface = Video.SetVideoMode(500, 700, 32, false, false, false, true);

            Game jogo = new Game();
            List<Box> Boxes = new List<Box>();

            SdlDotNet.Core.Events.Quit += new EventHandler<QuitEventArgs>(delegate(object sender, QuitEventArgs args)
            {
                SdlDotNet.Core.Events.QuitApplication();
            });

            SdlDotNet.Core.Events.Fps = 15;

            SdlDotNet.Core.Events.Tick += new EventHandler<TickEventArgs>(delegate(object sender, TickEventArgs args)
            {
                Peca p = jogo.Tabuleiro.PecaAtual;

                if (Keyboard.IsKeyPressed(Key.DownArrow))
                    p.descerUmNivel();
                else if (Keyboard.IsKeyPressed(Key.LeftArrow))
                    p.moverParaEsquerda();
                else if (Keyboard.IsKeyPressed(Key.RightArrow))
                    p.moverParaDireita();
                else if (Keyboard.IsKeyPressed(Key.KeypadEnter) || Keyboard.IsKeyPressed(Key.Return))
                    p.Rotate();

                surface.Fill(Color.Black);

                //Imprime a peça atual
                foreach (Box item in p.Piece)
                    item.Draw(surface, p.Cor, true, true);

                //Imprime as peças do jogo
                foreach (Box item in jogo.GamePieces)
                    item.Draw(surface, Color.Gray, true, true);

                p.Update();
                jogo.Update();

                surface.Update();
            });

            SdlDotNet.Core.Events.Run();
        }
开发者ID:lucassklp,项目名称:Tetris,代码行数:46,代码来源:Form1.cs

示例6: OnReadOnlyMainThread

 // Should use ReadWrite to be correct but that would be too slow
 public override void OnReadOnlyMainThread(Game game, float dt)
 {
     game.Update(dt);
 }
开发者ID:MagistrAVSH,项目名称:manicdigger,代码行数:5,代码来源:GameMisc.ci.cs

示例7: LaunchMissileTowardTarget

 public void LaunchMissileTowardTarget()
 {
     var game = new Game();
     var system = new StarSystem();
     game.Add(system);
     var enemy = new Ship();
     system.AddEntity(enemy);
     var attacker = new Ship() { Tubes = 3 };
     system.AddEntity(attacker);
     game.Update(TimeSpan.FromSeconds(0.25));
     attacker.LoadProjectile(0, ProjectileType.Torpedo);
     enemy.ImpulsePercentage = 100;
     game.Update(TimeSpan.FromSeconds(0.25));
     game.Update(TimeSpan.FromSeconds(0.25));
     game.Update(TimeSpan.FromSeconds(0.25));
     game.Update(TimeSpan.FromSeconds(0.25));
     game.Update(TimeSpan.FromSeconds(0.25));
     game.Update(TimeSpan.FromSeconds(0.25));
     game.Update(TimeSpan.FromSeconds(0.25));
     game.Update(TimeSpan.FromSeconds(0.25));
     game.Update(TimeSpan.FromSeconds(0.25));
     game.Update(TimeSpan.FromSeconds(0.25));
     game.Update(TimeSpan.FromSeconds(0.25));
     game.Update(TimeSpan.FromSeconds(0.25));
     game.Update(TimeSpan.FromSeconds(0.25));
     game.Update(TimeSpan.FromSeconds(0.25));
     game.Update(TimeSpan.FromSeconds(0.25));
     game.Update(TimeSpan.FromSeconds(0.25));
     game.Update(TimeSpan.FromSeconds(0.25));
     game.Update(TimeSpan.FromSeconds(0.25));
     game.Update(TimeSpan.FromSeconds(0.25));
     game.Update(TimeSpan.FromSeconds(0.25));
     Assert.AreNotEqual(0, enemy.Position.X, "The enemy should have moved along the x axis");
     Assert.AreEqual(0, attacker.Position.X, "the attacker was not at the center");
     var missile = attacker.LaunchProjectile(0, enemy);
     Assert.AreEqual(0, missile.Position.X, "the missile was not at the center");
     var oldDiff = enemy.Position.X - missile.Position.X;
     missile.Update(TimeSpan.FromSeconds(0.25));
     var newDiff = enemy.Position.X - missile.Position.X;
     Assert.IsTrue(newDiff < oldDiff, "The missile didn't get closer to the ship");
 }
开发者ID:AdmiralPotato,项目名称:ggj2013,代码行数:41,代码来源:MissileTests.cs

示例8: RunOutOfEnergy

        public void RunOutOfEnergy()
        {
            var game = new Game();
            var system = new StarSystem();
            system.RandomlySpawnEnemies = false;
            game.Add(system);
            var ship = new Ship();
            system.AddEntity(ship);
            ship.ImpulsePercentage = 100;
            Assert.IsTrue(ship.Energy > 0, "Ship didn't have any energy");
            var oldVelocity = ship.Velocity;
            Assert.AreEqual(0, ship.Velocity.Magnitude(), "Ship should be at rest at first");

            for (int i = 0; i < 200; i++)
            {
                game.Update(TimeSpan.FromSeconds(0.25));
                game.Update(TimeSpan.FromSeconds(0.25));
                game.Update(TimeSpan.FromSeconds(0.25));
                game.Update(TimeSpan.FromSeconds(0.25));
                Assert.IsTrue(oldVelocity.Magnitude() < ship.Velocity.Magnitude(), "The ship didn't increase in speed");
                oldVelocity = ship.Velocity;
            }
            Assert.AreEqual(0, ship.Energy, "The ship didn't run out of energy");
            game.Update(TimeSpan.FromSeconds(1));
            Assert.AreEqual(oldVelocity, ship.Velocity, "The ship should not have been able to increase it's velocity without energy.");
            game.Update(TimeSpan.FromSeconds(100000)); // get that ship very far away, so the missile won't detonate
            var missile = new Projectile();
            system.AddEntity(missile);
            missile.Target = ship;
            oldVelocity = missile.Velocity;
            Assert.AreEqual(0, missile.Velocity.Magnitude(), "Missile should be at rest at first.");
            for (int i = 0; i < 20; i++)
            {
                game.Update(TimeSpan.FromSeconds(0.25));
                game.Update(TimeSpan.FromSeconds(0.25));
                game.Update(TimeSpan.FromSeconds(0.25));
                game.Update(TimeSpan.FromSeconds(0.25));
                Assert.IsFalse(missile.IsDestroyed, "the missile got destroyed.");
                Assert.IsTrue(oldVelocity.Magnitude() < missile.Velocity.Magnitude(), "The missile didn't increase in speed");
                oldVelocity = missile.Velocity;
            }
            game.Update(TimeSpan.FromSeconds(0.25));
            game.Update(TimeSpan.FromSeconds(0.25));
            game.Update(TimeSpan.FromSeconds(0.25));
            game.Update(TimeSpan.FromSeconds(0.25));
            Assert.IsFalse(missile.IsDestroyed, "the missile didn't get destroyed.");
            oldVelocity = missile.Velocity;
            game.Update(TimeSpan.FromSeconds(0.25));
            Assert.AreEqual(oldVelocity.Magnitude(), missile.Velocity.Magnitude(), "The missile didn't run out of energy after over 20 seconds");
        }
开发者ID:AdmiralPotato,项目名称:ggj2013,代码行数:50,代码来源:MissileTests.cs

示例9: LoadProjectileLaunchWithoutWaitingAfterLoading

 public void LoadProjectileLaunchWithoutWaitingAfterLoading()
 {
     var game = new Game();
     var system = new StarSystem();
     system.RandomlySpawnEnemies = false;
     game.Add(system);
     var ship = new Ship() { Tubes = 3 };
     system.AddEntity(ship);
     game.Update(TimeSpan.FromSeconds(0.25));
     ship.LoadProjectile(0, ProjectileType.Torpedo);
     var projectile = ship.LaunchProjectile(0, ship);
     Assert.IsNull(projectile, "The projectile shouldn't have been launched if there hasn't been enough time to load it.");
 }
开发者ID:AdmiralPotato,项目名称:ggj2013,代码行数:13,代码来源:MissileTests.cs

示例10: DestroyShip

        public void DestroyShip()
        {
            var game = new Game();
            var system = new StarSystem();
            system.RandomlySpawnEnemies = false;
            game.Add(system);
            var ship = new Ship();
            system.AddEntity(ship);
            ship.ImpulsePercentage = 100;
            Assert.IsTrue(ship.Energy > 0, "Ship didn't have any energy");
            var oldVelocity = ship.Velocity;
            Assert.AreEqual(0, ship.Velocity.Magnitude(), "Ship should be at rest at first");

            for (int i = 0; i < 20; i++)
            {
                game.Update(TimeSpan.FromSeconds(0.25));
                game.Update(TimeSpan.FromSeconds(0.25));
                game.Update(TimeSpan.FromSeconds(0.25));
                game.Update(TimeSpan.FromSeconds(0.25));
                Assert.IsTrue(oldVelocity.Magnitude() < ship.Velocity.Magnitude(), "The ship didn't increase in speed");
                oldVelocity = ship.Velocity;
            }
            var missile = new Projectile();
            system.AddEntity(missile);
            missile.Target = ship;
            oldVelocity = missile.Velocity;
            Assert.AreEqual(0, missile.Velocity.Magnitude(), "Missile should be at rest at first.");
            for (int i = 0; i < 9; i++)
            {
                game.Update(TimeSpan.FromSeconds(0.25));
                game.Update(TimeSpan.FromSeconds(0.25));
                game.Update(TimeSpan.FromSeconds(0.25));
                game.Update(TimeSpan.FromSeconds(0.25));
                Assert.IsFalse(missile.IsDestroyed, "the missile got destroyed.");
                Assert.IsTrue(oldVelocity.Magnitude() < missile.Velocity.Magnitude(), "The missile didn't increase in speed");
                oldVelocity = missile.Velocity;
            }
            game.Update(TimeSpan.FromSeconds(0.25));
            game.Update(TimeSpan.FromSeconds(0.25));
            game.Update(TimeSpan.FromSeconds(0.25));
            game.Update(TimeSpan.FromSeconds(0.25));
            Assert.IsTrue(missile.IsDestroyed, "the missile didn't get destroyed.");
            oldVelocity = missile.Velocity;
            game.Update(TimeSpan.FromSeconds(0.25));
            Assert.AreEqual(oldVelocity.Magnitude(), missile.Velocity.Magnitude(), "The (dead) missile didn't increase in speed");
        }
开发者ID:AdmiralPotato,项目名称:ggj2013,代码行数:46,代码来源:MissileTests.cs

示例11: LoadProjectileLaunchWithoutLoading

 public void LoadProjectileLaunchWithoutLoading()
 {
     var game = new Game();
     var system = new StarSystem();
     system.RandomlySpawnEnemies = false;
     game.Add(system);
     var ship = new Ship() { Tubes = 3 };
     system.AddEntity(ship);
     game.Update(TimeSpan.FromSeconds(0.25));
     var projectile = ship.LaunchProjectile(0, ship);
     Assert.IsNull(projectile, "The projectile shouldn't have been launched if it hadn't been loaded.");
 }
开发者ID:AdmiralPotato,项目名称:ggj2013,代码行数:12,代码来源:MissileTests.cs

示例12: LoadProjectileDoubleLoad

 public void LoadProjectileDoubleLoad()
 {
     var game = new Game();
     var system = new StarSystem();
     system.RandomlySpawnEnemies = false;
     game.Add(system);
     var ship = new Ship() { Tubes = 3 };
     system.AddEntity(ship);
     game.Update(TimeSpan.FromSeconds(0.25));
     var loaded = ship.LoadProjectile(0, ProjectileType.Torpedo);
     Assert.IsTrue(loaded, "Couldn't load the first projectile");
     loaded = ship.LoadProjectile(0, ProjectileType.Torpedo);
     Assert.IsFalse(loaded, "Somehow Loaded a second projectile.");
 }
开发者ID:AdmiralPotato,项目名称:ggj2013,代码行数:14,代码来源:MissileTests.cs

示例13: Main

    static void Main(String[] args)
    {
        var game = new Game();
        game.Init();

        while (true) {
            game.Update();
            game.Play();
            foreach (var drone in game.MyPlayer.Drones)
            {
                Console.WriteLine(String.Format("{0} {1}", drone.TargetX, drone.TargetY));
            }
        }
    }
开发者ID:CodinGame,项目名称:gameofdrones,代码行数:14,代码来源:Player1.cs


注:本文中的Game.Update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。