// Initialize the player 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; }
public void Initialize(Animation animation, Vector2 position, Vector2 player_pos) { // 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 = 1; // Set the amount of damage the enemy can do Damage = 10; // Set how fast the enemy moves enemyMoveSpeed = 4f; // Set the score value of the enemy Value = 100; }
private void AddExplosion(Vector2 position) { Animation explosion = new Animation(); explosion.Initialize(explosionTexture, position, 32, 32, 6, 45, Color.White, 1f, false); explosions.Add(explosion); }
private void AddEnemy(Vector2 boss_pos) { // Create the animation object Animation enemyAnimation = new Animation(); // Initialize the animation with the correct animation information enemyAnimation.Initialize(enemyTexture, Vector2.Zero, 32, 32, 4, 100, Color.White, 1f, true); int posheight = GraphicsDevice.Viewport.Height; float x_coord = boss.Position.X + 92; //float x_coord = boss_x_coords[0,1]; float y_coord = boss.Position.Y + 44; Vector2 position = new Vector2(x_coord,y_coord); // Create an enemy Enemy enemy = new Enemy(); // Initialize the enemy enemy.Initialize(enemyAnimation, position, player.Position); // Add the enemy to the active enemies list enemies.Add(enemy); }
/// <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 // Load the player resources //Vector2 playerPosition = new Vector2(GraphicsDevice.Viewport.TitleSafeArea.X, GraphicsDevice.Viewport.TitleSafeArea.Y + GraphicsDevice.Viewport.TitleSafeArea.Height / 2); // Load the player resources Animation playerAnimation = new Animation(); Texture2D playerTexture = Content.Load<Texture2D>("player"); playerAnimation.Initialize(playerTexture, Vector2.Zero, 65, 128, 3, 30, Color.White, 1f, true); Vector2 playerPosition = new Vector2(200,300); player.Initialize(playerAnimation, playerPosition) ; enemyTexture = Content.Load<Texture2D>("shot"); bossTexture = Content.Load<Texture2D>("boss"); boss.Initialize(GraphicsDevice.Viewport, bossTexture, new Vector2(100f, 100f), GraphicsDevice.Viewport.Width); Texture2D small_starTexture = Content.Load<Texture2D>("small_star"); //bg.Initialize(GraphicsDevice.Viewport, bossTexture, new Vector2(100f, 100f)); projectileTexture = Content.Load<Texture2D>("projectile"); explosionTexture = Content.Load<Texture2D>("explosion"); // Load the music gameplayMusic = Content.Load<Song>("sound/gameMusic"); // Load the laser and explosion sound effect laserSound = Content.Load<SoundEffect>("sound/projectile"); explosionSound = Content.Load<SoundEffect>("sound/explosion"); // Load the score font font = Content.Load<SpriteFont>("SpriteFont1"); // Start the music right away //PlayMusic(gameplayMusic); }