RobotArena.mesa
Edited by Nickell on July 9, 1985 5:32:42 pm PDT
DIRECTORY
RobotDefs USING [RobotIndex, RobotPic],
Rope USING [ROPE],
ViewerOps USING [CreateViewer],
ViewerClasses USING [Viewer, ViewerRec];
RobotArena: CEDAR DEFINITIONS
IMPORTS ViewerOps
~ {
OPEN V: ViewerClasses;
RobotIndex: TYPE ~ RobotDefs.RobotIndex;  --The number of robots on the screen at a time...
RobotPic: TYPE ~ RobotDefs.RobotPic;
Arena: TYPE = V.Viewer;  --Arenas are just viewers that are suited for robot battle.
arenaWidth, arenaHeight: INT ~ 100;
RobotImage: TYPE ~ RECORD [
x, y: REAL ← (arenaWidth)/2,  --Position of the robot
hit: BOOLEANFALSE,   --TRUE => show robot under fire
fire: BOOLEAN ← FALSE,   --Is he firing right now?
fireAngle: INT ← 0   --Angle if so.
];
Create: PROC [info: V.ViewerRec ← [], paint: BOOLTRUE] RETURNS [arena: Arena] =
INLINE {RETURN[ViewerOps.CreateViewer[$Arena, info, paint]]};
Creates a new, empty arena.
SetRobot: PROC [self: V.Viewer, i: RobotIndex, image: RobotImage];
Set all the information about a robot.
GetRobot: PROC [self: V.Viewer, i: RobotIndex] RETURNS [image: RobotImage];
Get all the information about a robot.
SetRobotLocation: PROC [self: Arena, num: RobotIndex, x, y: REAL];
Set the position of the specified robot within the arena...
SetRobotPicture: PROC [self: Arena, num: RobotIndex, picture: RobotPic];
Change the picture of the specified robot
SetRobotColor: PROC [index: RobotIndex, color: Rope.ROPE];
Change the default robot color
}.