private void AddEnemy() { Animation enemyAnimation = new Animation(); enemyAnimation.Initialize(enemyTexture, Vector2.Zero, 47, 61, 8, 30, Color.White, 1f, true); Vector2 position = new Vector2( GraphicsDevice.Viewport.Width + enemyTexture.Width, random.Next(100, GraphicsDevice.Viewport.Height - 100)); Enemy enemy = new Enemy(); enemy.Initialize(enemyAnimation, position, pixel); enemies.Add(enemy); }
private void AddExplosion(Vector2 position) { Animation explosionAnimation = new Animation(); explosionAnimation.Initialize(explosionTexture, position, 134, 134, 12, 45, Color.White, 1f, false); Explosion explosion = new Explosion(); explosion.Initialize(explosionAnimation); explosions.Add(explosion); }
/// <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); // TODO: use this.Content to load your game content here Animation playerAnimation = new Animation(); Texture2D playerTexture = Content.Load<Texture2D>("shipAnimation"); playerAnimation.Initialize(playerTexture, new Vector2(0,0), 115, 69, 8, 15, Color.White, 1f, true); Vector2 playerPosition = new Vector2(0, 100 + playerAnimation.FrameHeight); // set the collision border colors pixel = new Texture2D(GraphicsDevice, 1, 1, false, SurfaceFormat.Color); pixel.SetData(new[] { Color.White }); player.Initialize(playerAnimation, playerPosition, pixel); // load the backgrounds // background = Content.Load<Texture2D>("mainbackground"); bgLayer0.Initialize(Content, "mainbackground", GraphicsDevice.Viewport.Width,-1); bgLayer1.Initialize(Content, "bgLayer1", GraphicsDevice.Viewport.Width, -2); bgLayer2.Initialize(Content, "bgLayer2", GraphicsDevice.Viewport.Width, -4); // load enemies enemyTexture = Content.Load<Texture2D>("mineAnimation"); // Load projectile textures projectileTexture = Content.Load<Texture2D>("laser"); // load explosions.....PRRRKKKkakkkarrrrrrrrggkkkkkkkkk explosionTexture = Content.Load<Texture2D>("explosion"); // load the music and sounds gameplayMusic = Content.Load<Song>("audio/music/gameMusic"); laserSound = Content.Load<SoundEffect>("audio/sound/laserFire"); explosionSound = Content.Load<SoundEffect>("audio/sound/explosion"); // load fonts font = Content.Load<SpriteFont>("gameFont"); // start music PlayMusic(gameplayMusic); }