Предыдущая Следующая
/// Листинг 19.1
/// Исходный код к книге:
/// «Программирование игр для приставки Xbox 360 в XNA Game Studio Express»
/// Автор книги: Горнаков С. Г.
/// Глава 19
/// Проект: CursorBall
/// Класс 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; using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Storage;
318 Стреляем по целям
#endregion
namespace CursorBall {
public class Gamel : Microsoft.Xna.Framework.Game
{
private enum CurentGameState
{
}
CurentGameState gameState = CurentGameState.GameScreen;
GraphicsDeviceManager graphics;
ContentManager content;
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]; Random rand = new Random();
SpriteBatch spriteBatch; Sprite cursor;
public BoundingSphere[] bb = new BoundingSphere[3]; Vector3 camera = new Vector3(0.0f, 0.0f, 150.0f);
/// <summary> /// Конструктор /// <summary> public Game1()
{
graphics = new GraphicsDeviceManager(this); content = new ContentManager(Services); graphics.PreferredBackBufferWidth = 1280; graphics.PreferredBackBufferHeight = 720; screenWidth = graphics.PreferredBackBufferWidth; screenHeight = graphics.PreferredBackBufferHeight; for (int i = 0; ball.Length > i;
{
ball[i] = new ModelClass();
}
cursor = new Sprite();
}
/// <summary>
Целимся и стреляем 319
/// Инициализация /// <summary>
protected override void Initialize() {
spriteBatch = new SpriteBatch(graphics.GraphicsDevice);
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, 60)), rand.Next(0, 60)); Предыдущая Следующая
|