Project 31 (ecs09)

April 5, 2010

This project has intermediate milestones that are relevant to your grade.

Objective

Practice high level programming in the Jack language by building a simple game. Jack is a simple, modern, object-based programming language. In the next project we will build a compiler for it. Before we do so, it helps getting acquainted with the language by writing some programs in it.

Your goal is to adopt or invent an application idea like a simple computer game or some other interactive program. Then design and build the application.

Resources

You will need several tools: the Jack Compiler or the Jack IDE (win32 only), to translate your program into a set of .vm files, the VM Emulator, to run and test your program, and the Jack Operating System (OS). To help you get started, a sample Jack program is included in project 09.zip.

The Jack OS

The executable Jack Operating System is a set of .vm files that implement the standard library of the Jack programming language specified in Chapter 9. In order for any Jack program to execute properly, the compiled .vm files of the program must reside in a directory that also contains all the .vm files of the Jack OS. Here is a list of the Jack OS Error Codes and their textual meaning.

A Sample Jack Program: Square Dance

Description: This simple interactive program allows the user to move a square around the screen: 

 The user can  also change the square size during the movement.

 

When the program starts running, a square of size 30 by 30 pixels is placed at the top left corner of the screen.  The program then listens, and responds to, the following keyboard keys:

  • right arrow:    move the square to the right;
  • left arrow:       move the square to the left;
  • up arrow:        move the square up;
  • down arrow:   move the square down;
  • x:                      increment the square size by 2 pixels;
  • z:                      decrement the square size by 2 pixels;
  • q:                     quit the program.

Movement speed: to control it, you can change the delay constant in the moveSquare method in class SquareGame.

Here is the source code of the Square Dance program (available in project 09.zip):

Class Description

Main.Jack

Initializes and starts a new "square moving session."

Square.jack

Implements an animated square. A square object has properties that characterizes its size and screen location, and methods for drawing, erasing, moving, and size changing.

SquareGame.jack

Runs the program according to the game rules.

Recommended Steps

First, read ECS chapter 9. This pdf may also be insightful.

Within your src directory, create a subdir named project09. Extract the contents of project09.zip into it.

Add, commit and push the new files.

cd src/project09
git add *
git commit -m "Adding project09 files, can't wait to play square dance all night!"
git push

Next, compile and run the Square Dance 'game' by following the steps below.

Compiling & Running a Jack Program

  1. It is best to store all the class files associated with a Jack program in a single directory, say Xxx. Start by creating this directory, then copy all the files from tools/OS into it.
  2. Write your program -- a set of one or more Jack classes -- each stored in a separate ClassName.jack text file. Put all these .jack files in the Xxx directory.
  3. Compile your program using the supplied Jack Compiler (or the Jack IDE). This is best done by applying the compiler to the name of the program directory (Xxx). This will cause the compiler to translate all the .jack classes found in the directory into corresponding .vm files. If a compilation error is reported, debug the relevant class file and re-compile Xxx until no error messages are issued.
  4. At this point the Xxx directory should contain three sets of files: your source .jack files, the .vm files that the compiler generated from them, and the .vm files comprising the Jack OS. To test your program, load the entire Xxx directory into the VM Emulator and then run the program. In case of run-time errors or undesired program behavior, fix the program and go back to step 2.

Grading Criteria (1000 pts)

Due Date Points Description Grading Criteria
April 7 @ 4:00PM 100 Choose partners, declare program You must send me an email that tells me:
  • Who you are partnering with (or if you're working alone)
  • Whose repository you will be using (so I can add you as a collaborator)
  • What program you intend to build
April 9 @ 5:00PM 100 Initial version / Hello World in Jack You must create, compile and run, and then commit & push the Main class for your program, whose main() method should just print "Hello World" or something ridiculous to the screen.
This program should reside in project09/YourProgram/Main.jack.
April 12 @ 3:00PM 400 Screen specification You must commit & push a simple screen specification document (pdf preferred) that describes what your program will do. Examples will be presented in class, or you can refer to this simple example.
April 16 @ 5PM 400 Final program You must commit & push a complete, working version of your program. You should include a README unless your game is obvious to operate.

Your repository must show a history of work. You should be committing at least every time you complete a milestone (per the ones above or your own intermediate milestones). A repository log showing one commit with a message like "project done" is not acceptable.

The final due date is 5PM on Tuesday, April 16.