Предыдущая Следующая
ball[i].position.Y = rand.Next(50, 80); ball[i].position.Z = -(rand.Next(20, 100));
}
cursor.Load(content, «Content\\Textures\\cursor»]; cursor.spritePosition = new Vector2(400, 300);
}
}
/// <summary>
/// Освобождаем ресурсы
/// <summary>
protected override void UnloadGraphicsContent(bool unloadAllContent)
{
if (unloadAllContent == true)
{
content.Unload();
}
}
/// <summary>
/// Обновляем состояние игры /// <summary>
protected override void Update(GameTime gameTime)
{ }
/// <summary>
/// Рисуем на экране
320 Стреляем по целям
/// <summary>
protected override void Draw(GameTime gameTime) {
graphics.GraphicsDevice.Clear(new Color(159, 147, 207)); switch (gameState)
{
case CurentGameState.SplashScreen:
{
break;
}
case CurentGameState.MenuScreen:
{
break;
}
case CurentGameState.AboutScreen:
{
break;
}
case CurentGameState.GameScreen:
{
graphics.GraphicsDevice.RenderState.DepthBufferEnable = true; view = Matrix.CreateLookAt(camera, Vector3.Zero, Vector3.Up); proj = Matrix.CreatePerspectiveFieldOfView(FOV, aspectRatio, nearClip, farClip); for (int i = 0; ball.Length > i;
{
world = Matrix.CreateTranslation(ball[i].position); ball[i].DrawModel(world, view, proj);
}
spriteBatch.Begin(SpriteBlendMode.AlphaBlend);
cursor.DrawSprite(spriteBatch);
spriteBatch.End();
break;
}
case CurentGameState.GameOverScreen:
{
break;
}
case CurentGameState.VictoryScreen:
{
Целимся и стреляем 321
break;
}
}
base.Draw(gameTime);
}
/// <summary> /// Движение мячей /// <summary> void MoveBall()
{
for (int i = 0; ball.Length > i;
{
ball[i].position.Y -= ball[i].speed;
}
}
/// <summary> /// Прицел /// <summary> void GamePadClick()
{
GamePadState currentState = GamePad.GetState(PlayerIndex.One]; // GamePadThumbSticks Left
if(currentState.ThumbSticks.Left.X < -0.65f]
cursor.spritePosition.X -= 10; else if(currentState.ThumbSticks.Left.X > 0.65f]
cursor.spritePosition.X += 10; if(currentState.ThumbSticks.Left.Y > 0.65f]
cursor.spritePosition.Y -= 10; else if(currentState.ThumbSticks.Left.Y < -0.65f]
cursor.spritePosition.Y += 10;
// Обработка выхода прицела за пределы экрана if(cursor.spritePosition.X < 0]
cursor.spritePosition.X = 0; else if(cursor.spritePosition.X > screenWidth — cursor.spriteTexture.Width]
cursor.spritePosition.X = screenWidth - cursor.spriteTexture.Width; if(cursor.spritePosition.Y < 0]
cursor.spritePosition.Y = 0; else if(cursor.spritePosition.Y > screenHight —cursor.spriteTexture. Hight] Предыдущая Следующая
|