Предыдущая Следующая
{
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); menu.Load(content);
mouse.Load(content, "Content\\Textures\\mouse");
pausedTexture = content.Load<Texture2D>("Content\\Textures\\paused"); gameLevel = content.Load<Texture2D>("Content\\Textures\\game");
} }
/// <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 (levelState == true)
{
LevelSelect();
}
else if(menuState == true)
{
UpdateMouse();
}
else if(gameState == true)
{
if(keyboardState.IsKeyDown(Keys.Escape)) menuState = true; Pause();
if(paused == false)
{
if (totalScore >= endScore)
{
gameState = false; menuState = false; levelState = true; tempLevel = level;
level += 1; if (level > 8) {
level = 1;
}
}
double elapsed = gameTime.ElapsedGameTime.TotalSeconds; for (int i = 0; sprite.Length > i;
{
sprite[i].UpdateFrame(elapsed);
}
MoveSprite();
MovePlatform();
Collisions();
} }
Sound.Update(); base.Update(gameTime);
}
/// <summary>
/// Движение спрайта по вертикали
/// <summary>
public void MoveSprite()
{
for (int i = 0; sprite.Length > i;
{
sprite[i].spritePosition += sprite[i].speedSprite;
if (sprite[i].spritePosition.Y > Window.ClientBounds.Height)
228 Добавляем в игру новые уровни
Проект NewLevels 229
{
sprite[i].spritePosition = new Vector2(rand.Next(10, Window.ClientBounds.Width -
300 - sprite[i].spriteTexture.Width / 12), -500); sprite[i].speedSprite.Y = rand.Next(6, 10); Sound.PlayCue(soundList.Boom);
} } }
/// <summary>
/// Движение платформы по экрану
/// <summary>
public void MovePlatform() Предыдущая Следующая
|