Skip to content

Rotating Canvas Games

Menu
  • Games
    • Balloon Shooter
    • Choozak
    • Polar
    • Tap Shoot Zombie!
    • Speedboat Santa
    • Rapid Car Rush
    • Turtle Leap
    • Crossword
  • HTML5 Games
    • Speedboat Santa HTML5
    • Choozak HTML5
  • Blog
  • Tutorials Index
  • About Us
  • Contact Us
  • Privacy Policy & Terms and Conditions
    • Privacy Policy
    • Terms and Conditions
    • Copyright Notice
    • Disclaimer
Menu

Game Development in Android using Libgdx Part X

Posted on March 8, 2012December 4, 2023 by Rahul Srivastava

In this tutorial, we will be updating the different game states depending on time/enemy collision/star collections. For the best games you can find, you can try sites such as 벳엔드 후기.

We will edit the LevelManager class to handle changes.

LevelManager.java

public class LevelManager{
      //...........
      public Boolean IsPaused;
      Boolean levelWon;
      Boolean gameOver;
      public void Update(float dt){
               if(!isPaused && !gameOver){
                        GameTimer.Update(dt);
                        if(GameTimer.CrossTimeLimit){
                                  gameOver=true;
                                  levelWon=false;
                        }
                        if(CurrentStarCount==StarLimit){
                                   levelWon=true;
                                   gameOver=true;
                        }
               }
      }
      public void Reset(){
               GameTimer.Reset();
               //Init all the game variables like mobs/stars etc
      }
      public void SetTime(float timeLimit){
                GameTimer.TimeLimit=timeLimit;
                GameTimer.Reset();
      }
      public void Resume(){
              isPaused=false;
      }
      public void Pause(){
              isPaused=true;
      }
      public Boolean IsGameOver(){
           return gameOver;
      }
      public Boolean IsLevelWon(){
           return levelWon;
      }
}

So when we parse levels we can set the stars values and time limit for the level in this class’s object and call its update in game’s update function. In every frame we check for gameOver in main update funciton. If it is true then we check if level is Won or not and depending on that we generate a pause/restart/next level popup/screen.

Temporary Invincibility:

This was a feature we added to the protagonist, so that when it hits the laser or other enemies it doesn’t get hurt in a short span twice. This feature is usually present in many games and it is a really simple feature to add. Here is a snippet of how we applied it in our game.

Hero.java

public Timer InvincibleTimer;
public void AddDamage(){
      if(InvincibleTimer.CrossTimeLimit){
            //Add damage to hero
            InvincibleTimer.Reset();
      }
}

So if hero collides in a span shorter then the invincibleTimer time limit then it won’t add damage to the hero.

Next Tutorial:

Next tutorial would be short one on how to handle the back key event in android.

Let us know any of your doubts/suggestions; please put them in the comments section and we would try to answer them.

Thank you for the patience.

  • Tweet
©2025 Rotating Canvas Games | Built using WordPress and Responsive Blogily theme by Superb