Предыдущая Следующая
score4 += 1;
}
}
/// <summary>
/// Новая игра
/// <summary>
public void NewGame()
{
j = 0;
for (int i = 0; sprite.Length > i;
{
sprite[i].spritePosition = new Vector2(rand.Next(10, Window.ClientBounds.Width - 500), j = j - 300);
}
platform.spritePosition = new Vector2(Window.ClientBounds.Width/ 2, Window.ClientBounds.Height - 90); score0 = 0;
score1 = 0; score2 = 0; score3 = 0; score4 = 0; base.Initialize();
}
/// <summary>
/// Обновляем состояние мыши
/// <summary>
public void UpdateMouse()
{
// Получаем местонахождение курсора мыши mouseState = Mouse.GetState(); mouse.spritePosition.X = mouseState.X; mouse.spritePosition.Y = mouseState.Y;
// Создаем ограничивающие прямоугольники для курсора и табличек bbMouse.Min = new Vector3(mouse.spritePosition.X, mouse.spritePosition.Y, 0);
bbMouse.Max = new Vector3(mouse.spritePosition.X + mouse.spriteTexture.Width,
mouse.spritePosition.Y + mouse.spriteTexture.Height, 0);
bbCursorGame.Min = new Vector3(650, 400, 0); bbCursorGame.Max = new Vector3(950, 500, 0);
bbCursorExit.Min = new Vector3(650, 600, 0); bbCursorExit.Max = new Vector3(950, 700, 0);
// Обрабатываем пересечение прямоугольников if (bbMouse.Intersects(bbCursorGame))
{
menu.cursorPositionGame = new Vector2(650, 400); menu.cursorPositionExit = new Vector2(700, 550); cursorState = 1;
}
if (bbMouse.Intersects(bbCursorExit))
{
menu.cursorPositionGame = new Vector2(700, 400); menu.cursorPositionExit = new Vector2(650, 550); cursorState = 2;
}
// Обрабатываем нажатие левой кнопки мыши if(mouseState.LeftButton = = ButtonState.Pressed && bbMouse.Intersects(bbCursorGame))
{
this.NewGame(); menuState = false;
}
else if(mouseState.LeftButton = = ButtonState.Pressed && bbMouse.Intersects(bbCursorExit))
194 Создаем игровое меню
{
this.Exit();
}
}
/// <summary>
/// Рисуем на экране
/// <summary>
protected override void Draw(GameTime gameTime)
{
graphics.GraphicsDevice.Clear(Color.CornflowerBlue); if (menuState == true)
{
spriteBatch.Begin(SpriteBlendMode.AlphaBlend); menu.DrawMenu(spriteBatch, cursorState); mouse.DrawSprite(spriteBatch); spriteBatch.End();
}
else
{
spriteBatch.Begin(SpriteBlendMode.AlphaBlend);
spriteBatch.Draw(background1, new Vector2(0, 0), Color.White); for (int i = 0; sprite.Length > i;
{
sprite[i].DrawAnimationSprite(spriteBatch);
}
spriteBatch.Draw(background2, new Vector2(0, 0), Color.White);
platform.DrawSprite(spriteBatch); Предыдущая Следующая
|