#include <graphics.h> /* graph.h o graphics.h */
#include <conio.h>
#include <stdlib.h>
#include <stdio.h>
#include "alloc.h"
#include <conio.h>
#include <ctype.h>
#include <dos.h>
char *buffer,*buffer1;
int tecla,tecla1,y4,y5;
int i,y,x,direccionx,direcciony,x1,y1;
size_t t_imagen1;
size_t t_imagen;
int pi,pd;
void main(void)
{
int gdriver,gmode;
detectgraph(&gdriver,&gmode);
initgraph(&gdriver,&gmode,"c:\\TC\\bgi");
setcolor(DARKGRAY); /*DARKGRAY LIGHTGRAY*/
rectangle(20, 20, 30,120);
setfillstyle(SOLID_FILL,DARKGRAY);
floodfill(25,25,DARKGRAY);
setcolor(WHITE);
rectangle(20,20,30,120);
t_imagen=(size_t)imagesize(19,19,31,121);
buffer=(char *)malloc(t_imagen);
if (buffer == (char *)NULL )
exit(1);
getimage(19,19,31,121,buffer);
setcolor(BLUE);
circle(100, 100, 20);
setfillstyle(SOLID_FILL,BLUE);
floodfill(105,105,BLUE);
for (i=1;i<50;i++)
{
putpixel(105+random(5),85+random(6),WHITE);
}
t_imagen1=(size_t)imagesize(77,77,122,122);
buffer1=(char *)malloc(t_imagen1);
if (buffer1 == (char *)NULL )
exit(1);
getimage(77,77,122,122,buffer1);
randomize();
x=random(560);
y=random(400);
direccionx=random(1)+1;
direcciony=random(1)+1;
x1 = getmaxx() / 2;
y1 = 450;
pi=pd=0;
cleardevice();
rectangle(0,0,630,455);
setcolor(WHITE);
settextjustify(CENTER_TEXT, CENTER_TEXT);
outtextxy(x1, 10, "Pin-Pon Game CopyRigth IVAN JONATHAN 2001");
y4=163; /* barra izquierda */
y5=163; /* barra derecha */
putimage(12,y4,buffer,COPY_PUT);
putimage(610,y5,buffer,COPY_PUT);
do {
do {
if (pi == pd-3)
{
closegraph();
exit(0);
}
if (pd == pi-3)
{
closegraph();
exit(0);
}
putimage(x,y,buffer1,COPY_PUT);
if ((direccionx == 1) && (direcciony == 1))
{
x++;
y++;
if (x > 560)
{
if ((y<(y5-20)) || (y>(y5+100)))
{
pi++;
gotoxy(20,25);
printf("Player1: %d Player2: %d",pi,pd);
gotoxy(20,24);
printf("Lost player rigth. Press any key to continue...");
getch();
gotoxy(19,24);
printf(" ");
gotoxy(20,25);
printf(" ");
direccionx=2;
}
else
{
direccionx=2;
sound(220);
delay(10);
nosound();
}
}
if (y > 400)
{
direcciony=2;
sound(220);
delay(10);
nosound();
}
}
if ((direccionx == 2) && (direcciony == 1))
{
x--;
y++;
if (x <= 30)
{
if ((y<(y4-20)) || (y>(y4+100)))
{
pd++;
gotoxy(20,25);
printf("Player1: %d Player2: %d",pi,pd);
gotoxy(20,24);
printf("Lost player left. Press any key to continue...");
getch();
gotoxy(19,24);
printf(" ");
gotoxy(20,25);
printf(" ");
direccionx=1;
}
else
{
direccionx=1;
sound(220);
delay(10);
nosound();
}
}
if (y > 400)
{
direcciony=2;
sound(220);
delay(10);
nosound();
}
}
if ((direccionx == 1) && (direcciony == 2))
{
y--;
x++;
if (x > 560)
{
if ((y<(y5-20)) || (y>(y5+100)))
{
pi++;
gotoxy(20,25);
printf("Player1: %d Player2: %d",pi,pd);
gotoxy(20,24);
printf("Lost player Rigth. Press any key to continue...");
getch();
gotoxy(19,24);
printf(" ");
gotoxy(20,25);
printf(" ");
direccionx=2;
}
else
{
direccionx=2;
sound(220);
delay(10);
nosound();
}
}
if (y <= 15)
{
direcciony=1;
sound(220);
delay(10);
nosound();
}
}
if ((direccionx == 2) && (direcciony == 2))
{
x--;
y--;
if (x <= 30)
{
if ((y<(y4-20)) || (y>(y4+100)))
{
pd++;
gotoxy(20,25);
printf("Player1: %d Player2: %d",pi,pd);
gotoxy(20,24);
printf("Lost player left. Press any key to continue...");
getch();
gotoxy(19,24);
printf(" ");
gotoxy(20,25);
printf(" ");
direccionx=1;
}
else
{
direccionx=1;
sound(220);
delay(10);
nosound();
}
}
if (y <= 15)
{
direcciony=1;
sound(220);
delay(10);
nosound();
}
}
delay(30);
} while (!kbhit());
tecla=getche();
if ((toascii(tecla) == 101) || (toascii(tecla) == 69)) /*e = 101, E=69*/
{
y4--;
y4=y4-2;
if ( y4 == 4)
{
y4++;
y4=y4+2;
}
putimage(12,y4,buffer,COPY_PUT);
setcolor(BLACK);
line(10,y4+105-1,32,y4+105-1);
line(10,y4+105-2,32,y4+105-2);
line(10,y4+105-3,32,y4+105-3);
}
if ((toascii(tecla) == 120) || (toascii(tecla) == 88)) /*x = 120 ,
X=88*/
{
setcolor(BLACK);
line(10,y4+1,32,y4+1);
line(10,y4+2,32,y4+2);
y4++;
y4=y4+2;
if (y4 == 346)
{
y4--;
y4=y4-2;
}
putimage(12,y4,buffer,COPY_PUT);
}
if (toascii(tecla) == 0)
{
tecla1=getche();
if (toascii(tecla1) == 72) /*arriba=0,72*/
{
y5--;
y5=y5-2;
if ( y5 == 4)
{
y5++;
y5=y5+2;
}
putimage(610,y5,buffer,COPY_PUT);
setcolor(BLACK);
line(605,y5+105-1,623,y5+105-1);
line(605,y5+105-2,623,y5+105-2);
line(605,y5+105-3,623,y5+105-3);
}
if (toascii(tecla1) == 80) /*abajo=0,80*/
{
setcolor(BLACK);
line(605,y5+1,623,y5+1);
line(605,y5+2,623,y5+2);
y5++;
y5=y5+2;
if (y5 == 346)
{
y5--;
y5=y5-2;
}
putimage(610,y5,buffer,COPY_PUT);
}
}
} while (toascii(tecla) != 01);
free(buffer);
closegraph();
}
Comentarios sobre la versión: Versión 1 (3)
http://mundovb.net/mundoc/pin-pon.htm
espero que tengas criterio y te disculpes por robar un codigo, y no creo que sea el unico cuantos no has deber robado y puesto a tu nombre.
Atte. Victor Hugo De la O Martinez
Y pues una disculpa por el mal entendido que algunas personas X tratan de hacerlo explicito.
DAKGRAY undeclared (first use this funtion)
setcolor undeclared (first use this funtion)....
y mucha mas si me pueden decir que puedo hacer envienme un correo por favor: [email protected]