Enhancing Game Play: Creating a Scoring Engine, Adding Treasure and an Enemy Auto-Attack Engine
Now that we've implemented collision detection for our game, as well as putting the foundation in place for a scoring engine, let's finish coding the scoring engine that is called from the .checkCollisions() method, and then add some more game play elements to take advantage of this scoring engine, as well as to make the game play more interesting. To implement our scoring engine display, we will create a gameScore integer variable and scoreText Text object in our InvinciBagel.java class. We will also create a scoreFont Font object, and use it to style the scoreText Text object, to make it stand out better. We will also learn how to use the Java instanceof evaluator in the conditional if() statement in the .scoringEngine() method that we will be creating, and use this to determine what type of Actor object the InvinciBagel has collided with. Of course, we will then increment our gameScore variable accordingly.