Предыдущая Следующая
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; #endregion
namespace Platform {
public class Gamel : Microsoft.Xna.Framework.Game
{
GraphicsDeviceManager graphics; ContentManager content; SpriteBatch spriteBatch; Sprite[] sprite = new Sprite[5]; private Texture2D background; Random rand = new Random(); int screenWidth, screenHeight; int j = 0; Sprite platform;
/// <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; sprite.Length > i;
{
sprite[i] = new Sprite(12, 10);
}
platform = new Sprite();
}
/// <summary>
178 Работа с джойстиком
/// Инициализация /// <summary
protected override void Initialize() {
J = 0;
for (int i = 0; sprite.Length > i;
{
sprite[i].spritePosition = new Vector2(rand.Next(10, screenWidth - 150), j = j - 300);
}
platform.spritePosition = new Vector2(screenWidth / 2, screenHeight - 90);
base.Initialize();
}
/// <summary>
/// Загрузка компонентов игры /// <summary>
protected override void LoadGraphicsContent(bool loadAllContent)
{
if (loadAllContent)
{
spriteBatch = new SpriteBatch(graphics.GraphicsDevice);
background = content.Load<Texture2D>(«Content\\Textures\\background»); 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»);
} }
/// <summary>
/// Освобождаем ресурсы
/// <summary>
protected override void UnloadGraphicsContent(bool unloadAllContent)
{ }
/// <summary>
/// Обновляем состояние игры /// <summary>
protected override void Update(GameTime gameTime)
{
if (GamePad.GetState(Playerlndex.One).Buttons.Back == ButtonState.Pressed) this.Exit();
double elapsed = gameTime.ElapsedGameTime.TotalSeconds; for (int i = 0; sprite.Length > i; Предыдущая Следующая
|