Hi,
OpenGl ist dfür viel zu aufwendig, wenn du hiermit etwas anfangen kannst:
Delphi-Quellcode:
var
Form1: TForm1;
xspeed: Integer=1;
yspeed: Integer=1;
bdirection: byte;
{ ... }
procedure TForm1.ki;
var schritt: integer;
begin
schritt := 2;
if ball.Top > enemy.Top then enemy.Top := enemy.Top+schritt;
if ball.Top < enemy.Top then enemy.Top := enemy.Top-schritt;
end;
procedure TForm1.go_p1;
begin
showmessage(Edit1.text+' '+'gewinnt');
end;
procedure TForm1.go_p2;
begin
showmessage(Edit2.text+' '+'gewinnt');
end;
procedure TForm1.tTimer(Sender: TObject);
var toleranz : integer; // umgebung um den balken herum in pixeln
begin
toleranz := ball.Width div 2;
//KI-Aktivierung
ki;
//Vereinbarungen
ball.left := ball.Left + xspeed;
ball.Top := ball.Top + yspeed;
//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;
//Kollisionserkennung
if ball.Left<0 then
begin
t.Enabled:= false;
ball.Visible:= false;
go_p2;
end;
if ball.Left>345 then
begin
t.Enabled:= false;
ball.Visible:= false;
go_p1;
end;
if ball.Left<0 then xspeed := -xspeed;
if ball.Top<0 then yspeed := -yspeed;
if ball.Left>346 then xspeed := -xspeed;
if ball.Top>346 then yspeed := -yspeed;
end;
Such dir was du brauchst einfach raus.
Du musst aufpassen, dass width und height angepasst [schritt := 2] ist.