Pascal/Turbo Pascal - ayuda con el juego de ping-pong,no tengo idea de como seguir

 
Vista:

ayuda con el juego de ping-pong,no tengo idea de como seguir

Publicado por yearim ortega (1 intervención) el 28/03/2018 23:58:06
hola, tengo un gran problema con programar el juego de ping-pong, es bastante basico , solo necesito hacer las barras y lograr que se muevan por que ya tengo la pelota.El problema es que no se como hacerlo, el profesor no nos explico nada y solo nos puso a hacerlo :c, pasar mi materia depende de este programa,ojala puedan ayudarme.
MUCHAS GRACIAS POR SU TIEMPO! C:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
program ping;
uses CRT;
var  x,y,i,xi,yi:integer;
 
Const
     KEY_UP = 18432;
     KEY_DOWN = 20480;
     KEY_EXIT = 27;
     CHAR_ON = ('[');
 
Var
   Key :Word;
   b, a :Byte;
 procedure pong;
Function wReadKey :Word;
         Var
            Key :Word;
         Begin
              Key := Ord(ReadKey);
              If (Key=0) then Key := Ord(ReadKey)*256;
              wReadKey := Key;
         End;
 
Begin
     a := 1;
     b := 1;
     ClrScr;
     Repeat
           GotoXY(a, b);
           Write(CHAR_ON);
           Repeat
                 Key := wReadKey;
           Until (Key=KEY_UP) or (Key=KEY_DOWN)  or (Key=KEY_EXIT);
           GotoXY(a,b);
           Write(' ');
           Case Key of
                KEY_UP   : Dec(b);
                KEY_DOWN : Inc(b);
           End;
           If (a=0) then a:= 80;
           If (a=81) then a := 1;
           If (b=0) then b := 23;
           If (b=24) then b := 1;
              Until (Key=KEY_EXIT);
           end;
procedure pelota;
 
begin
  x:=1;
  y:=1;
  xi:=1;
  yi:=1;
    for i:=1 to 200 do
    begin
    pong;
 
    begin
      gotoxy(x,y);
      writeln('*');
      delay(100);
      gotoxy(x,y);
      writeln('          ');
      x:=x+xi;
      y:=y+yi;
      if (y=20) then
        begin
          yi:= -1;
        end;
          if y=1 then
            begin
              yi:=1;
            end;
              if (x=80) then
        begin
          xi:=-1;
        end;
          if (x=1) then
            begin
              xi:=1;
            end;
            end;
 
 
end;
end;
begin
pelota;
end.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder