-
Notifications
You must be signed in to change notification settings - Fork 2
Scoring System and Leaderboard
Score is stored as a ScoreComponent
associated with a entity. You can use changeScore(int change)
by triggering a update_score
event on the entity and it will append the change. You can also getScore()
on the entity if you wish to uses the score in another manner ie thresholds of object interactions. Score is stored in a text file after every level. Here it is associated with a username. Score is displayed via the PlayerStatsDisplay
. PlayerStatsDisplay
contains the listener which updates the score. The only occurrence which triggers a update score event is the movement of the character.
Having the score implemented as a component is more efficient because its congruent with the component system used in this game engine. Having it as a time based display on the main game screen is limiting in that you'll have trouble altering the score outside of the main game screen class. Thus you'd have trouble changing the score based on player interactions or levels etc.
The leaderboard is in another screen accessible via the main menu. When you click through to it, it reads the leaderboard.txt
and sorts it based on the score of the players in side. The score is stored as username:level1score,level2score.... getLeaderBoard()
reads this text file and sums the level scores to get a total score. It then sorts it and returns a TreeMap<String, Integer>
as a representation of the leaderboard. The top 25 scores are then written to the table.
Entities and Components
Interaction System
Unit Testing
Input Handling
UI
Game Screens and Areas
Map Generation
Basic Interactable Objects Design