Creo que te falta tener un campo que te diga la dirección en que se está moviendo la pelota.
En tal caso, el incrementeo/decremento de tu posición dependerá de la dirección:
Algo así:
Código Delphi
[-]
col := 40;
lin := 12;
direccion := 5
k := 0;
repeat
case direccion of
1 :
begin
dec(col);
dec(lin);
end
2 :
begin
dec(lin);
end
3 :
begin
inc(col);
dec(lin);
end
4 :
begin
dec(col);
end
5 :
begin
dec(col);
inc(lin);
end
6 :
begin
inc(lin);
end
7 :
begin
inc(col);
inc(lin);
end
8 :
begin
dec(col);
end
end
if (direccion >= 1) and (direccion <= 3)
if (lin = 0) then
begin
direccion := direccion + 4; line := 1;
end;
if (direccion >= 5) and (direccion <= 7)
if (lin > 25) then
begin
direccion := direccion - 4; lin := 24;
end;
if (direccion = 1) or (direccion = 4) or (direccion = 5)
if (col = 0) then
begin
case direccion of
1 : direccion := 3;
4 : direccion := 8;
5 : direccion := 7;
end;
col := 0;
end;
if (direccion = 3) or (direccion = 8) or (direccion = 7)
if (col = 81) then
begin
case direccion of
3 : direccion := 1;
8 : direccion := 4;
7 : direccion := 5;
end;
col := 80;
end;
clrscr;
GotoXY(col,lin);
write('O')
until k = 300;