Dots and Boxes

Remember back in High School when you and a buddy got out a piece of graph paper, drew a grid of dots, and then proceeded to take turns connecting the dots to form boxes? Whoever had the most boxes at the end of the game won. Well, I implemented it in openGL! [Update 3/3/2012. I’ve uploaded the project for you to play! See details at the bottom of this post for more Update 9/30/2012: Due to (unpopular) demand, I’ve let the hosted file expire. Hit me up if you want me to repost it!]

Playing is simple: You’re initially asked by a prompt how many dots across you want to build your grid with (The whole grid will be square, so only the length of one side is needed).

Next, a grid is created for red and blue to play. Red always goes first. If you create a box (or more) then you get to go again!

Here, Red has just scored a box and thus gets to play again. Blue is way ahead, but that’s about to change! When someone wins the game, I created a cool little win animation where fireworks come up from the bottom screen and explode.

Here red has won!

Some notes about the project:

1. This was an early 2D project for my graphics course. As a result, I got a lot wrong before I got anything right. The clickable areas, drawing the boxes, displaying text. All that was really hard for a newbie.

2. When a box is created it makes a little grow/shrink animation that I think looks pretty cool.

3. The fireworks on the win screen probably took the longest out of any single task. I had to have a point rise up from the bottom, reach mid-screen, then render 100 or so dots in a random distribution around a circle. Each dot then had to simultaneously fall, shrink, and grow blacker as they faded out until they disappeared.

4. When a person wins, it’s displayed to the right of the scores in a randomly generated color. Snazzy!

Downloading and Playing

  1. Download the files from here.
  2. After you unzip the project, there should be an application named “DotsAndBoxes”, double-click that to start the program.
  3. The program will ask “How many dots?”, this is this size of your grid. Type 4 for a 4×4 grid, and 10 for a 10×10 grid.
  4. Players alternate turns, with Red always playing first. To draw a line, click the space where the line should be (between two points)
  5. If a player finishes a box, they get to draw another line.
  6. Whoever has the most boxes at the end wins! Enjoy!
Advertisements

Tags:

2 Responses to “Dots and Boxes”

  1. Pradeep Bajrachayra Says:

    can you post the file up for dots and boxes, it would be a real help. Thanks in advance

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: