Assignment #3

Battleships, Graphical Version, no Animation

Due: We. Oct. 6th
Score: 10 points


This assignment has to be done by everyone if not specified otherwise. All people who do NOT have to process this assignment will be informed by me personally on Wednesday. These will be the people already heaving a huge programming load due to the projects they are working on. If you are not sure if your load is high enough to qualify for this relief please contact me so that there will be no misconception.

Modify the output of your Battleships program, do not use any console print commands any longer, use OpenGL instead. Show each battlefield (= the matrix) as a grid of quads, being placed in XY plane. The state of each field is defined by color:

Make sure that you still provide a grid, not a plane blue surface without a grid structure. You can achieve this by first drawing the filled quads and draw on top of it a quad as outline, having color black. Or you simply draw a quad that is smaller than the field it is supposed to occupy, hence leaving space for the background.

The initial input (position of the ships etc.) can still be made by console input, the game itself though must react to mouseclicks, i.e. you select a certain square by simply clicking on it. The function required is 'glutMouseFunc', you find a web tutorial HERE .

The task you have therefore consists of 2 parts:

For JAVA programmers:
Your task is a bit different: you might use swing instead of openGL, but you have to draw all your output in a single panel, i.e. no labels, buttons, layouts, ... are allowed. We might extend the program with animation later, and and this animation will cover the whole playfield (i.e. the whole output window).