Предыдущая Следующая
//=========================================================================
/// <summary>
/// Листинг 21.1
/// Исходный код к книге:
/// "Программирование компьютерных игр под Windows в XNA Game Studio Express"
/// Автор книги: Горнаков С. Г.
/// Глава 21
/// Проект: Plane
/// Класс: Game1
/// Трехмерная сцена
/// <summary>
//=========================================================================
#region Using Statements using System;
using System.Collections.Generic; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics;
324 Формируем трехмерную сцену
Небо и тучи 325
using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Storage; #endregion
namespace Plane {
public class Gamel : Microsoft.Xna.Framework.Game
{
private enum CurentGameState
{
SplashScreen,
MenuScreen,
AboutScreen,
GameScreen,
GameOverScreen,
VictoryScreen
}
CurentGameState gameState = CurentGameState.GameScreen;
GraphicsDeviceManager graphics; ContentManager content; KeyboardState keyboardState; int screenWidth, screenHeight;
Matrix view; Matrix proj; Matrix world;
static float aspectRatio;
static float FOV = MathHelper.PiOver4;
static float nearClip = 1.0f;
static float farClip = 1000.0f;
private ModelClass[] ball = new ModelClass[3]; MouseState mouseState; Random rand = new Random();
SpriteBatch spriteBatch; Sprite cursor;
public BoundingSphere[] bb = new BoundingSphere[3]; Vector3 camera = new Vector3(0.0f, 20.0f, 250.0f);
private ModelClass stadium; private Texture2D background;
/// <summary> /// Конструктор /// <summary> public Gamel()
{
graphics = new GraphicsDeviceManager(this); content = new ContentManager(Services); for (int i = 0; ball.Length > i;
{
ball[i] = new ModelClass();
}
cursor = new Sprite(); stadium = 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> Предыдущая Следующая
|