Игровая программа
CountTickTimer:=0;
RightButton:=true;
PlaySound('SoundSelect_CarMenu.wav',0,SND_ASYNC);
end;
if CarMenuItem>4 then CarMenuItem:=1;
if CarMenuItem<1 then CarMenuItem:=4;
end; //Car
end;//CountTickTimer
if Selected_Menu_item='Exit' then //Нажата клавиша Exit в гланом меню
begin
SpeedGL.MediaPlayer1.Free;
Application.Terminate;
Application.ProcessMessages;
end;
InvalidateRect(SpeedGL.Handle, nil, False);//перерисовка
if (Symvol=0)and
(PressedKey[78]=true)and
(CountNitro>0)and
(GasDeley=1) then
begin
Gas:=true;
CountNitro:=CountNitro-1;
GasDeley:=0;
PlaySound('SoundStart_Nitro.wav',0,SND_ASYNC);
end;
end;
событие OnPaint:
procedure TSpeedGL.FormPaint(Sender: TObject);
var
ps:TPaintStruct;
begin
BeginPaint(dc,ps);
if Selected_Menu_item='' then
begin
case Menu_item of
1:begin LeftTiresMeny:=-0.849; RightTiresMeny:=0.8; TopTiresMeny:=0.76; end;
2:begin LeftTiresMeny:=-1.1; RightTiresMeny:=1.0; TopTiresMeny:=0.4; end;
3:begin LeftTiresMeny:=-0.8; RightTiresMeny:=0.8; TopTiresMeny:=0.0; end;
4:begin LeftTiresMeny:=-0.8; RightTiresMeny:=0.8; TopTiresMeny:=-0.58; end;
end;
if OldSelectMenyItem='Car' then begin
if RemoveMeny>=0.0 then begin RemoveMeny:=0.0; OldSelectMenyItem:='' end else
RemoveMeny:=RemoveMeny+0.018;
glCallList(Background);
glPushMatrix;
glTranslatef(RemoveMeny,0.0,0.0);
glCallList(StringMeny);
glPopMatrix;
end
else begin
glCallList(Background);//Загрузка фона
glCallList(StringMeny);//Загрузка надписей в меню
end;
if (Selected_Menu_item<>'Car')and(RemoveMeny=0.0) then begin
Angel:=Angel+1;
if Angel=360 then Angel:=0;
glCallList(8);//Загрузка колеса
glPushMatrix;
glScalef(0.5,0.66,0.5);
glTranslatef(LeftTiresMeny,TopTiresMeny,0.0);
glRotatef(Angel,0.0,0.0,1.0);
glCallList(Tires);
glPopMatrix;
glPushMatrix;
glScalef(0.5,0.66,1.0);
glTranslatef(RightTiresMeny,TopTiresMeny,0.0);
glRotatef(Angel,0.0,0.0,1.0);
glCallList(Tires);
glPopMatrix;
end;
end;
if Selected_Menu_item='Start' then //Нажата клавиша Start игра началась
begin //Start
// glClear(GL_COLOR_BUFFER_BIT); //медленное стирание
glPushMatrix;
glTranslatef(0.0,Y_Kord,0.0);
glCallList(WayDesert_1);
glPopMatrix;
glPushMatrix;
glTranslatef(0.0,Y_Kord+1.99,0.0);
glCallList(WayDesert_1);
glPopMatrix;
if not Pause then
if Speed<>0 then CountKM:=CountKM+abs(Speed/27);//количесто пройденых километров
// Caption:=FloatToStrF(CountKM,ffNumber,6,3);
//Генерирование Бензина или Нитро на дороге
if (CountKM>NextKM_GenerFuel)and(FuelGoToWay=False)and(speed<>0) then
begin
if Random(2)=1 then X_KordFuel:=Random*0.5 else X_KordFuel:=-Random*0.5;
FuelGoToWay:=true;
Y_KordFuel:=1.5;
Inc(NextKM_GenerFuel,1);
if not FuelOrNitro then FuelOrNitro:=true else FuelOrNitro:=false;
end;
if (FuelGoToWay)and(Y_KordFuel<-1.2) then FuelGoToWay:=False;
//Прорисовка Бензина или Нитро
if not KordObjectItems(X_KordFuel,Y_KordFuel,0.05,0.065,X_KordCar,Y_KordCar,CarXPogresh,CarYPogresh) then
begin // KordObject
glPushMatrix;
glTranslatef(X_KordFuel,Y_KordFuel,0.0);
if FuelOrNitro then glCallList(ItemFuelList) else glCallList(ItemNitroList);
glPopMatrix;
end//KordObject
else
begin
Y_KordFuel:=1.5;
FuelGoToWay:=False;
PlaySound('SoundGet_Nitro_Fuel.wav',0,SND_ASYNC);
if FuelOrNitro then if CountFuel<20 then CountFuel:=CountFuel+1;
if not FuelOrNitro then if CountNitro<=10 then CountNitro:=CountNitro+1;
end;
//////////////////////////////////////////////////////
{Caption:=FloatToStrF(CountFuel,ffNumber,6,3)+' '+
FloatToStrF(CountNitro,ffNumber,6,3)+' '+
FloatToStrF(CountKM,ffNumber,6,3)+' '+
FloatToStrF(GasDeley,ffNumber,6,3);}
//////////////////////////////////////////////////////
if (CountKM>NextKmEnymy)and(EnymiGoToWay=False)and(speed<>0) then
begin
NumbrCar:=random(9)+1;
EnymiGoToWay:=true;
NextKmEnymy:=NextKmEnymy+0.1;
Y_Enymi:=1.2;
end;
if (EnymiGoToWay)and(Y_Enymi<-1.2) then EnymiGoToWay:=False;
if not KordObjectEnimy(X_Enymi,Y_Enymi,0.08,0.130,X_KordCar,Y_KordCar,CarXPogresh-0.05,CarYPogresh-0.05) then
begin // KordObject
glPushMatrix;
glTranslatef(X_Enymi,Y_Enymi,0.0);
glCallList(EnymiCars[NumbrCar]);
glPopMatrix;
end//KordObject
else
begin
Y_Enymi:=1.2;
EnymiGoToWay:=False;
GasDeley:=1;
Gas:=false;
Speed:=-0.001;
PlaySound('SoundDenger_Sound.wav',0,SND_ASYNC);
if CountFuel>0 then CountFuel:=CountFuel-1;
if CountFuel<0 then CountFuel:=0;
end;
//рисование машины
if ChooseCar='ShotWarKiller' then begin
glPushMatrix;
glTranslatef(X_KordCar,Y_KordCar,0.0);
glCallList(WarKiller);
glPopMatrix;
end;
if ChooseCar='ShotFlash' then begin
glPushMatrix;
glTranslatef(X_KordCar,Y_KordCar,0.0);
glCallList(Flash);
glPopMatrix;
end;
if ChooseCar='ShotGembic' then begin
glPushMatrix;
glTranslatef(X_KordCar,Y_KordCar,0.0);
glCallList(Gembic);
glPopMatrix;
end;
if ChooseCar='ShotGlass' then begin
glPushMatrix;
glTranslatef(X_KordCar,Y_KordCar,0.0);
glCallList(Glass);
glPopMatrix;
end;
//Проигрыш и выигрышь в игре
if (CountFuel<=0)and(CountKM<20) then begin glCallList(GameOver); if not sound then sound:=true; end;
if CountKM>=20 then begin glCallList(YouWin); if not sound then sound:=true; end;
if ((CountFuel<=0)or(CountKM>=20))and(Speed>=0)then begin
glPushMatrix;
glTranslatef(0.0,-0.4,0.0);
glCallList(PressEsc);
glPopMatrix