Esempio n. 1
0
File: Enemy.cs Progetto: jysr/TP
        public void Initialize(Animation animation, Vector2 position)
        {
            // Load the enemy ship texture

            EnemyAnimation = animation;

            // Set the position of the enemy

            Position = position;

            // We initialize the enemy to be active so it will be update in the game

            Active = true;

            // Set the health of the enemy

            Health = 10;

            // Set the amount of damage the enemy can do

            Damage = 10;

            // Set how fast the enemy moves

            enemyMoveSpeed = 6f;

            // Set the score value of the enemy

            Value = 100;
        }
Esempio n. 2
0
File: Player.cs Progetto: jysr/TP
        public void Initialize(Animation animation, Vector2 position)
        {
            PlayerAnimation = animation;

            // Set the starting position of the player around the middle of the screen and to the back

            Position = position;

            // Set the player to be active

            Active = true;

            // Set the player health

            Health = 100;
        }
Esempio n. 3
0
File: Laser.cs Progetto: jysr/TP
 public void Initialize(Animation animation, Vector2 position)
 {
     LaserAnimation = animation;
     Position = position;
     Active = true;
 }
Esempio n. 4
0
File: Game1.cs Progetto: jysr/TP
        protected void AddLaser()
        {
            Animation laserAnimation = new Animation();
            // initlize the laser animation
            laserAnimation.Initialize(laserTexture,
                player.Position,
                46,
                16,
                1,
                30,
                Color.White,
                1f,
                true);

            Laser laser = new Laser();
            // Get the starting postion of the laser.

            var laserPostion = player.Position;
            // Adjust the position slightly to match the muzzle of the cannon.
            laserPostion.Y += 37;
            laserPostion.X += 70;

            // init the laser
            laser.Initialize(laserAnimation, laserPostion);
            laserBeams.Add(laser);
            /* todo: add code to create a laser. */
            // laserSoundInstance.Play();
        }
Esempio n. 5
0
File: Game1.cs Progetto: jysr/TP
        private void AddEnemy()
        {
            // Create the animation object

            Animation enemyAnimation = new Animation();

            // Initialize the animation with the correct animation information

            enemyAnimation.Initialize(enemyTexture, Vector2.Zero, 47, 61, 8, 30, Color.White, 1f, true);

            // Randomly generate the position of the enemy

            Vector2 position = new Vector2(GraphicsDevice.Viewport.Width + enemyTexture.Width / 2,

            random.Next(100, GraphicsDevice.Viewport.Height - 100));

            // Create an enemy

            Enemy enemy = new Enemy();

            // Initialize the enemy

            enemy.Initialize(enemyAnimation, position);

            // Add the enemy to the active enemies list

            enemies.Add(enemy);
        }
Esempio n. 6
0
File: Game1.cs Progetto: jysr/TP
        /// <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

            enemyTexture = Content.Load<Texture2D>("Graphics/mineAnimation");
            // load th texture to serve as the laser
            laserTexture = Content.Load<Texture2D>("Graphics\\laser");

            // load Font
            Font = Content.Load<SpriteFont>("Graphics\\gameFont");
            // Load the player resources

            Animation playerAnimation = new Animation();

            Texture2D playerTexture = Content.Load<Texture2D>("Graphics\\shipAnimation");
            Rectangle titleSafeArea = GraphicsDevice.Viewport.TitleSafeArea;
            playerAnimation.Initialize(playerTexture, Vector2.Zero, 115, 69, 8, 30, Color.White, 1f, true);

            menu.LoadContent(Content, new Size(800, 600));

            Vector2 playerPosition = new Vector2(GraphicsDevice.Viewport.TitleSafeArea.X,

            GraphicsDevice.Viewport.TitleSafeArea.Y

            + GraphicsDevice.Viewport.TitleSafeArea.Height / 2);

            player.Initialize(playerAnimation, playerPosition);
            // Load the parallaxing background

            bgLayer1.Initialize(Content, "Graphics/bgLayer1", GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, -1);

            bgLayer2.Initialize(Content, "Graphics/bgLayer2", GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, -2);
            mainBackground = Content.Load<Texture2D>("Graphics/mainbackground");
            endGame = Content.Load<Texture2D>("Graphics/endMenu");
        }