This repository has been archived by the owner on May 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.pas
134 lines (95 loc) · 2.89 KB
/
main.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
//-----------------------------------------------------------------------------
{$r media/media.rc}
//-----------------------------------------------------------------------------
uses aplib;
//-----------------------------------------------------------------------------
{$i 'inc/const.inc'}
{$i 'inc/types.inc'}
{$i 'inc/globals.inc'}
{$i 'inc/tools.inc'}
{$i 'inc/interrupts.inc'}
{$i 'inc/ai.inc'}
{$i 'inc/levels.inc'}
{$i 'inc/init.inc'}
//-----------------------------------------------------------------------------
procedure playerMove;
begin
if ply.isAlive then begin
checkAvailDir;
if availDir = 0 then playerBusted
else begin
case ply.brain of
PLY_CTRL : human;
AI_STRAIGHT : aiStraight;
AI_SAPPER : aiSapper;
AI_BULLY : aiBully;
AI_MIRROR : aiMirror;
end;
drawPlayer;
end;
end;
end;
//-----------------------------------------------------------------------------
procedure mainLoop;
begin
initArena; startScreen;
repeat
pause; ply := @player1; playerMove;
pause(2); // 1 fast; 2 normal; 3 slow
ply := @player2; playerMove;
ply := @player3; playerMove;
ply := @player4; playerMove;
until isOneLeft;
updateScore; pause(100); nextLevel;
end;
//-----------------------------------------------------------------------------
procedure welcome;
begin
pause;
initPlayfield;
setPlayer(@player1, 3, Random(18) + 3, direction[Random(4)], AI_SAPPER, PLY1_COLOUR, true);
setPlayer(@player2, 36, Random(18) + 3, direction[Random(4)], AI_SAPPER, PLY2_COLOUR, true);
pause;
printXY('ai calibration, computing,'~, 2, 0, $71);
printXY(' * wait * '~, 28, 0, $71 + $80);
pause;
printBigXY(3, 3, $51, 'tron'~);
printBigXY(11, 13, $51, '+4'~);
repeat
pause(4);
ply := @player1; playerMove;
ply := @player2; playerMove;
until (not player1.isAlive) or (not player2.isAlive);
end;
//-----------------------------------------------------------------------------
procedure showGFX;
begin
t0b := SETBITMAP; t1b := VIDEOMATRIX; i0b := SETMCOLOR; i1b := TED_FF12;
SETBITMAP := 0;
SETMCOLOR := (SETMCOLOR and $40) or $18;
VIDEOMATRIX := %01011000;
TED_FF12 := %00011000 or (TED_FF12 and %00000011);
BORDER := 0;
BACKGROUND := 0;
COLOUR1 := 1;
SETBITMAP := t0b or $20;
pause(400);
SETBITMAP := 0;
unapl(pointer(MP_LOGO_APL), pointer(GFX));
SETMCOLOR := (SETMCOLOR and $40) or $8;
BORDER := $3d;
SETBITMAP := t0b or $20;
pause(200);
SETBITMAP := t0b; VIDEOMATRIX := t1b; SETMCOLOR := i0b; TED_FF12 := i1b;
end;
//-----------------------------------------------------------------------------
begin
initSystem; showGFX;
repeat
welcome; initScore; gameOver := false; level := 1;
pause;
repeat mainLoop until isGameOver;
showScore; endScreen;
until false;
end.
//-----------------------------------------------------------------------------