Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- Form1.DoubleBuffered:=true;
- end;
- procedure SetOncomingCarSpeed(Meteor:TImage);
- var
- Speed: Integer;
- Begin
- Speed := RandomRange(3, 9);
- Meteor.Top:=Meteor.Top+Speed
- End;
- procedure MeteorSpawn(Meteor:TImage; LeftPosition: Integer);
- Begin
- if (Meteor.Top>form1.Height) then
- begin
- Meteor.Top:=-70;
- Meteor.Left:=LeftPosition;
- end;
- End;
- procedure CollisionDetection(OncomingCar, Car: TImage; Timer: TTimer);
- begin
- if ((OncomingCar.top+OncomingCar.Height>Car.top) and(OncomingCar.top<Car.top+Car.Height) and(OncomingCar.Left+OncomingCar.Width>Car.left) and (OncomingCar.left<Car.Left+Car.Width)) then
- begin
- //timer.Enabled:=false;
- { fire.Picture.LoadFromFile('fire.png');
- fire.Top:=Rocket.top-32;
- fire.Left:=Rocket.Left;
- button1.Visible:=true;
- sndPlaySound('sounds\explosion.wav',SND_NODEFAULT Or SND_ASYNC); }
- end;
- end;
- procedure PlayerControl(Car: TImage);
- begin
- if GetaSyncKeyState($25)<>0 then //влево
- if not(Car.Left<220) then
- Car.Left:=Car.Left-7;
- if GetaSyncKeyState($27)<>0 then //вправо
- if not(Car.Left>460) then
- Car.Left:=Car.Left+7;
- if GetaSyncKeyState($26)<>0 then //вверх
- if (Car.Top>50) then
- Car.Top:=Car.Top-7;
- if GetaSyncKeyState($28)<>0 then //вниз
- if (Car.Top<530) then
- Car.Top:=Car.Top+7;
- end;
- procedure InfiniteGeneration(Road, BufRoad: TImage);
- var
- Speed: Integer;
- Begin
- Speed := 5;
- BufRoad.Top:= Road.Top-Form1.Height+35;
- Road.Top := Road.Top + Speed;
- BufRoad.Top := BufRoad.Top + Speed;
- if Road.Top > Form1.Height-40 then
- Road.Top := 0;
- End;
- procedure TForm1.TimerTimer(Sender: TObject);
- begin
- BufRoad.SendToBack;
- InfiniteGeneration(Road, BufRoad);
- SetOncomingCarSpeed(OncomingCar1);
- SetOncomingCarSpeed(OncomingCar2);
- SetOncomingCarSpeed(OncomingCar3);
- MeteorSpawn(OncomingCar1, 220);
- MeteorSpawn(OncomingCar2, 340);
- MeteorSpawn(OncomingCar3, 460);
- PlayerControl(Car);
- CollisionDetection(OncomingCar1, Car, Timer);
- CollisionDetection(OncomingCar2, Car, Timer);
- CollisionDetection(OncomingCar3, Car, Timer);
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement