Предыдущая Следующая
public BoundingBox[] bb = new BoundingBox[5];
/// <summary> /// Конструктор /// <summary> public Gamel()
{
}
/// <summary> /// Инициализация /// <summary
protected override void Initialize()
{ }
/// <summary>
/// Загрузка компонентов игры /// <summary>
protected override void LoadGraphicsContent(bool loadAllContent)
{ }
/// <summary>
/// Освобождаем ресурсы
/// <summary>
protected override void UnloadGraphicsContent(bool unloadAllContent)
{ }
/// <summary>
Проект Collision 189
/// Обновляем состояние игры /// <summary>
protected override void Update(GameTime gameTime)
{
if (GamePad.GetState(Playerlndex.One).Buttons.Back == ButtonState.Pressed) this.Exit();
Pause();
if (paused == false)
{
double elapsed = gameTime.ElapsedGameTime.TotalSeconds; for (int i = 0; sprite.Length > i;
{
sprite[i].UpdateFrame(elapsed);
}
MoveSprite();
MovePlatform();
Collisions();
}
base.Update(gameTime);
}
/// <summary>
/// Движение спрайта по вертикали
/// <summary>
public void MoveSprite()
{ }
/// <summary>
/// Движение ковра-самолета по экрану /// <summary>
public void MovePlatform()
{ }
/// <summary> /// Пауза в игре /// <summary> public void Pause()
{ }
/// <summary>
/// Столкновения
/// <summary>
public void Collisions()
{
190 Игровые столкновения
bbplatform.Min = new Vector3(platform.spritePosition.X, platform.spritePosition.Y + 45, 0);
bbplatform.Max = new Vector3(platform.spritePosition.X + platform.spriteTexture.Width, platform.spritePosition.Y + 45 + platform.spriteTexture.Height, 0);
for (int i = 0; bb.Length > i;
{
bb[i].Min = new Vector3(sprite[i].spritePosition.X, sprite[i].spritePosition.Y, 0);
bb[i].Max = new Vector3(sprite[i].spritePosition.X + sprite[i].spriteTexture.Width / 12,
sprite[i].spritePosition.Y + sprite[i].spriteTexture.Height, 0);
}
if (bbplatform.Intersects(bb[0]))
{
sprite[0].spritePosition = new Vector2(rand.Next(50, screenWidth -sprite[0].spriteTexture.Width / 12 - 50), -500);
}
if (bbplatform.Intersects(bb[1]))
{
sprite[1].spritePosition = new Vector2(rand.Next(50, screenWidth -sprite[1].spriteTexture.Width / 12 - 50), -500);
}
if (bbplatform.Intersects(bb[2]))
{
sprite[2].spritePosition = new Vector2(rand.Next(50, screenWidth -sprite[2].spriteTexture.Width / 12 - 50), -500);
}
if (bbplatform.Intersects(bb[3]))
{
sprite[3].spritePosition = new Vector2(rand.Next(50, screenWidth -sprite[3].spriteTexture.Width / 12 - 50), -500); Предыдущая Следующая
|