Esempio n. 1
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            playerTexture = Content.Load <Texture2D>("player");
            player.Initialize(playerTexture, playerPosition);

            laserTexture = Content.Load <Texture2D>("laser");
            laser.Initialize(laserTexture, laserPosition);

            laser2Texture = Content.Load <Texture2D>("laser");
            laser2.Initialize(laser2Texture, laser2Position);

            for (int i = 0; i < enemies.Length; i++)
            {
                enemiesTexture[i] = Content.Load <Texture2D>("enemy");
                enemies[i].Initialize(enemiesTexture[i], new Vector2(j, 100));
                j = j + enemiesTexture[i].Width + 10;
            }

            font = Content.Load <SpriteFont>("Score");

            textureGameOver = Content.Load <Texture2D>("gameOver");

            textureGameStart = Content.Load <Texture2D>("gameStart");
        }
Esempio n. 2
0
 private void CreateLaser(GameTime gameTime, Vector2 pos)
 {
     if (gameTime.TotalGameTime - previousLaserSpawnTime > laserSpawnTime)
     {
         previousLaserSpawnTime = gameTime.TotalGameTime;
         var laser = new Laser();
         laser.Initialize(enemyLaserTexture
                          , pos);
         lasers.Add(laser);
     }
 }