private void Pierde(Vehiculo vehiculo) { StopSound(); SoundFrenazo.Play(1, 0, 0); VelocidadPierde = vehiculo.Carril.Velocidad; faseJuego = FaseJuego.Pierde; }
private void UpdatePierde() { if (posicion.X > 0 && posicion.X < virtualScreen.X) { posicion.X += VelocidadPierde; //sacamos el personaje } else { vidas--; if (vidas > 0) { posicion.Y = virtualScreen.Y - 64; faseJuego = FaseJuego.Juego; if (MediaPlayer.State != MediaState.Playing && MediaPlayer.GameHasControl) { MediaPlayer.Play(musica); } } else { faseJuego = FaseJuego.Inicio; nivel = 0; vidas = 3; IniciarNivel(); } posicion.X = virtualScreen.X / 2; VelocidadPierde = 0; } }
private void UpdateJuego() { if (tiempo > 0 && scroll == 0) { tiempo--; //drementamos el tiempo, si el tiempo es positivo y que no haya scroll(no cambie de pantalla) } if (tiempo == 0) //si nos quedamos sin tiempo , perdemos { faseJuego = FaseJuego.Pierde; VelocidadPierde = 3; //velocidad de retirada del movimiento tiempo = 1000; // ponemos el tiempo en 1000 nuevamente previamwente a perder } ControlDeTeclado(); MoverVehiculos(); ComprobarColisiones(); ComprobarLimites(); }
private void UpdateInicio() { MoverVehiculos(); KeyboardState state = Keyboard.GetState(); if (state.IsKeyDown(Keys.Enter)) { faseJuego = FaseJuego.Juego; SoundAmbienteInstance.Play(); if (MediaPlayer.State != MediaState.Playing && MediaPlayer.GameHasControl) //validamos que no este reproducciendose y //validamos si el juego tiene el control se puede reproducir { MediaPlayer.Play(musica); } } }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // TODO: Add your initialization logic here posicion = new Vector2( graphics.GraphicsDevice.Viewport.Width / 2, graphics.GraphicsDevice.Viewport.Height - 64); //el origen esde coodenadas esta en la parte superior derecha 0.0 base.Initialize(); carriles = new Carril[5]; posicion.X = virtualScreen.X / 2; //centramos horizontalmente IniciarNivel(); faseJuego = FaseJuego.Inicio; //inioci seria inicio puntuacion = 0; }
private void Gana() { faseJuego = FaseJuego.Gana; SoundCash.Play(1, 0, 0); }
private void UpdateGana() { puntuacion = puntuacion + tiempo; //sumamos el tiempo a la puntuacion IniciarNivel(); faseJuego = FaseJuego.Juego; }