Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I wanted each time I play my game, it will show in the console how many times you compiled or run the game. How do I do that?

share|improve this question

closed as off-topic by Josh Petrie Nov 11 at 17:18

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Programming questions that aren't specific to game development are off-topic here, but can be asked on Stack Overflow. A good rule of thumb is to ask yourself "would a professional game developer give me a better/different/more specific answer to this question than other programmers?"" – Josh Petrie
If this question can be reworded to fit the rules in the help center, please edit the question.

3  
You need to work on your accept rate. 0% is very low. –  Byte56 Sep 28 '12 at 15:30

1 Answer 1

up vote 3 down vote accepted

Well the question really is how do you compile your game:

  • If you just use javac in the console, make a batch file (in whatever batching language your OS supports, i.e. .bat file for windows, .sh file for Linux, etc) that before executing the compiling command (or after) will read the current build number from a text file, increment it and re-write it;

  • If you use a project build tool such as Ant or Maven, you can configure them to automatically place the build number (and build date, etc) into a specified text file.

Finally, whatever your approach, make your application code read the values in that text file and display them somewhere.

share|improve this answer
1  
As to how many times you've played your game, just add code to the start of your game that increments a counter in a file.. –  Jari Komppa Sep 28 '12 at 11:25
    
If you do not yet use a build tool like ant or maven, you really should consider using it. –  Markus Sep 29 '12 at 9:08

Not the answer you're looking for? Browse other questions tagged or ask your own question.