Thema: Delphi PingPong

Einzelnen Beitrag anzeigen

Benutzerbild von Khabarakh
Khabarakh

Registriert seit: 18. Aug 2004
Ort: Brackenheim VS08 Pro
2.876 Beiträge
 
#11

Re: PingPong

  Alt 6. Mai 2005, 09:43
Nagut, aber bei so etwas verliert man doch den Überblick :
Delphi-Quellcode:
//Ballkollision
if (Abs(ball.Left - enemy.left) <= 5) and (Abs(ball.Top - enemy.Top) <= 5) then xspeed:= -xspeed;
if (ball.top > player1.top -1-toleranz) and (ball.top < player1.top + player1.height +1+toleranz) and (ball.left = player1.left+player1.width) then xspeed := -xspeed;

//Ballkollisions Ton
if (Abs(ball.Left - enemy.left) <= 5) and (Abs(ball.Top - enemy.Top) <= 5) then mp1;
if (ball.top > player1.top -1-toleranz) and (ball.top < player1.top + player1.height +1+toleranz) and (ball.left = player1.left+player1.width) then mp1;
Wie wäre es mit
Delphi-Quellcode:
if (Abs(ball.Left - enemy.left) <= 5) and (Abs(ball.Top - enemy.Top) <= 5)
  or (ball.top > player1.top - 1 - toleranz) and (ball.top < player1.top + player1.height + 1 + toleranz) and (ball.left = player1.left + player1.width) then
begin
  xspeed := -xspeed;
  mp1;
end;
?

Und was ist überhaupt "enemy" und "ball" ? Doch hoffentlich keine TImages ?
Sebastian
Moderator in der EE
  Mit Zitat antworten Zitat