ero.Position.Y gt; 640 amp; amp; currentLevel == 3)
{= 2; .Position.Y=0;
}
/* 1 - gt; 2
*/(Hero.Position.Y lt; -Hero.Height + 10 amp; amp; currentLevel == 2)
{= 3; .Position.Y=640 - Hero.Height;
}
}
{. Position.X=MathHelper.Clamp (Hero.Position.X, 0, _viewPortRectangle.Width - Hero.Width) ;. Position.Y=MathHelper.Clamp (Hero.Position.Y, 0, _viewPortRectangle.Height - Hero.Height);
}
[currentLevel] .UpdateField (gameTime);// Обновеляем кімнату ();// Дивимося рух по клавішах
if (Hero.hp == 0)
gameState=GameState.Menu;
}
/// lt; summary gt;
/// This is called when the game should draw itself.
/// lt;/summary gt;
/// lt; param name= gameTime gt; Provides a snapshot of timing values. lt;/param gt; override void Draw (GameTime gameTime)
{. Clear (Color.Black);
(gameState == GameState.Game) (); menu.Draw (spriteBatch);
. Draw (gameTime);
}
void DrawGame ()
{. Begin (SpriteSortMode.FrontToBack, BlendState.AlphaBlend); [currentLevel] .DrawField (spriteBatch);// Малюємо кімнату (Hero.hp == 2) .Draw (hp, new Vector2 (50, 50), null, Color.White, 0, Vector2.Zero, 1, SpriteEffects.None, 1); if (Hero. hp == 1) .Draw (hp1, new Vector2 (50, 50), null, Color.White, 0, Vector2.Zero, 1, SpriteEffects.None, 1) ;. End ();
}
void control ()
{(Keyboard.GetState (). IsKeyDown (Keys.Escape))=GameState.Menu;
(Keyboard.GetState (). IsKeyUp (Keys.W) || Keyboard.GetState (). IsKeyUp (Keys.S)). Move.Y=0;
(Keyboard.GetState (). IsKeyUp (Keys.D) || Keyboard.GetState (). IsKeyUp (Keys.A)). Move.X=0;
(Keyboard.GetState (). IsKeyDown (Keys.D))//Вправо
{. MoveRight ();
}
(Keyboard.GetState (). IsKeyDown (Keys.A))//Вліво
{. MoveLeft ();
}
(Keyboard.GetState (). IsKeyDown (Keys.W))//Вгору
{. MoveUp ();
}
(Keyboard.GetState (). IsKeyDown (Keys.S))//Вниз
{. MoveDown ();
}
(Keyboard.GetState (). IsKeyDown (Keys.E) amp; amp; pastKey.IsKeyUp (Keys.E))//W - стрелять.Shoot (Hero.listBullet);
(Keyboard.GetState (). IsKeyDown (Keys.Q) amp; amp; pastKey.IsKeyUp (Keys.Q))
{. hp -;=null;
}
(Keyboard.GetState (). IsKeyDown (Keys.Space) amp; amp; pastKey.IsKeyUp (Keys.Space))
{[currentLevel] .AddEnemy ();
}
=Keyboard.GetState ();
}
enum GameState
{,
}
}
}