Assignment #3
Battleships, Graphical Version, no Animation
Due: We. Oct. 6th
Score:
10 points
- in time: 100%
- one week delay: 65%
- two weeks delay: 40%
- else: 20%
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:
- unexplored water: DARK BLUE [0,0,0.4] (on both sides, player and computer)
- unexplored ship: GREEN [0,0.8,0] on player's terrain, DARK BLUE on computer's terrain
- explored water: LIGHT BLUE [0.2,0.2,1.0]
- explored ship, hit: LIGHT RED [0.9,0.3,0.3] (both sides)
- explored ship, sunk: PURE BRIGHT RED [1.0, 1.0, 1.0] (both sides)
- water, close to at least one unexplored ship: LIGHT BLUE on player's terrain, GRAY [0.5, 0.5, 0.5]
on computer's terrain
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:
- change the output
- change the game input to be mouse based. This means: change your game logic from structured programming to
event based programming
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).