Ejemplo n.º 1
0
 public override void OnFixedUpdate(float time)
 {
     if (QInput.Pressed(QKeyStates.Escape))
     {
         Window.Exit();
     }
     if (QInput.Pressed(QKeyStates.R))
     {
         Window.Reset();
     }
 }
Ejemplo n.º 2
0
 public override void OnUpdate(QTime time)
 {
     if (QInput.Held(QKeyStates.W))
     {
         Transform.Position += QVec.Up * speed * time.Delta;
     }
     if (QInput.Held(QKeyStates.A))
     {
         Transform.Position += QVec.Left * speed * time.Delta;
     }
     if (QInput.Held(QKeyStates.S))
     {
         Transform.Position += QVec.Down * speed * time.Delta;
     }
     if (QInput.Held(QKeyStates.D))
     {
         Transform.Position += QVec.Right * speed * time.Delta;
     }
     if (QInput.Pressed(QKeyStates.Tab))
     {
         Scene.ResetScene();
     }
     if (QInput.Held(QKeyStates.Space) && Accumulator.CheckAccum("ball", 0.06f))
     {
         Instantiate(new QDemoCircle());
     }
     if (QInput.Pressed(QMouseStates.Up))
     {
         Camera.Zoom += Camera.Zoom * 0.1f;
     }
     if (QInput.Pressed(QMouseStates.Down))
     {
         Camera.Zoom -= Camera.Zoom * 0.1f;
     }
     if (QInput.Pressed(QMouseStates.Forward))
     {
         Console.WriteLine("forwardsMouseButtonDown");
     }
     if (QInput.Pressed(QMouseStates.Backward))
     {
         Console.WriteLine("backwardsMouseButton");
     }
     if (QInput.Pressed(QMouseStates.Middle))
     {
         Console.WriteLine("middleMouseButton");
     }
     Camera.Lerp(Transform.Position, 5, time.Delta);
 }
Ejemplo n.º 3
0
        public override void OnFixedUpdate(float time)
        {
            Collision = new QRect(Transform.Position - new QVec(sprite.Width / 2f - 5), new QVec(Movement - 5));
            if (Collision.Intersects(fruit.Collision))
            {
                var body = new SnakeBody();
                Bodies.Insert(0, body);
                Instantiate(body, LastPosition);
                fruit.NewLocation();
                //snakeMoveSpeed -= snakeMoveSpeed * 0.05f;
                Points++;
            }
            if (Bodies.Count > 0)
            {
                Bodies[0].Transform.Position = LastPosition;
            }
            for (int i = 0; i < Bodies.Count; i++)
            {
                if (Collision.Intersects(Bodies[i].Collision))
                {
                    Scene.Destroy(this);
                }
                //Bodies[i + 1].PreviousPosition = Bodies[i].PreviousPosition;
            }
            if (QInput.Held(QKeyStates.W))
            {
                CurrentDir = SnakeDirection.Up;
            }
            if (QInput.Held(QKeyStates.S))
            {
                CurrentDir = SnakeDirection.Down;
            }
            if (QInput.Held(QKeyStates.A))
            {
                CurrentDir = SnakeDirection.Left;
            }
            if (QInput.Pressed(QKeyStates.D))
            {
                CurrentDir = SnakeDirection.Right;
            }

            if (!Camera.IsInCameraView(Transform.Position))
            {
                Scene.Destroy(this);
            }
        }
Ejemplo n.º 4
0
 public override void OnFixedUpdate(float time)
 {
     if (QInput.Pressed(QKeyStates.R))
     {
         Scene.SpriteRenderer.ClearColor = QColor.Red;
     }
     else if (QInput.Pressed(QKeyStates.B))
     {
         Scene.SpriteRenderer.ClearColor = QColor.Blue;
     }
     else if (QInput.Pressed(QKeyStates.G))
     {
         Scene.SpriteRenderer.ClearColor = QColor.Green;
     }
     else if (QInput.Pressed(QKeyStates.Escape))
     {
         Window.Exit();
     }
 }
Ejemplo n.º 5
0
 public void OnLateUpdate()
 {
     if (DebugLevel > 0)
     {
         Label.Visible = true;
         Label.Append($"FrameDelay: {QTime.Latency}ms\nFPS: {QTime.CurrentFramesPerSecond}\n" +
                      $"TotalFrames: {QTime.TotalFrames}\nTime: {QTime.TotalSeconds} seconds");
         Transform.Position =
             new QVector2(Window.Bounds.Left, Window.Bounds.Bottom - Label.Measure(Label.Text).Y);
     }
     else
     {
         Label.Visible = false;
     }
     if (QInput.Pressed(QKeyStates.F12))
     {
         DebugLevel++;
         if (DebugLevel == 3)
         {
             DebugLevel = 0;
         }
     }
 }