Exemplo n.º 1
0
        public void Initialize(Animation animation)
        {
            this.animation = animation;

            movementSpeed = -6f;
            finished = false;
        }
Exemplo n.º 2
0
        public void Initialize(Animation animation, Vector2 position, Texture2D pixel)
        {
            PlayerAnimation = animation;

            // set the starting position in the middle of the screen and near the left side
            Position = position;
            Active = true;
            this.pixel = pixel;
            Health = 100;

            CollisionOffset = new Vector2(22, 0);
            CollisionWidth = Width - 27;
            CollisionHeight = Height;
        }
Exemplo n.º 3
0
        public void Initialize(Animation animation, Vector2 position, Texture2D pixel)
        {
            EnemyAnimation = animation;
            Position = position;
            Active = true;
            Health = 2;
            Damage = 10;

            enemySpeed = 4f;

            PointValue = 100;

            // for collisions
            this.pixel = pixel;
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
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);

            // 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);
        }