Предыдущая Следующая
/// Загрузка компонентов игры /// <summary>
protected override void LoadGraphicsContent(bool loadAllContent)
{
if (loadAllContent)
{
spriteBatch = new SpriteBatch(graphics.GraphicsDevice); cursor.Load(content, "Content\\Textures\\cursor"); ball[0].Load(content, "Content\\Models\\Soccerball"); ball[1].Load(content, "Content\\Models\\SoccerballGreen"); ball[2].Load(content, "Content\\Models\\SoccerballRed"); for (int i = 0; ball.Length > i;
{
ball[i].position.X = rand.Next(-(rand.Next(0, 80)), rand.Next(0, 80));
ball[i].position.Y = rand.Next(0, 80); ball[i].position.Z = rand.Next(-(rand.Next(0, 50)), rand.Next(0, 150));
}
stadium.Load(content, "Content\\Models\\stadium 1"); stadium.position = new Vector3(0, 0, 0); background
=content.Load<Texture2D>("Content\\Textures\\hallake001");
}
}
/// <summary>
/// Освобождаем ресурсы
/// <summary>
protected override void UnloadGraphicsContent(bool unloadAllContent)
{
if (unloadAllContent == true)
{
326 Формируем трехмерную сцену
Небо и тучи 327
content.Unload();
}
}
/// <summary>
/// Обновляем состояние игры /// <summary>
protected override void Update(GameTime gameTime)
{
keyboardState = Keyboard.GetState(); switch (gameState)
{
case CurentGameState.SplashScreen:
{
break;
}
case CurentGameState.MenuScreen:
{
break;
}
case CurentGameState.AboutScreen:
{
break;
}
case CurentGameState.GameScreen:
{
if (keyboardState.IsKeyDown(Keys.Escape)) this.Exit();
MoveBall(); MouseClick(); break;
}
case CurentGameState.GameOverScreen:
{
break;
}
case CurentGameState.VictoryScreen:
{
break;
} }
base.Update(gameTime);
}
/// <summary>
/// Рисуем на экране
/// <summary>
protected override void Draw(GameTime gameTime)
{
graphics.GraphicsDevice.Clear(Color.CornflowerBlue); switch (gameState)
{
case CurentGameState.SplashScreen:
{
break;
}
case CurentGameState.MenuScreen:
{
break;
}
case CurentGameState.AboutScreen:
{
break;
}
case CurentGameState.GameScreen:
{
spriteBatch.Begin(SpriteBlendMode.AlphaBlend);
spriteBatch.Draw(background, new Vector2(0, -50), Color.White); spriteBatch.End();
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); Предыдущая Следующая
|