Hi
ich habe mal ne frage
wie schaff ich das bei dem dem Spiel pong das der einfallswinkel nicht gleich ausfallswinkel ist?
Vll. mit random nur wie?
ein teil meinses Delphi Quelltextextes..
SCHON MAL DANKE!!!
Delphi-Quellcode:
procedure TForm1.Timer1Timer(Sender: TObject);
begin
(...)
if (Ball.Left < 0) then begin
scorep2 := scorep2 + 1;
Ball.Left := 320 ;
xspeed := 1;
yspeed := 2;
exit;
end;
if (Ball.Left > 800) then begin
scorep1 := scorep1 + 1;
Ball.Left := 320 ;
xspeed := -1;
yspeed := 2;
exit;
end;
if yspeed = 0 then yspeed := 2;
if xspeed = 0 then xspeed := 5;
Ball.Top := Ball.Top + yspeed;
Ball.Left := Ball.Left + xspeed;
if (Ball.Top > 500)
or (Ball.Top <= 0)
then yspeed := -yspeed;
if (Ball.Left < shape1.Left + 22)
and (Ball.Top > shape1.Top)
and (Ball.Top < shape1.Top + 90)
then xspeed := + speed;
if (Ball.Left > shape2.Left - 22)
and (Ball.Top > shape2.Top)
and (Ball.Top < shape2.Top + 90)
then xspeed := - speed;
if (shape2.Top + 28 > Ball.Top)
and (shape2.Top > 0)
then shape2.Top := shape2.Top - dif;
if (shape2.Top + 28 < Ball.Top)
and (shape2.Top < 444)
then shape2.Top := shape2.Top + dif;
(...)
end;