Juego pong
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.
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 personas con únicamente conocimiento básico del lenguaje, no de programación.
Otro punto importante: Si vas a sugerir un segmento de código en algún lenguaje debes hacerlo así:
- Si es lenguaje C [c]Código en C[/c]
- Si es lenguaje Pascal [pascal]Aquí dentro el código de Pascal[/pascal].
De esta manera el código coloreas el código.
Otro punto importante para muchos que sienten que se les ignora: Todos los comentarios los reviso y en su debido momento los apruebo, pero ojo con el con lo siguiente:Me reservo el derecho de alterar, publicar o no los comentarios as´ como cambiar mis condiciones en el momento que así lo requiera.
¿estas de acuerdo? entonces adelante que ya te he quitado bastante tiempo leyendo esta basura de advertencias :)