Предыдущая Следующая
public BoundingBox[] bb = new BoundingBox[5]; BitmapFont font;
int scoreO, scorel, score2, score3, score4;
/// <summary> /// Конструктор /// <summary> public Game1()
160 Подсчет очков и вывод текста на экран
Работа с текстом 161
{
graphics = new GraphicsDeviceManager(this); content = new ContentManager(Services); graphics.PreferredBackBufferWidth = 1024; graphics.PreferredBackBufferHeight = 7 68; graphics.PreferMultiSampling = false; graphics.IsFullScreen = true; for (int i = 0; sprite.Length > i;
{
sprite[i] = new Sprite(12, 10);
}
platform = new Sprite();
font = new BitmapFont("Content\\Font\\russian.xml'');
}
/// <summary>
/// Инициализациия
/// <summary
protected override void Initialize()
{
for (int i = 0; sprite.Length > i;
{
sprite[i].spritePosition = new Vector2(rand.Next(10, Window.ClientBounds.Width - 500), j = j - 300);
}
platform.spritePosition = new Vector2(Window.ClientBounds.Width / 2,
Window.ClientBounds.Height - 90);
scoreO = 0;
scorel = 0;
score2 = 0;
score3 = 0;
score4 = 0;
base.Initialize();
}
/// <summary>
/// Загрузка компонентов игры /// <summary>
protected override void LoadGraphicsContent(bool loadAllContent)
{
if (loadAllContent)
{
spriteBatch = new SpriteBatch(graphics.GraphicsDevice);
background1 = content.Load<Texture2D>("Content\\Textures\\background1"); background2 = content.Load<Texture2D>("Content\\Textures\\background2"); platform.Load(content, "Content\\Textures\\platform"); sprite[0].Load(content, "Content\\Textures\\0"); sprite[1].Load(content, "Content\\Textures\\1"); sprite[2].Load(content, "Content\\Textures\\2"); sprite[3].Load(content, "Content\\Textures\\3"); sprite[4].Load(content, "Content\\Textures\\4"); font.Reset(graphics.GraphicsDevice);
} }
/// <summary>
/// Освобождаем ресурсы
/// <summary>
protected override void UnloadGraphicsContent(bool unloadAllContent)
{
if (unloadAllContent == true)
{
content.Unload();
}
}
/// <summary>
/// Обновляем состояние игры /// <summary>
protected override void Update(GameTime gameTime)
{
keyboardState = Keyboard.GetState(); if (keyboardState.IsKeyDown(Keys.Escape)) this.Exit();
Pause();
if (paused == false)
{
double elapsed = gameTime.ElapsedGameTime.TotalSeconds; for (int i = 0; sprite.Length > i;
{
sprite[i].UpdateFrame(elapsed);
}
MoveSprite();
MovePlatform(); Предыдущая Следующая
|