gh-scrum/src/gohamster.pas

51 lines
1.0 KiB
ObjectPascal
Raw Normal View History

2026-02-28 09:28:56 +00:00
program go_hamster;
2026-02-28 10:57:08 +00:00
uses crt, arena_m, trace_m, creature_m, graphics_m, hamster_m, keys_m, ghost_m,
debug_m;
2026-02-28 10:40:16 +00:00
2026-02-28 09:38:37 +00:00
const
2026-02-28 10:57:08 +00:00
DelaySizeMs = 75;
2026-02-28 10:22:41 +00:00
procedure RunLevel;
var
2026-02-28 10:57:08 +00:00
h, g: creature;
a: arena;
t: tracePtr = nil;
2026-02-28 10:22:41 +00:00
continueLevel: boolean = true;
begin
2026-02-28 10:57:08 +00:00
Init(a);
InitHamster(h);
InitGhost(g);
DrawCreature(h);
DrawCreature(g);
2026-02-28 10:22:41 +00:00
while continueLevel do
2026-02-28 09:38:37 +00:00
begin
delay(DelaySizeMs);
2026-02-28 10:57:08 +00:00
if ArenaSplited(h, t, a) then
2026-02-28 09:38:37 +00:00
begin
2026-02-28 10:57:08 +00:00
SetArenaBorder(t, a);
CutSmallerPart(h, t, a)
2026-02-28 10:16:21 +00:00
end;
2026-02-28 10:22:41 +00:00
if keypressed then
2026-02-28 10:57:08 +00:00
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)
2026-02-28 09:38:37 +00:00
end
2026-02-28 10:22:41 +00:00
end;
2026-02-28 09:38:37 +00:00
2026-02-28 10:22:41 +00:00
begin
if not IsTerminalValid then
begin
PrintTerminalHelp;
exit
end;
clrscr;
2026-02-28 10:57:08 +00:00
DrawLevel;
2026-02-28 10:22:41 +00:00
RunLevel;
2026-02-28 10:57:08 +00:00
clrscr
2026-02-28 10:22:41 +00:00
end.