As soon as you start work on your game project, you need to create a Git repository to track all your changes. You will use BitBucket.org to keep a master copy of your game project, and it is your BitBucket.org Git repository that you will use to submit your game project for marking. After you have created your Eclipse project, follow these steps to set everything up:
- Go to organd create a free account ('Get started for free'). Then create a 'private' Git repository in that account (this is the URL that you will submit to Blackboard for marking).
- Then, in Eclipse, right-click on your whole project and use Team / Share Project / Git / Next / Createto create a new local repository.
- Commit all your project source files into your local Git repository: (Team / Commit). You should add all the *.java files, the .project and .classpath files, and ALLother image files or data files that are needed to compile and run your game. Do NOT add binary output files such as *.class files. Enter a meaningful commit message (e.g. "First version of game"), and press Commit.
- Push your project up into your BitBucket repository: (Team / Remote / Push, and then paste in the URI of your BitBucket repository from Step 1). You will need to tell Eclipse your BitBucket.org password. Set the 'Source Ref'to 'Master[branch]' and press the 'Add spec' button, then press Finish.
- Go back to BitBucket.org and refresh your repository there, and you should see that some files have been created. You should create a README file too, with a couple of sentences to explain your project.
- Important!Finally, click the 'Send invitation' button and invite your tutor (Mark [email protected], or Amol [email protected]) to be able to share your repository (READ permission will suffice). Then invite the Course Coordinator ([email protected]) as well. If you don't do this, we will not be able to mark your assignment.
Now you have joined the world of professional software developers, who use version control to manage their source code safely. Every day after you have made some changes to your game (and tested them of course!), you should use the Team / Commit / Commit and Push command in Eclipse to save a record of your changes into your local repository, and also push a copy of those changes up to your BitBucket repository, where they will be safely backed up, and where we will be able to access them for marking.
You can even use this feature to keep your home and University computers synchronised with the latest version of your game, if you:
- do a 'Team / Commit / Commit and Push' after you make changes.
- do a 'Team / Pull'each time you arrive at a new computer, to pull the latest version of your game down to this computer.
Start by developing a simple first version of the 2D board in your core game engine. You could look at the TicTacToe game for an example of how to do this.
- Think carefully about whether each cell in your board should be a primitive value (like a boolean, an integer, or an enumerated value), or should it be an object? Using objects is more flexible, since it allows you to use Java subtyping to make different cells have different behaviour. But many of the games suggested above do not require the cells to have fancy behaviour, so a primitive value might be sufficient for your game.
- If you have a multi-player game, think carefully about whether the players should just be numbered, or do you want to be able to switch between computer players and human players? If the latter, then a nice way of doing this is to have a Playersuperclass (or interface), with one subclass for a human player (which prompts the user and reads their response), and another subclass for a computer player (which implements a simple playing strategy such as choosing a random move).
- To get high marks, your engine needs to include several classes, with some association/composition relationships between them, and if possible, some inheritance relationships. Think about where you can best use these Java features.
Here are two suggestions for how you can develop your game engine in small iterations, so that you check that each new feature is working correctly. I suggest that each iteration should take at most 10-30 minutes, so that you are doing lots of small iterations, adding one feature at a time.
- Use TDD to develop your unit tests and game engine at the same time.
Write a simple textual user interface first, and use that to test the game engine manually each time you add a new feature. (Hint: to make sure you have not broken any old features, you can also rerun previous tests by recording the input in a text file, and redirecting that file into your program using input redirection. Eg. java -jar game.jar <in.txt >out.txt).