Предыдущая Следующая
{
graphics = new GraphicsDeviceManager(this); content = new ContentManager(Services);
for (int i = 0; ball.Length > i;
{
ball[i] = new ModelClass();
}
}
/// <summary> /// Инициализация /// <summary>
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();
}
/// <summary>
/// Загрузка компонентов игры /// <summary>
protected override void LoadGraphicsContent(bool loadAllContent)
{
if (loadAllContent)
{
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>
302 Движение моделей в пространстве
Случайный выбор позиции на экране 303
/// Обновляем состояние игры /// <summary>
protected override void Update(GameTime gameTime)
{
keyboardState = Keyboard.GetState(); switch (gameState)
{
case CurentGameState.SplashScreen:
{
break;
}
case CurentGameState.MenuScreen:
{
break;
}
case CurentGaimeState.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:
{
graphics.GraphicsDevice.RenderState.DepthBufferEnable = true; Предыдущая Следующая
|