/// <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() { EstadoDeJogo.ZeraJogo(); Sujeira.Limpa(); base.Initialize(); }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { if (Keyboard.GetState().IsKeyDown(Keys.Escape)) { Exit(); } MouseState mouse = Mouse.GetState(); switch (EstadoDeJogo.FaseDeExecucao) { case Fase.Inicial: if (btnPlay.isClicked == true) { EstadoDeJogo.FaseDeExecucao = Fase.Partida; Sujeira.CriaLixo(); } btnPlay.Update(mouse); break; case Fase.Partida: // TODO: Atualizar a posição dos lixos de acordo com o toque Sujeira.Update(); Sujeira.CriaLixo(gameTime); VerificaPontuacao(); background.Update(gameTime); if (EstadoDeJogo.Vidas == 0) { EstadoDeJogo.FaseDeExecucao = Fase.Final; flag_acabou = true; } break; case Fase.Final: btnPlay.isClicked = false; if (mouse.LeftButton == ButtonState.Pressed && flag_acabou == false) { EstadoDeJogo.ZeraJogo(); } if (mouse.LeftButton == ButtonState.Released) { flag_acabou = false; } break; default: break; } base.Update(gameTime); }