Предыдущая Следующая
protected override void Initialize()
{
GraphicsAdapter adapter =
graphics.GraphicsDevice.CreationParameters.Adapter;
graphics.PreferredBackBufferWidth = adapter.CurrentDisplayMode.Width; graphics.PreferredBackBufferHeight = adapter.CurrentDisplayMode.Height; graphics.IsFullScreen = true; graphics.ApplyChanges();
screenWidth = graphics.PreferredBackBufferWidth; screenHeight = graphics.PreferredBackBufferHeight; aspectRatio = (float)screenWidth / (float)screenHeight; base.Initialize();
312 Стреляем по целям
}
/// <summary>
/// Загрузка компонентов игры /// <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(20, 150));
}
}
}
/// <summary>
/// Освобождаем ресурсы
/// <summary>
protected override void UnloadGraphicsContent(bool unloadAllContent)
{
if (unloadAllContent == true)
{
content.Unload();
}
}
/// <summary>
/// Обновляем состояние игры /// <summary>
protected override void Update(GameTime gameTime)
{
keyboardState = Keyboard.GetState(); switch (gameState)
{
case CurentGameState.SplashScreen:
{
break;
}
case CurentGameState.MenuScreen:
{
break;
Целимся и стреляем 313
}
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);
}
/// <su^ary>
/// Рисуем на экране
/// <summary>
protected override void Draw(GameTime gameTime)
{
graphics.GraphicsDevice.Clear(Color.CornflowerBlue); switch (gameState)
{
case CurentGameState.SplashScreen:
{
break;
}
case CurentGameState.MenuScreen:
{
break;
}
314 Стреляем по целям
Целимся и стреляем 315
case CurentGameState.AboutScreen:
{
break;
}
case CurentGameState.GameScreen:
{
graphics.GraphicsDevice.RenderState.DepthBufferEnable = true;
view = Matrix.CreateLookAt(new Vector3(0.0f, 0.0f, 150.0f), Vector3.Zero, Предыдущая Следующая
|