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); }
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); } }