コード例 #1
0
ファイル: engine_game.cs プロジェクト: unk1nd/US_AirForce
        public void Run()
        {
            Initialize();

            InitializeResources();

            while (m_Running)
            {
                m_StopWatch.Reset();
                m_StopWatch.Start();
                Application.DoEvents();
                Engine_Keyboard.Update();
                InternalUpdate();
                Render();

                m_StopWatch.Stop();
                m_CurrentFrameTime = (double)m_StopWatch.ElapsedTicks;

                double delta = m_FrameTime - m_CurrentFrameTime;


                if (delta > 0)
                {
                    m_StopWatch.Reset();
                    m_StopWatch.Start();
                    while ((double)m_StopWatch.ElapsedTicks < delta)
                    {
                        ;
                    }
                    m_StopWatch.Stop();
                    m_CurrentFrameTime += m_StopWatch.ElapsedTicks;
                }
            }
        }
コード例 #2
0
        public override void Update()
        {
            Text = "FPS: " + Engine_Game.CurrentFrameRate.ToString();

            if (Engine_Keyboard.IsTriggered(Key.F9))
            {
                Visible = !Visible;
            }
        }
コード例 #3
0
        public override void Update()
        {
            int vx = 0, vy = 0;

            if (Position.Y > 50 && Engine_Keyboard.IsPressed(Key.UpArrow))
            {
                vy = -2;
            }
            if (Position.Y < 550 && Engine_Keyboard.IsPressed(Key.DownArrow))
            {
                vy = 2;
            }
            if (Position.X > 30 && Engine_Keyboard.IsPressed(Key.LeftArrow))
            {
                vx     = -2;
                ScaleX = 1;
            }

            if (Position.X < 770 && Engine_Keyboard.IsPressed(Key.RightArrow))
            {
                vx     = 2;
                ScaleX = -1;
            }
            if (Engine_Keyboard.IsPressed(Key.LeftShift))
            {
                vx *= 2;
                vy *= 2;
            }

            if (Engine_Keyboard.IsTriggered(Key.Space))
            {
                Shoot fire = (Shoot)Spillet.Fire.Clone();
                fire.Position = new PointF(Position.X, Position.Y - 32);
                fire.Velocity = new Vector2(0, -4);
                Spillet.Add(fire);

                Spillet.Shoot.Play();
                m_shots++;

                Spillet.Shots.Text = "Shots: " + m_shots.ToString();
            }

            Velocity = new Vector2(vx, vy);
        }