-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCar.p
executable file
·165 lines (161 loc) · 4.48 KB
/
Car.p
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
unit Car;
interface
uses
Sound, QDOffScreen, Tools, Globals, GameGlobals, GameTools,
Animations, ToolUtils;
procedure DoCar;
implementation
procedure DoCar;
var
i:integer;
ResetSucc:boolean;
DeadString:string;
begin
if not Dead then
begin
Engine(UDSpeed + abs(LRSpeed) div 5);
if Jump <> 0 then
begin
if Jump < MaxJump then
Jump := Jump + 2
else
begin
MaxJump := 0;
Jump := Jump - 2;
end;
if Jump < 0 then
begin
Jump := 0;
CarDirection := CarDirection + random div 14000;
PlaySound(1103);
end;
end;
if (Jump = 0) then
begin
if LKey then
LRSpeed := LRspeed - round(UDSpeed / 50 * MyCar.Steering);
if RKey then
LRSpeed := LRspeed + round(UDSpeed / 50 * MyCar.Steering);
if AccKey and (Wait = 0) then
if UDSpeed>8 then
UDSpeed := UDSpeed + MyCar.Acc
else
UDSpeed := UDSpeed + MyCar.Acc*2;
if BrakKey then
begin
if (UDSpeed > MyCar.Speed * 3 div 4) and not BrakeDone then
PlaySound(1000);
BrakeDone := true;
if UDSpeed>=MyCar.Brakes then
UDSpeed := UDSpeed - MyCar.Brakes;
LrSpeed := LRSpeed div (MyCar.Brakes * 2);
end
else
BrakeDone := False;
if UDSpeed>=1 then
UDSpeed := UDSpeed - abs(random div 12000)
else if UDSpeed<=-1 then
UDSpeed := UDSpeed + abs(random div 12000);
if (DoneCount <> 0) then
if (UDSpeed >= 5) then
UDSpeed := UDSpeed - 5
else
UDSpeed:=0;
if UDSpeed > MyCar.Speed then
UDspeed := MyCar.Speed ;
if abs(LRSpeed) > MyCar.Speed then
LRspeed := MyCar.Speed * sign(LRSpeed);
if LRSpeed <> 0 then
LRSpeed := LRSpeed -1 * sign(LRSpeed);
if CheckSect(scroll + GamePrefs^^.Offset div 2, LRpos, 7, i) then
begin
if BitTst(@MyRoad^^.Flags, 0) then
if CheckSect(scroll + GamePrefs^^.Offset div 2, LRpos + 16, -16, i) and (DoneCount=0) then
begin
Dead := true;
Animate(MyCar.Crash, CarRect);
end;
if BitTst(@MyRoad^^.Flags, 1) then
if CheckSect(scroll + GamePrefs^^.Offset div 2, LRpos + 16, -16, i) and (DoneCount=0) then
begin
Dead := true;
Animate(MyCar.Drawn, CarRect);
end;
if BitTst(@MyRoad^^.Flags, 2) then
begin
if UDSpeed > round(16 * (MyCar.OffRoad / 100)) then
UDSpeed := UDSpeed - MyCar.Acc * 3;
if abs(LRSpeed) > round(8 * (MyCar.OffRoad / 100)) then
LRSpeed := LRSpeed - MyCar.Acc * 3 * LRSpeed div abs(LRSpeed);
end;
end;
end;
scroll := Scroll + UDSpeed div 2;
LRPos := LRPos + LrSpeed;
if UDSpeed <> 0 then
CarDirection := round((LRSpeed / UDSpeed) * 6)
else
Cardirection:=0;
if abs(CarDirection) > MyCar.Frames then
CarDirection := MyCar.Frames * sign(CarDirection);
SetRect(CarRect, LRPos, UDPos, LRPos + 32, UDPos + 32);
InsetRect(CarRect, -Jump div 5, -Jump div 5);
if not Dead then
PlotSprite(MyCar.BaseIcon + CarDirection, CarRect);
end
else if dead then
begin
if DeadCount = 0 then
begin
UDSpeed := 0;
LRspeed := 0;
KillEngine;
OldScroll := Scroll;
Lives := Lives - 1;
if Lives = 0 then
GameOver := true;
Deadcount := 20;
end;
if Info^^.Bonus=0 then
begin
GetIndString(DeadString, 2000, 7);
ShowMessage(DeadString, 310 - 100, 180, 36);
Info^^.Bonus:=500;
end;
Deadcount := DeadCount - 1;
if (DeadCount = 0) and not GameOver then
begin
Dead := false;
ResetSucc := false;
if Info^^.Bonus<0 then
Info^^.Bonus:=500;
for i := 15 downto 1 do
if Rebirthes^^[i].SCR < Scroll + GamePrefs^^.Offset then
begin
Scroll := Rebirthes^^[i].SCR;
OldScroll := Scroll - 480 + GamePrefs^^.Offset;
LRPos := Rebirthes^^[i].LRP;
ResetSucc := true;
Leave;
end;
if not ResetSucc then
begin
Scroll := 0;
OldScroll := 0 - 480 - GamePrefs^^.Offset;
LRPos := 310;
end;
end;
end;
if Scroll + GamePrefs^^.Offset div 2 > Info^^.StopAt then
begin
if DoneCount = 0 then
begin
DoneCount := 12;
PlaySound(1104);
end;
DoneCount := DoneCount - 1;
if DoneCount = 0 then
DoneCount := -1;
end;
end;
end.