Example #1
0
        public void Update()
        {
            lastTime    = currentTime;
            currentTime = stopwatch.ElapsedMilliseconds;
            deltaTime   = (currentTime - lastTime) / 1000.0f;
            timer      += deltaTime;
            if (timer >= 1)
            {
                fps    = frames;
                frames = 0;
                timer -= 1;
            }
            frames++;

            //Update game objects here
            m_Level.Update(deltaTime);
            m_Level.UpdateTransforms();

            CollisionManager.CheckCollision();
        }
Example #2
0
        public override void Update(float _deltatime)
        {
            m_MousePosition  = GetMousePosition().ToVector2();
            currentGlobalPos = GetGlobalPosition();
            targetDirection  = m_MousePosition - currentGlobalPos;
            targetDirection.Normalise();

            float rotation = 0.0f;

            if (IsKeyDown(KeyboardKey.KEY_RIGHT))
            {
                rotation += m_TurretTurnSpeed * _deltatime;
            }
            if (IsKeyDown(KeyboardKey.KEY_LEFT))
            {
                rotation -= m_TurretTurnSpeed * _deltatime;
            }

            if (IsKeyPressed(KeyboardKey.KEY_SPACE))
            {
                FireGun();
                CollisionManager.AddObject(m_Bullet);
            }

            Matrix3 rotationMatrix = new Matrix3();

            rotationMatrix.SetRotateZ(rotation);

            m_LocalTransform = m_LocalTransform * rotationMatrix;

            m_Bullet.Update(_deltatime);
            m_Bullet.UpdateTransforms();

            m_Bullet.SetRotation(rotation);

            base.Update(_deltatime);
        }
Example #3
0
        public void Update()
        {
            #region DeltaTime
            lastTime    = currentTime;
            currentTime = stopwatch.ElapsedMilliseconds;
            deltaTime   = (currentTime - lastTime) / 1000.0f;
            timer      += deltaTime;
            if (timer >= 1)
            {
                fps    = frames;
                frames = 0;
                timer -= 1;
            }
            frames++;
            #endregion

            //Update game objects here

            m_Level.Update(deltaTime);
            m_Level.UpdateTransforms();

            //Check collision after all objects have been updated
            CollisionManager.CheckCollision();
        }
Example #4
0
        public void Destroy()
        {
            SetAlive(false);

            CollisionManager.RemoveObject(this);
        }