


## brick-util.pkg
# Compiled by:
# src/lib/x-kit/tut/badbricks-game/badbricks-game-app.libstipulate
include threadkit; # threadkit is from src/lib/src/lib/thread-kit/src/core-thread-kit/threadkit.pkg #
package xg = xgeometry; # xgeometry is from src/lib/std/2d/xgeometry.pkg #
package xc = xclient; # xclient is from src/lib/x-kit/xclient/xclient.pkgherein
package brick_util
: Brick_Util # Brick_Util is from src/lib/x-kit/tut/badbricks-game/brick-util.api {
brick_size_high = 16;
brick_size_wide = 48;
brick_font = "-adobe-helvetica-medium-r-normal--10-100-*-*-p-56-iso8859-1";
Difficulty = EASY
| NORMAL
| HARD
| DESPERATE
| RIDICULOUS
| ABSURD
;
difficulty_list
=
[ EASY, NORMAL, HARD, DESPERATE, RIDICULOUS, ABSURD ];
Range = SHORT | LONG;
Palette
=
{ brick: xc::Rgb,
mark: xc::Rgb,
concrete: xc::Rgb,
dark_lines: xc::Rgb,
light_lines: xc::Rgb,
highlight_lines: xc::Rgb
};
fun difficulty_probability d
=
case d
#
EASY => 15;
NORMAL => 20;
HARD => 25;
#
DESPERATE => 30;
RIDICULOUS => 40;
ABSURD => 50;
esac;
fun difficulty_name d
=
case d
#
EASY => "Easy";
NORMAL => "Normal";
HARD => "Hard";
DESPERATE => "Desperate";
RIDICULOUS => "Ridiculous";
ABSURD => "Absurd";
esac;
fun cmp_difficulty (d1, d2)
=
difficulty_probability d1
-
difficulty_probability d2;
State = NO_BRICK_STATE
| UNKNOWN_STATE
| OK_STATE
| BAD_STATE Int # Number of good brick neighbors.
;
fun state_val NO_BRICK_STATE => -3;
state_val UNKNOWN_STATE => -2;
state_val OK_STATE => -1;
state_val (BAD_STATE count) => count;
end;
Position = xg::Point;
fun west_of (xg::POINT { col, row } ) = xg::POINT { col=>col - 1, row=>row };
fun northwest_of (xg::POINT { col, row } ) = xg::POINT { col=>col - 1+(row % 2), row=>row - 1 };
fun northeast_of (xg::POINT { col, row } ) = xg::POINT { col=>col + (row % 2), row=>row - 1 };
fun east_of (xg::POINT { col, row } ) = xg::POINT { col=>col+1, row=>row };
fun southeast_of (xg::POINT { col, row } ) = xg::POINT { col=>col + (row % 2), row=>row + 1 };
fun southwest_of (xg::POINT { col, row } ) = xg::POINT { col=>col - 1+(row % 2), row=>row + 1 };
Mse_Evt = DOWN (xc::Mousebutton, Position)
| UP (xc::Mousebutton, Position)
| CANCEL Position
;
};
end;


