Developing User Interfaces
CMSC 498B
Spring 2005
Prof. Ben Bederson
Project #2
Due March 17, 2005


Purpose

The purpose of this program is to implement undo/redo using the Command design pattern, and use an independent model and view.

The Problem

You must create a game that lets users solve a puzzle of the type depicted in the photo below.  An image is broken up into N x N tiles. One of the tiles is missing, and the game starts with all tiles initially in a random order.  There is a single action a player can perform on this game.  Clicking on any tile shifts the tiles between the clicked tile and the empty space one cell towards the empty space.  In this way, the tile clicked on becomes empty.  If the player clicks on a tile which is not in the same row or column as the empty cell, then nothing happens.  In addition, if the player clicks on the empty cell, nothing happens.

There is one extra trick for this implementation which is that you must display two synchronized games with different images, where interacting with either one plays the game, but both games remain in sync.

The requirements of the project are:

C# Hints

    using System.Net;
    using System.IO;
    public Image FetchImage(string url) {
        HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
        WebResponse webResponse = webRequest.GetResponse();
        Stream stream = webResponse.GetResponseStream();
        return Bitmap.FromStream(stream);
    }

public Image CropImage(Image inImage, int x, int y, int width, int height) {
    Image outImage = new Bitmap(inImage, width, height);
    Graphics g = Graphics.FromImage(outImage);
    g.Clear(Color.Black);
    g.DrawImage(inImage, new Rectangle(0, 0, width, height),
                new Rectangle(x, y, width, height), GraphicsUnit.Pixel);
    g.Dispose();

    return outImage;
}
 

Submitting

Submit following the same rules as Project #1, but make the subject line of your email contain "DUI: Proj #2 submission".  As before, any submissions after the deadline will be ignored.  If multiple submissions are made, then only the last one before the deadline will be looked at.

The zip file you submit must contain all files within a directory named "proj2-<name>.zip" where you replace <name> with your last name.