gh-scrum/src/gohamster.pas

51 lines
1.0 KiB
ObjectPascal

program go_hamster;
uses crt, arena_m, trace_m, creature_m, graphics_m, hamster_m, keys_m, ghost_m,
debug_m;
const
DelaySizeMs = 75;
procedure RunLevel;
var
h, g: creature;
a: arena;
t: tracePtr = nil;
continueLevel: boolean = true;
begin
Init(a);
InitHamster(h);
InitGhost(g);
DrawCreature(h);
DrawCreature(g);
while continueLevel do
begin
delay(DelaySizeMs);
if ArenaSplited(h, t, a) then
begin
SetArenaBorder(t, a);
CutSmallerPart(h, t, a)
end;
if keypressed then
HandleKey(h, continueLevel, a, t);
if not HamsterStepPossible(h, t, a) then
StopCreature(h);
if not ((h.dX = 0) and (h.dY = 0)) then
MakeHamsterStep(h, t, a);
MakeEnemyStep(g, a);
if GhostShouldTurn(g, a) then
TurnGhost(g, a)
end
end;
begin
if not IsTerminalValid then
begin
PrintTerminalHelp;
exit
end;
clrscr;
DrawLevel;
RunLevel;
clrscr
end.