This repository has been archived by the owner on Apr 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathelements.pas
218 lines (175 loc) · 4.27 KB
/
elements.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
unit Elements;
interface
const
cIdHero1 = 0;
cIdHero2 = 1;
cIdEvil = 2;
type
PCharacter = ^TCharacter;
TCharacter =
record
id : Byte;
x, y : Integer;
xFrac, yFrac : Integer;
speed : Integer;
direction : Byte;
faceDir : Byte;
facial : Byte;
face : Byte;
body : Byte;
gunPic : Byte;
gunPos : Byte;
phase : Byte;
command : Byte;
armor : Integer;
lives : Integer;
invincibility : Integer;
dead : Boolean;
deathCount : Integer;
gun :
record
kind : Byte;
lock : Byte;
ammo : Integer;
end;
closeCombat : Byte;
cmd : Byte;
actionDelay,
delay : Byte;
visible,
sleeping : Boolean;
moving,
shooting,
launching,
tracking : Byte;
isTarget : Boolean;
boobyTrapped : Boolean;
detouring : Boolean;
tryRight : Boolean;
turns : Integer;
currentDir : Word;
distanceToPlayer : Word;
prev,
next : PCharacter;
end;
PBullet = ^TBullet;
TBullet =
record
id : Byte;
kind : Byte;
x, y : Integer;
xFrac,
yFrac : Integer;
dx, dy : Integer;
range : Integer;
owner : Byte;
pic : Integer;
prev,
next : PBullet;
end;
PFireBall = ^TFireBall;
TFireBall =
record
stage : Integer;
x, y : Integer;
prev,
next : PFireBall;
end;
function AddCharacter( id : Byte ) : PCharacter;
function RemoveCharacter( c : PCharacter ) : PCharacter;
function AddBullet : PBullet;
function RemoveBullet( b : PBullet ) : PBullet;
function AddFireBall : PFireBall;
function RemoveFireBall( f : PFireBall ) : PFireBall;
procedure RemoveAllElements;
const
gHero1 : PCharacter = nil;
gHero2 : PCharacter = nil;
gCharacters : PCharacter = nil;
gBullets : PBullet = nil;
gFireBalls : PFireBall = nil;
implementation
function AddCharacter( id : Byte ) : PCharacter;
var c : PCharacter;
begin
New( c);
FillChar( c^, SizeOf( c^), 0);
c^.id := id;
c^.prev := nil;
c^.next := gCharacters;
if gCharacters <> nil then
gCharacters^.prev := c;
gCharacters := c;
AddCharacter := c;
end;
function RemoveCharacter( c : PCharacter ) : PCharacter;
begin
if c^.next <> nil then
c^.next^.prev := c^.prev;
if c^.prev <> nil then
c^.prev^.next := c^.next
else
gCharacters := c^.next;
RemoveCharacter := c^.next;
if c = gHero1 then
gHero1 := nil;
if c = gHero2 then
gHero2 := nil;
Dispose( c);
end;
function AddBullet : PBullet;
var b : PBullet;
begin
New( b);
FillChar( b^, SizeOf( b^), 0);
b^.prev := nil;
b^.next := gBullets;
if gBullets <> nil then
gBullets^.prev := b;
gBullets := b;
AddBullet := b;
end;
function RemoveBullet( b : PBullet ) : PBullet;
begin
if b^.next <> nil then
b^.next^.prev := b^.prev;
if b^.prev <> nil then
b^.prev^.next := b^.next
else
gBullets := b^.next;
RemoveBullet := b^.next;
Dispose( b);
end;
function AddFireBall : PFireBall;
var f : PFireBall;
begin
New( f);
FillChar( f^, SizeOf( f^), 0);
f^.prev := nil;
f^.next := gFireBalls;
if gFireBalls <> nil then
gFireBalls^.prev := f;
gFireBalls := f;
AddFireBall := f;
end;
function RemoveFireBall( f : PFireBall ) : PFireBall;
begin
if f^.next <> nil then
f^.next^.prev := f^.prev;
if f^.prev <> nil then
f^.prev^.next := f^.next
else
gFireBalls := f^.next;
RemoveFireBall := f^.next;
Dispose( f);
end;
procedure RemoveAllElements;
begin
while gCharacters <> nil do
RemoveCharacter( gCharacters);
while gBullets <> nil do
RemoveBullet( gBullets);
while gFireBalls <> nil do
RemoveFireBall( gFireBalls);
end;
end.