/// <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); try { Texture2D texturaJugador = Content.Load <Texture2D>("Imagenes/naveAnimacion"); //se divide entre 8 debido a que son 3 imagenes que componen la textura y necesitamos la mitad de una de las texturas animacionJugador.Inicialize(texturaJugador, new Vector2((graphics.GraphicsDevice.Viewport.Width / 2) - (texturaJugador.Width / 8), (graphics.GraphicsDevice.Viewport.Height / 2) - (texturaJugador.Height / 2)), 58, 90, 4, 30, Color.White, 1f, true); disparo = Content.Load <SoundEffect>("Sonidos/efectoLaser"); jugador.inicializar(GraphicsDevice.Viewport, Content, animacionJugador, new Vector2((graphics.GraphicsDevice.Viewport.Width / 2) - (animacionJugador.FrameWidth / 2), (graphics.GraphicsDevice.Viewport.Height / 2) - (animacionJugador.FrameHeight / 2)), velocidadJugador, disparo); fondoJuego = new Fondo(); fondoJuego.inicializar(Content, "Imagenes/fondoFinal", GraphicsDevice.Viewport.Height, 1); explosion = Content.Load <SoundEffect>("Sonidos/efectoExplosion"); musicaFondo = Content.Load <Song>("Sonidos/gameMusic"); } catch (Exception) { } // TODO: use this.Content to load your game content here }
void agregarExplosion(Vector2 posicion) { try { AnimacionElementos animacionExplosion = new AnimacionElementos(); if ((int)texturaEnemigoNivel.asteoide == (int)nivelActual) { Texture2D texturaAnimacion = contenedor.Load <Texture2D>("Imagenes/ExplosionAsteoide"); animacionExplosion.Inicialize(texturaAnimacion, posicion, 134, 134, 12, 30, Color.White, 1f, false); } else { Texture2D texturaAnimacion = contenedor.Load <Texture2D>("Imagenes/ExplosionMarciano"); animacionExplosion.Inicialize(texturaAnimacion, posicion, 60, 64, 21, 30, Color.White, 1f, false); } explosiones.Add(animacionExplosion); } catch (Exception) { } }
public void agregarEnemigo() { try { Enemigo enemigo = new Enemigo(); Texture2D texturaE; texturaE = contenedor.Load <Texture2D>(texturaEnemigo[(int)nivelActual]); animacionEnemigo = new AnimacionElementos(); if ((int)texturaEnemigoNivel.asteoide == (int)nivelActual) { animacionEnemigo.Inicialize(texturaE, Vector2.Zero, 35, 35, 8, 150, Color.White, 1f, true); } else { animacionEnemigo.Inicialize(texturaE, Vector2.Zero, 50, 45, 6, 150, Color.White, 1f, true); } int posicionAncho = generarPosicionAleatoria(nivelActual); if (nivelActual == (int)nivel.facil) { enemigo.inicializar(new Vector2(posicionAncho, 0 - animacionEnemigo.FrameHeight), velocidadEnemigo, viewport, generarDesplazamiento(posicionAncho), animacionEnemigo); enemigo.danio = 15; } else if (nivelActual == (int)nivel.medio) { enemigo.inicializar(new Vector2(posicionAncho, 0 - animacionEnemigo.FrameHeight), velocidadEnemigo, viewport, generarDesplazamiento(posicionAncho), true, animacionEnemigo); enemigo.danio = 10; } else { enemigo.inicializar(new Vector2(posicionAncho, 0 - animacionEnemigo.FrameHeight), velocidadEnemigo, viewport, generarDesplazamiento(posicionAncho), true, animacionEnemigo); enemigo.danio = 5; } enemigos.Add(enemigo); } catch (Exception) { } }