%Declaration Statments
var attacked : boolean := false
var thisColour : int % Used to set square colours
var output_col : int % Used in xySquareID to find the clicked column
var output_row : int % Used in xySquareID to find the clicked row
var output_xy : array 1 .. 2 of int % Used in SquareIDXY to output the xy coordinates for displaying
var player_squares : array 1 .. 10, 1 .. 10 of int
var opponent_squares : array 1 .. 10, 1 .. 10 of int
for current_row : 1 .. 10
for current_column : 1 .. 10
player_squares (current_row, current_column) := 0
opponent_squares (current_row, current_column) := 0
end for
end for
% Colour Settings
var col_emp, col_hit, col_mis, col : int
col := 0
col_emp := 101 % Light Blue
col_hit := 40 % Red
col_mis := 9 % Dark Blue
% Square ID to X Y - Inputs SquareID, Outputs the X and Y for displaying
procedure squareIDXY (input_row : int, input_col : int, who : int)
if who = 1 then
if input_col = 1 then
output_xy (1) := 25
elsif input_col = 2 then
output_xy (1) := 50
elsif input_col = 3 then
output_xy (1) := 75
elsif input_col = 4 then
output_xy (1) := 100
elsif input_col = 5 then
output_xy (1) := 125
elsif input_col = 6 then
output_xy (1) := 150
elsif input_col = 7 then
output_xy (1) := 175
elsif input_col = 8 then
output_xy (1) := 200
elsif input_col = 9 then
output_xy (1) := 225
elsif input_col = 10 then
output_xy (1) := 250
end if
else
if input_col = 1 then
output_xy (1) := 275
elsif input_col = 2 then
output_xy (1) := 300
elsif input_col = 3 then
output_xy (1) := 325
elsif input_col = 4 then
output_xy (1) := 350
elsif input_col = 5 then
output_xy (1) := 375
elsif input_col = 6 then
output_xy (1) := 400
elsif input_col = 7 then
output_xy (1) := 425
elsif input_col = 8 then
output_xy (1) := 450
elsif input_col = 9 then
output_xy (1) := 475
elsif input_col = 10 then
output_xy (1) := 500
end if
end if
if input_col = 10 then
output_xy (2) := 25
elsif input_col = 9 then
output_xy (2) := 50
elsif input_col = 8 then
output_xy (2) := 75
elsif input_col = 7 then
output_xy (2) := 100
elsif input_col = 6 then
output_xy (2) := 125
elsif input_col = 5 then
output_xy (2) := 150
elsif input_col = 4 then
output_xy (2) := 175
elsif input_col = 3 then
output_xy (2) := 200
elsif input_col = 2 then
output_xy (2) := 225
elsif input_col = 1 then
output_xy (2) := 250
end if
end squareIDXY
% Check if Already Attacked
procedure checkAttacked (input_row : int, input_col : int, who : int)
attacked := false % Reset attacked to false
if who = 1 then % If who is player(1)
if player_squares (input_row, input_col) = 0 then
attacked := false
else
attacked := true
end if
else % If who is opponant (2)
if opponent_squares (input_row, input_col) = 0 then
attacked := false
else
attacked := true
end if
end if
end checkAttacked
% Colour in Squares
procedure fillSquares
for column : 1 .. 10
for row : 1 .. 10
squareIDXY (row, column, 1)
squareColour (row, column, 1)
drawfill (output_xy (1), output_xy (2), thisColour, 7)
end for
end for
end fillSquares |