/** * Method to update the bird. **/ private void Update() { switch (state) { default: case State.WaitingToStart: if (TestInput()) { // Start playing state = State.Playing; birdRigidbody2D.bodyType = RigidbodyType2D.Dynamic; Jump(); if (OnStartedPlaying != null) { OnStartedPlaying(this, EventArgs.Empty); } } break; case State.Playing: if (TestInput()) { Jump(); } // Rotate bird as it jumps and falls transform.eulerAngles = new Vector3(0, 0, birdRigidbody2D.velocity.y * .15f); break; case State.Dead: break; case State.Question: if (Question != null) { Question(this, EventArgs.Empty); } if (Answers != null) { Answers(this, EventArgs.Empty); } if (waiting == false) { state = State.Playing; birdRigidbody2D.bodyType = RigidbodyType2D.Dynamic; questionWindow.Hide(); answersWindow.Hide(); waiting = true; if (OnStartedPlaying != null) { OnStartedPlaying(this, EventArgs.Empty); } } break; case State.Feedback: if (Feedback != null) { Feedback(this, EventArgs.Empty); } if (waiting == false) { state = State.Playing; birdRigidbody2D.bodyType = RigidbodyType2D.Dynamic; feedbackWindow.Hide(); waiting = true; wrongAnswer(); if (wrongAnswer() == false) { if (OnStartedPlaying != null) { OnStartedPlaying(this, EventArgs.Empty); } } if (wrongAnswer() == true) { if (OnDied != null) { OnDied(this, EventArgs.Empty); } } } break; } aboveMap(); }
static void Main() { string s; TextWindow.Show(); // запрашиваем размер еды и проверяем на допустимость do { TextWindow.WriteLine("Введите размер еды от 10 до 50px"); s = TextWindow.Read(); } while (!((int.TryParse(s, out int i)) && int.Parse(s) >= 10 && int.Parse(s) <= 50)); TextWindow.Hide(); int eatSize = int.Parse(s); Turtle.Speed = 4; Turtle.PenUp(); GraphicsWindow.CanResize = false; GraphicsWindow.BrushColor = "Red"; var eat = Shapes.AddRectangle(eatSize, eatSize); int x = 200; int y = 200; Shapes.Move(eat, x, y); Random rand = new Random(); GraphicsWindow.Title = "Погнали!"; GraphicsWindow.KeyDown += GraphicsWindow_KeyDown; while (true) { Turtle.Move(10); if (Turtle.X >= x && Turtle.X <= x + eatSize && Turtle.Y >= y && Turtle.Y <= y + eatSize) { if (Turtle.Speed < 9) { Turtle.Speed++; } if (Turtle.Speed < 9) { GraphicsWindow.Title = "Переключились на скорость: " + (Turtle.Speed - 3); } else if (Turtle.Speed == 9 && GraphicsWindow.BrushColor != "Yellow") { GraphicsWindow.Title = "Вышли на максимальную скорость!"; GraphicsWindow.BackgroundColor = "Red"; GraphicsWindow.BrushColor = "Yellow"; Shapes.Remove(eat); eat = Shapes.AddRectangle(eatSize, eatSize); } x = rand.Next(eatSize, GraphicsWindow.Width - eatSize); y = rand.Next(eatSize, GraphicsWindow.Height - eatSize); Shapes.Move(eat, x, y); } } }