if PressedKey[27]=true then
begin
Selected_Menu_item:='';
SpeedGL.MediaPlayer1.Stop;
SpeedGL.MediaPlayer1.Close;
SpeedGL.MediaPlayer1.FileName:='';
CountTickTimer:=0;
end;
if Selected_Menu_item='Car' then //Íàæàòà êëàâèøà Car
begin //Car
if SpeedGL.MediaPlayer1.FileName<>'Sound\Garage.mp3' then begin
SpeedGL.MediaPlayer1.FileName:='Sound\Garage.mp3';
SpeedGL.MediaPlayer1.Open;
SpeedGL.MediaPlayer1.Play;
OldSelectMenyItem:='Car';
if PressedKey[37]=true then
Dec(CarMenuItem);
LeftButton:=true;
PlaySound('Sound\Select_CarMenu.wav',0,SND_ASYNC);
if PressedKey[39]=true then
Inc(CarMenuItem);
RightButton:=true;
if CarMenuItem>4 then CarMenuItem:=1;
if CarMenuItem<1 then CarMenuItem:=4;
end; //Car
end;//CountTickTimer
if Selected_Menu_item='Exit' then //Íàæàòà êëàâèøà Exit â ãëàíîì ìåíþ
SpeedGL.MediaPlayer1.Free;
Application.Terminate;
Application.ProcessMessages;
InvalidateRect(SpeedGL.Handle, nil, False);//ïåðåðèñîâêà
if (Symvol=0)and
(PressedKey[78]=true)and
(CountNitro>0)and
(GasDeley=1) then
Gas:=true;
CountNitro:=CountNitro-1;
GasDeley:=0;
PlaySound('Sound\Start_Nitro.wav',0,SND_ASYNC);
ñîáûòèå OnPaint:
procedure TSpeedGL.FormPaint(Sender: TObject);
var
ps:TPaintStruct;
BeginPaint(dc,ps);
if Selected_Menu_item='' then
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;
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);//Çàãðóçêà íàäïèñåé â ìåíþ
if (Selected_Menu_item<>'Car')and(RemoveMeny=0.0) then begin
Angel:=Angel+1;
if Angel=360 then Angel:=0;
glCallList(8);//Çàãðóçêà êîëåñà
glScalef(0.5,0.66,0.5);
glTranslatef(LeftTiresMeny,TopTiresMeny,0.0);
glRotatef(Angel,0.0,0.0,1.0);
glCallList(Tires);
glScalef(0.5,0.66,1.0);
glTranslatef(RightTiresMeny,TopTiresMeny,0.0);
if Selected_Menu_item='Start' then //Íàæàòà êëàâèøà Start èãðà íà÷àëàñü
begin //Start
// glClear(GL_COLOR_BUFFER_BIT); //ìåäëåííîå ñòèðàíèå
glTranslatef(0.0,Y_Kord,0.0);
glCallList(WayDesert_1);
glTranslatef(0.0,Y_Kord+1.99,0.0);
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
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;
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
glTranslatef(X_KordFuel,Y_KordFuel,0.0);
if FuelOrNitro then glCallList(ItemFuelList) else glCallList(ItemNitroList);
end//KordObject
else
FuelGoToWay:=False;
PlaySound('Sound\Get_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;
//////////////////////////////////////////////////////
{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
NumbrCar:=random(9)+1;
EnymiGoToWay:=true;
NextKmEnymy:=NextKmEnymy+0.1;
Y_Enymi:=1.2;
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
glTranslatef(X_Enymi,Y_Enymi,0.0);
glCallList(EnymiCars[NumbrCar]);
EnymiGoToWay:=False;
GasDeley:=1;
Gas:=false;
Speed:=-0.001;
PlaySound('Sound\Denger_Sound.wav',0,SND_ASYNC);
if CountFuel>0 then CountFuel:=CountFuel-1;
if CountFuel<0 then CountFuel:=0;
//ðèñîâàíèå ìàøèíû
if ChooseCar='ShotWarKiller' then begin
glTranslatef(X_KordCar,Y_KordCar,0.0);
glCallList(WarKiller);
if ChooseCar='ShotFlash' then begin
glCallList(Flash);
if ChooseCar='ShotGembic' then begin
glCallList(Gembic);
if ChooseCar='ShotGlass' then begin
glCallList(Glass);
//Ïðîèãðûø è âûèãðûøü â èãðå
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
glTranslatef(0.0,-0.4,0.0);
glCallList(PressEsc);
glPopMatrix
//Èãðîâîå ìåíþ
glTranslatef(0.7,0.58,0.0);
glScalef(1.5,1.5,1.0);
glCallList(GameMenu);
//Íàäïèñè íà ìåíþ
glTranslatef(0.64,0.68,1.0);
glCallList(FontList);
//
if Pause then glCallList(PauseToGame);
end; //Start
if RemoveMeny<=-0.5 then RemoveMeny:=-0.5 else RemoveMeny:=RemoveMeny-0.018;
if RemoveMeny<=-0.5 then
//Ìåíþ
glTranslatef(0.5,0.2,0.0);
glCallList(SubMenuInCar);
DeleyButtonInCarMeny;
//Âûáèðàåòñÿ ìàøèíà
case CarMenuItem of
1:begin
//ShotWarKiller
glTranslatef(0.5,0.12,0.0);
glCallList(ShotWarKiller);
ChooseCar:='ShotWarKiller';
CarXPogresh:=XPogreshWarKiller;
CarYPogresh:=YPogreshWarKiller;
2:begin
//ShotFlash
glCallList(ShotFlash);
ChooseCar:='ShotFlash';
CarXPogresh:=XPogreshFlash;
CarYPogresh:=YPogreshFlash;
3:begin
//ShotGembic
glCallList(ShotGembic);
ChooseCar:='ShotGembic';
4:begin
//ShotGlass
glCallList(ShotGlass);
ChooseCar:='ShotGlass';
end;//Case
end;//RemoveMeny
if Selected_Menu_item='Actors' then //Íàæàòà êëàâèøà Actors
glCallList(Actor);
if Selected_Menu_item='Exit' then //Íàæàòà êëàâèøà Exit
SwapBuffers(DC);
EndPaint(DC,ps);
{if Selected_Menu_item='Start'then begin
Canvas.Brush.Color:=clWhite;
Canvas.TextOut(500,40,'Áåíçèí: '+FloatToStrF(CountFuel,ffNumber,6,3)+'ë');
Canvas.TextOut(500,55,'Íèòðî: '+FloatToStrF(CountNitro,ffNumber,6,3)+'êã/ñì');
Canvas.TextOut(500,70,'Ê.ìåòðû: '+FloatToStrF(CountKM,ffNumber,6,3)+'êì');
end;}
Caption:=StatisticCaption;
//Ïîääåðæêà àïïàðàòíîãî óñêîðèòåëÿ è âåðñèÿ OpenGL êëàâèøà 'a'
if PressedKey[65]=true then
Caption:='OpenGL: '+
StrPas(glGetString(GL_VERSION))+
' '+
StrPas(glGetString(GL_VENDOR))+
StrPas(glGetString(GL_RENDERER));
if PressedKey[70]=true then //Ïîêàçûâàòü Fps -- êëàâèøà 'f'
newCount:=GetTickCount;
Inc(frameCount);
If abs(newCount - lastCount) > 1000 then
StatisticCaption:='FPS: '+FloatToStr(frameCount);
lastCount := newCount;
frameCount := 0;
if PressedKey[75]=true then
StatisticCaption:='X='+FloatToStrF(xpos,ffNumber,4,3)+
' '+'Y='+FloatToStrF(ypos,ffNumber,4,3);
if (PressedKey[70]=false)and
(PressedKey[75]=false)and
(PressedKey[65]=false)then StatisticCaption:='SpeedLine';
procedure TSpeedGL.FormDestroy(Sender: TObject);
//glDeleteLists(1,1);
timeKillEvent(uTimerID);
wglMakeCurrent (0, 0);
wglDeleteContext (hrc);
ReleaseDC (Handle, DC);
procedure TSpeedGL.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
//////////////////////////////////////////////
xpos:=2*X/ClientWidth-1;
ypos:=2*(ClientHeight-Y)/ClientHeight-1;
if Selected_Menu_item='' then begin //Selected_Menu_item
if (xpos>-0.3)and(ypos>0.4)and
(xpos<0.3)and(ypos>0.4)and
(xpos<0.3)and(ypos<0.6)and
(xpos>-0.3)and(ypos<0.6)then begin
if Menu_item<>1 then
PlaySound('Sound\Select_MainMenu.wav',0,SND_ASYNC);
Menu_item:=1;
if (xpos>-0.3)and(ypos>0.15)and
(xpos<0.3)and(ypos>0.15)and
(xpos<0.3)and(ypos<0.35)and
(xpos>-0.3)and(ypos<0.35)then begin
if Menu_item<>2 then
Menu_item:=2;
if (xpos>-0.3)and(ypos>-0.1)and
(xpos<0.3)and(ypos>-0.1)and
(xpos<0.3)and(ypos<0.1)and
(xpos>-0.3)and(ypos<0.1)then begin
if Menu_item<>3 then
Menu_item:=3;
if (xpos>-0.3)and(ypos>-0.5)and
(xpos<0.3)and(ypos>-0.5)and
(xpos<0.3)and(ypos<-0.3)and
(xpos>-0.3)and(ypos<-0.3)then begin
if Menu_item<>4 then
Menu_item:=4;
{if Selected_Menu_item='Start' then
if
end; //Selected_Menu_item
Ñòðàíèöû: 1, 2, 3, 4, 5