This is a Snake game I wrote in about two week time for my high school CS project. It uses javax.swing for graphics and java.awt for events.
This is the src/
directory structure. Code in src/main/java/
is separated into three packages, Controller
, Model
and View
. There are also replaceable resources under src/main/resources
, such as sprites and sound files.
There are also test files under src/test/java/
. They are JUnit tests to check certain functionalities are working. To use them, check the below instructions.
These are the .sh
files under build/
The .sh
files are there to help the user use the code! There are currently four of them:
build/scripts/compileEverything.sh
is to (re-)compile both the game source and the unit test codes.build/scripts/compileGame.sh
only compiles the game source undersrc/main/java/
. Use this to test the game.build/scripts/test.sh
runs the unit tests against the code.- Usage:
build/scripts/test.sh [test1] [test2] [test3] ...
orbuild/scripts/test.sh -all
- Calling
build/scripts/test.sh
without any arguments brings up a help menu.
- Usage:
build/scripts/clean.sh
removes all class files and jar files.- Mainly used by me to clean up my compilation files.
- Open Finder, go to
/Applications/
, go intoUtilities/
and findTerminal.app
. Open it.
- An alternative is to open
Spotlight
and search forTerminal
. Hit Return.
- If you haven't, download this code as a
zip
, unzip it and open it in aFinder
. Locate the.sh
files. - Now in your
Terminal
, typechmod +x
. - Now drag your
.sh
file into theTerminal
. Hit Return. - Repeat step 4 without typing anything before it. Hit Return.
- If you are using
build/scripts/test.sh
, this will bring up a help menu. Repeat the drag and drop process following the instructions.
- It should compile and run the relevant code now!
- If you put any arguments (e.g. a dash
-
) after the commandsomething.sh
, it will not run the compiled code!
- Example:
build/scripts/compileGame.sh -