DisplayField:
PROC[context: Imager.Context, erase:
BOOL] = {
x, y: REAL;
rope: ROPE;
IF erase THEN Erase[context, ImagerBackdoor.GetBounds[context]];
IF viewer.column = color
THEN {
Imager.SetColor[context, ImagerColor.ColorFromAtom[$Green]];
Imager.MaskRectangle[context, ImagerBackdoor.GetBounds[context]];
Imager.SetColor[context, Imager.white];
};
y ← fieldWidth*yard;
DrawLine[context, -10*yard, 0, 110*yard, 0];
DrawLine[context, -10*yard, fieldWidth*yard, 110*yard, fieldWidth*yard];
DrawLine[context, -10*yard, 0, -10*yard, y];
DrawLine[context, 110*yard, 0, 110*yard, y];
FOR i:
INTEGER
IN [0..10]
DO
x ← i*10*yard;
y ← fieldWidth*yard;
DrawLine[context, x, 0, x, y];
DrawLine[context, x-3, y/3, x+3, y/3];
DrawLine[context, x-3, 2*y/3, x+3, 2*y/3];
IF i = 0
OR i = 10
THEN rope ← Rope.FromChar['G]
ELSE rope ← Convert.RopeFromInt[MIN[100-i*10, i*10]];
DrawRope[context, rope, x-5, y+5];
DrawRope[context, rope, x-5, -15];
ENDLOOP;
IF viewer.column # color
THEN {
Imager.SetGray[context, 0.5];
Imager.MaskBox[context, [-10*yard, 0, 0, fieldWidth*yard]];
Imager.MaskBox[context, [100*yard, 0, 110*yard, fieldWidth*yard]];
Imager.SetGray[context, black];
};
};
DisplayStats:
PROC[context: Imager.Context, erase:
BOOL] = {
(home)
HOME* First Quarter VISITORS
7 7:14 14
4 - timeouts - 4
first down and goal on the 4
number: ROPE;
IF erase THEN Erase[context, scoreboard];
MessageWindow.Clear[]; -- remove any messages.
first line
IF myTeam = home
THEN DrawRope[context, "(home)", statsX+82, statsY+15]
ELSE DrawRope[context, "(visitors)", statsX+75, statsY+15];
Imager.SetXY[context, [statsX, statsY]];
IF game.offense = home
THEN MyShowRope[context, "HOME* "]
ELSE MyShowRope[context, "HOME "];
SELECT game.quarter
FROM
1 => MyShowRope[context, " First Quarter "];
2 => MyShowRope[context, " Second Quarter "];
3 => MyShowRope[context, " Third Quarter "];
4 => MyShowRope[context, " Fourth Quarter "];
5 => MyShowRope[context, " Game Over "];
ENDCASE => ERROR;
IF game.offense = visitors
THEN MyShowRope[context, "VISITORS* "]
ELSE MyShowRope[context, "VISITORS "];
second line
number ← Convert.RopeFromInt[game.score[home]];
DrawRope[context, number, statsX+20, statsY-15];
(clock drawn separately)
number ← Convert.RopeFromInt[game.score[visitors]];
DrawRope[context, number, statsX+185, statsY-15];
third line
number ← Convert.RopeFromInt[game.timeouts[home]];
DrawRope[context, number, statsX+20, statsY-30];
DrawRope[context, " - timeouts - ", statsX+60, statsY-30];
number ← Convert.RopeFromInt[game.timeouts[visitors]];
DrawRope[context, number, statsX+185, statsY-30];
fourth line
SELECT game.down
FROM
1 => number ← "first down and ";
2 => number ← "second down and ";
3 => number ← "third down and ";
4 => number ← "fourth down and ";
ENDCASE => number ← ">>>> down and ";
DrawRope[context, number, statsX-20, statsY-45];
IF game.firstDownMarker <= 0
OR game.firstDownMarker >= 100
THEN number ← "goal"
ELSE {toGo:
INTEGER;
toGo ← Real.RoundI[ABS[game.scrimmage-game.firstDownMarker]];
number ← IF toGo < 1 THEN "inches" ELSE Convert.RopeFromInt[toGo]};
MyShowRope[context, number];
MyShowRope[context, " to go on the "];
number ← Convert.RopeFromInt[
MIN[Real.RoundI[game.scrimmage], Real.RoundI[100-game.scrimmage]]];
MyShowRope[context, number];
MyShowRope[context, " yard line."];
display status
Imager.SetXY[context, [statsX - 20, statsY - 60]];
IF game.penalties # [none, none] THEN {DisplayPenalties[context]; RETURN};
Imager.SetXY[context, [statsX + 60, statsY - 60]];
SELECT game.score[home] - oldScore[home]
FROM
7 => FlashMessage["TOUCHDOWN! "];
3 => FlashMessage["FIELD GOAL! "];
2 => FlashMessage["SAFETY! "];
ENDCASE;
SELECT game.score[visitors] - oldScore[visitors]
FROM
7 => FlashMessage["TOUCHDOWN! "];
3 => FlashMessage["FIELD GOAL! "];
2 => FlashMessage["SAFETY! "];
ENDCASE;
};
DisplayClock:
PROC[context: Imager.Context, clock:
INTEGER, erase:
BOOL] = {
stream: IO.STREAM ← IO.ROS[];
IF erase THEN Erase[context, [statsX+89, statsY-16, 60, 12]];
stream.PutF["%2d:%02d", IO.int[clock/60], IO.int[clock MOD 60]];
DrawRope[context, IO.RopeFromROS[stream], statsX+90, statsY-15];
stream.Close[];
};
DisplayPlayer:
PROC[context: Imager.Context, player: Player, erase:
BOOL] = {
i: Position;
x, y: REAL;
same: BOOL;
char: CHAR;
i ← player.position;
x ← Real.RoundI[player.x*yard];
y ← Real.RoundI[player.y*yard];
char ← IF TeamOf[i] = home THEN 'O ELSE 'X;
same ← (x = shadow[i].oldX AND y = shadow[i].oldY AND char = shadow[i].char);
IF erase AND same THEN RETURN;
IF erase AND ~same THEN DrawChar[context, shadow[i].char, shadow[i].oldX, shadow[i].oldY];
DrawChar[context, char, x, y];
shadow[i].oldX ← x;
shadow[i].oldY ← y;
shadow[i].char ← char;
};