Juego pong

¿Has encontrado un error? ¿Tienes la solución? Deja tu correción ;-)

Antes de comentar: Gran parte de los ejercicios propuestos no tienen librerías debido a que Wordpress las eliminó al verlas como etiquetas HTML. Si sabes/tienes/conoces las librerías que hacen falta, déjalo en los comentarios. Y lo mas importante: Todos los ejemplos fueron realizados por estudiante con únicamente conocimiento básico del lenguaje, no de programación.

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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
program pong;
   
   uses
      crt,
      graph;   
   var
      nombre,lives,puntos: string;
      c:char;
      gd, gm, radio,dx1,dx2,dy1,dy2:integer;      verb,horb,ver,hor,Sup,Izq,k,x1,x2,y1,y2:integer;
      b1,b2,v1,v2:integer;
      vidas:integer;
      a:char;
      nivel,del:integer;   
   procedure inicializa;
      begin
         x1:=10;
         x2:=20;         y1:=320;
         y2:=380;
         ver:=radio;
         hor:=radio;
         ver:=220;         hor:=250;
         sup:=random(2);
         izq:=random(2);
      end;
      Procedure score;
      begin
         str(vidas,lives);
         outtextxy(5,5,'Vidas:');
         outtextxy(70,5,lives);      end;
   
   procedure marco;
      begin
         setbkcolor(blue);         setlinestyle(0,0,3);
         setcolor(white);
         line(0,400,630,400);
         line(0,0,630,0);
         line(0,20,500,20);         line(500,0,500,400);
         line(630,0,630,400);
      end;
   
   procedure letrero;      begin
         setcolor(9);
         outtextxy(50,220,'ÛÛÛÛÛÛÛÛ± ');
         outtextxy(50,225,'ÛÛ±   ÛÛ± ');
         outtextxy(50,230,'ÛÛ±   ÛÛ± ');         outtextxy(50,235,'ÛÛÛÛÛÛÛÛ± ');
         outtextxy(50,240,'ÛÛ±       ');
         outtextxy(50,245,'ÛÛ±       ');
         outtextxy(50,250,'ÛÛ±       ');
                  outtextxy(200,220,'ÛÛÛÛÛÛÛÛ± ');
         outtextxy(200,225,'ÛÛ±   ÛÛ±  ');
         outtextxy(200,230,'ÛÛ±   ÛÛ±  ');
         outtextxy(200,235,'ÛÛ±   ÛÛ±   ');
         outtextxy(200,240,'ÛÛ±   ÛÛ±   ');         outtextxy(200,245,'ÛÛ±   ÛÛ±   ');
         outtextxy(200,250,'ÛÛÛÛÛÛÛÛ± ');
         
         outtextxy(350,220,'ÛÛ±   ÛÛ± ');
         outtextxy(350,225,'ÛÛÛ±  Ãƒâ€ºÃƒâ€ºÃ‚± ');         outtextxy(350,230,'ÛÛ±Û± ÛÛ± ');
         outtextxy(350,235,'ÛÛ± Û±ÛÛ± ');
         outtextxy(350,240,'ÛÛ±  Ãƒâ€ºÃƒâ€ºÃƒâ€ºÃ‚± ');
         outtextxy(350,245,'ÛÛ±   ÛÛ± ');
         outtextxy(350,250,'ÛÛ±   ÛÛ± ');         
         outtextxy(500,220,'ÛÛÛÛÛÛÛÛ± ');
         outtextxy(500,225,'ÛÛ±       ');
         outtextxy(500,230,'ÛÛ±       ');
         outtextxy(500,235,'ÛÛ±ÛÛÛÛÛ± ');         outtextxy(500,240,'ÛÛ±   ÛÛ± ');
         outtextxy(500,245,'ÛÛ±   ÛÛ± ');
         outtextxy(500,250,'ÛÛÛÛÛÛÛÛ± ');
         outtextxy(200,300,'PRESIONE UNA TECLA PARA INICIAR');
         readkey;         cleardevice;
      end;
   
   BEGIN
      gd:=detect;      randomize;
      initgraph(gd,gm,'C:TPBGI');
      radio:=5;
      inicializa;
      vidas:=5;      nivel:=0;
      del:=5;
      letrero;
      dx1:=470;
      dx2:=480;      dy1:=200;
      dy2:=260;
      repeat
         textbackground(green);
         marco;         score;
         setfillstyle(1,blue);
         bar(x1,b1,x2,b2);
         setfillstyle(1,white);
         bar(x1,y1,x2,y2);         repeat
            marco;
            str(nivel,puntos);
            outtextxy(530,50,'salir: Esc');
            outtextxy(410,5,'Puntos:');            outtextxy(538,150,'Pause: P');
            outtextxy(475,5,puntos);
            if sup=0 then
               begin
                  verb:=ver;                  ver:=ver+2;
               end;
            if sup=1 then
               begin
                  verb:=ver;                  ver:=ver-2;
               end;
            if (ver>=395) then sup:=1;
            if (ver<=25) then sup:=0;
            if izq=0 then               begin
                  horb:=hor;
                  hor:=hor+2;
               end;
            if izq=1 then               begin
                  horb:=hor;
                  hor:=hor-2;
               end;
            if (hor<=x2+6) and (ver>y1) and (ver<y2) then               begin
                  horb:=hor;
                  hor:=hor+2;
                  izq:=0;
                  nivel:=nivel+5;                  cleardevice;
                  setfillstyle(1,white);
                  bar(x1,y1,x2,y2);
                  score;
               end;            if (hor<=x2+3) and (ver>y2) and (ver<y2+10) then
               begin
                  sup:=0;
                  izq:=0;
                  nivel:=nivel+5;                  cleardevice;
                  setfillstyle(1,white);
                  bar(x1,y1,x2,y2);
                  score;
               end;            if (hor<=x2+3) and (ver<y1) and (ver>y1-10) then
               begin
                  sup:=1;
                  izq:=0;
                  nivel:=nivel+5;                  cleardevice;
                  setfillstyle(1,white);
                  bar(x1,y1,x2,y2);
                  score;
               end;            if (hor<=5) or (hor=6) then
               begin
                  vidas:=vidas-1;
                  cleardevice;
                  inicializa;                  score;
               end;
            if (hor>=495) or (hor=496) then izq:=1;
            marco;
            setlinestyle(1,0,0);            setcolor(blue);
            circle(horb,verb,radio);
            setcolor(white);
            circle(hor,ver,radio);
            delay(del);            if (nivel<=20) then
               begin
                  if nivel=20 then
                  outtextxy(220,200,'LEVEL 2');
                  del:=3;               end;
            if (nivel>=45) and (nivel<=69)then
               begin;
                  if nivel=45 then
                  outtextxy(220,200,'LEVEL 3');                  del:=2;
               end;
            if (nivel>=70) and (nivel<=99) then
               begin;
                  del:=1;                  if nivel=70 then
                  outtextxy(220,200,'LEVEL 4');
               end;
            if (nivel>=100) then
               begin                  if nivel=100 then
                     begin
                        outtextxy(220,200,'LEVEL 5');
                     end;
                  setcolor(red);                  setlinestyle(0,0,3);
                  line(503,180,503,280);
                  line(503,180,627,180);
                  line(627,180,627,280);
                  line(503,280,627,280);                  setcolor(red);
                  outtextxy(505,195,' Para la NUEVA');
                  outtextxy(505,210,' barra presione');
                  setcolor(7);
                  outtextxy(520,230,'5 = arriba');                  outtextxy(520,250,'2 = abajo');
                  setcolor(4);
                  setlinestyle(1,0,2);
                  line(485,21,485,400);
                  setfillstyle(1,blue);                  bar(dx1,v1,dx2,v2);
                  setfillstyle(1,red);
                  bar(dx1,dy1,dx2,dy2);
                  del:=0;
                  if (hor>=dx1-5) and (ver>dy1) and (ver<dy2) then                     begin
                        izq:=1;
                        nivel:=nivel+5;
                     end;
                  if (hor>=dx1+3) and (ver>dy2) and (ver<dy2+10) then                     begin
                        sup:=0;
                        izq:=1;
                        nivel:=nivel+5;
                     end;                  if (hor>=dx1+3) and (ver<dy1) and (ver>dy1-10) then
                     begin
                        sup:=1;
                        izq:=1;
                        nivel:=nivel+5;                     end;
                  if hor>=480 then
                     begin
                        vidas:=vidas-1;
                        inicializa;                        score;
                        cleardevice;
                        setfillstyle(1,white);
                        bar(x1,y1,x2,y2);
                     end;               end;
         until keypressed or (vidas=0);
         marco;
         c:=readkey;
         if (c=#72)  then            if y1>22 then
               begin
                  b1:=y1;
                  b2:=y2;
                  y1:=y1-10;                  y2:=y2-10;
                  marco;
               end;
         if (c=#80) then
            if y1<335 then               begin
                  b1:=y1;
                  b2:=y2;
                  y1:=y1+10;
                  y2:=y2+10;                  marco;
               end;
         if (c=#53) then
            if dy1>22 then
               begin                  v1:=dy1;
                  v2:=dy2;
                  dy1:=dy1-10;
                  dy2:=dy2-10;
                  marco;               end;
         if (c=#50) then
            if dy2<395 then
               begin
                  v1:=dy1;                  v2:=dy2;
                  dy1:=dy1+10;
                  dy2:=dy2+10;
                  marco;
               end;         if (c='p') then
            begin
               outtextxy(145,200,'~ ~ ~ ~ ~ P A U S E ~ ~ ~ ~ ~');
               readkey;
               cleardevice;            end;
      until (vidas=0) or (c=#27);
      cleardevice;
      outtextxy(210,260,'COME FRUTAS Y VERDURAS');
      outtextxy(100,240,'PRACTICA MAS PARA SER EL MEJOR JUGADOR DE PONG');      outtextxy(160,220,'GRACIAS POR JUGAR ESTE FABULOSO JUEGO');
      outtextxy(120,170,'########## P e r d i s t e T O N T O ##########');
      outtextxy(150,410,'PROYECTO REALIZADO POR ALUMNOS DE LA');
      outtextxy(120,428,'UNIVERSIDAD DE COLIMA   FACULTAD DE TELEMATICA');
      outtextxy(190,445,'ESTUDIA, LUCHA Y TRABAJA');      outtextxy(450,465,'¦ fumar causa cancer ¦');
      readkey;
   end.

12 comentarios en "Juego pong"

rage

hey mejro deverias subirlo como archivo .rar o .zip asi es mas facil, solo se abre en TP y ya no copiar todo q es un colmo... gracias por el programa XD

Cairo

Hola. me estoy iniciando en esto de la programacion y aunque quisiera entender un poco de lo que has peusto se me hace dificil estoy buscando este juego pero en diagrama de flujo se que esto es muy similar pero me cuesta entenderlo por que no esta detallado, si te pudieras molestar en ayudarme te lo agradeceria.

Punto importante: Si vas a sugerir un segmento de código en algún lenguaje debes hacerlo así:

  • Si es lenguaje C <code lang="c">Código en C</code>
  • Si es lenguaje Pascal <code lang="pascal">Aquí dentro el código de Pascal</code>.

De esta manera el código coloreas el código.

Deja un comentario

Suscribirse a los comentarios.