Пример #1
0
 /// <summary>
 /// Allows the game to perform any initialization it needs to before starting to run.
 /// This is where it can query for any required services and load any non-graphic
 /// related content.  Calling base.Initialize will enumerate through any components
 /// and initialize them as well.
 /// </summary>
 protected override void Initialize()
 {
     // TODO: Add your initialization logic here
     canvasHeight = graphics.GraphicsDevice.Viewport.Height;
     canvasWidth = graphics.GraphicsDevice.Viewport.Width;
     player = new Player(new Vector2(canvasWidth / 4, canvasHeight-80), this);
     Platforms = new List<Platform>();
     Bullets = new List<Bullet>();
     for (int i = 0; i < 5; i++)
     {
         Platform platform = new Platform((i * (canvasWidth / 3)), (canvasHeight - 20));
         Platforms.Add(platform);
     }
     base.Initialize();
 }
Пример #2
0
 public void onCollisionTop(Player player)
 {
     player.playerPos.Y = (position.Y - 60);
     player.inAir = false;
 }
Пример #3
0
 public Bullet(Player player)
 {
     position = new Vector2(player.playerPos.X+15, player.playerPos.Y);
 }
Пример #4
0
 public void onCollisionLeft(Player player)
 {
     player.playerPos.X = (position.X - 30);
 }
Пример #5
0
 /// <summary>
 /// Allows the game to perform any initialization it needs to before starting to run.
 /// This is where it can query for any required services and load any non-graphic
 /// related content.  Calling base.Initialize will enumerate through any components
 /// and initialize them as well.
 /// </summary>
 protected override void Initialize()
 {
     // TODO: Add your initialization logic here
     canvasHeight = graphics.GraphicsDevice.Viewport.Height;
     canvasWidth = graphics.GraphicsDevice.Viewport.Width;
     player = new Player(new Vector2( (canvasWidth-150), canvasHeight-60), this);
     Platforms = new List<Platform>();
     for (int i = 5; i < 8; i++)
     {
         Platform platform = new Platform((i * (canvasWidth / 3)), (canvasHeight - 20));
         Platforms.Add(platform);
     }
     horizontalCollisionDistance_platform = (player.getWidth() / 2) + (Platforms[0].getWidth() / 2);
     verticalCollisionDistance_platform = (player.getHeight() / 2) + (Platforms[0].getHeight() / 2);
     base.Initialize();
 }