Visual Studio 2008 を使い始めたばかりで、以前はコードブロックを使用していましたが、Visual Studio に関するすべてが混乱しています。
// Emilie Sutterlin による PONG、10/10/97 // 説明: このプログラムはゲームのポンです。//================================================ =================== #include #include #include #include #include #include #include #include //==========グローバルと定数======================== const MAX = 10; int lprow=2、rprow=2、col=2、colinc=2、rowinc=1、row=1、oldrow、oldcol、scorr=0、scorl=0;
//==========Prototypes===================================
void ball_bounce ();
void paddle_pong ();
//======================================================
int main (void)
{
clrscr (); fflush(stdin); int num;
textbackground (BLACK);
textcolor (WH|TE); clrscr(); _setcursortype(_NOCURSOR);
//|NTRODUCT|ON
cout<<"WELCOME TO PONG"<<endl<<"This is a two person game."
<<endl<<"The object is to gain points by having your opponent miss hitting the ball with the paddle."
<<endl<<"The game ends when a player reaches 20 points."
<<endl<<"You can stop the game early anytime by pressing either the Enter or Escape key."
<<endl<<"The paddle on the left can be controlled with the arrow up and down keys."
<<endl<<"The paddle on the right can be controlled using the page up and down keys."
<<endl<<"Press any key to begin";
getch(); clrscr();
//CREATE PADDLES
gotoxy (1,2); cout<<"|"<<endl<<"|"<<endl<<"|"<<endl<<"|"<<endl<<"|"<<endl;
gotoxy (79,2); cout<<"|";
gotoxy (79,3); cout<<"|";
gotoxy (79,4); cout<<"|";
gotoxy (79,5); cout<<"|";
gotoxy (79,6); cout<<"|";
//RUN BOTH FUNT|ONS "TOGETHER"
for (;;)
{
ball_bounce ();
fflush (stdin);
paddle_pong ();
}//end for loop
}//endmain
//--------------------------------------------------------------
void ball_bounce ()
{
int oldcol,oldrow;
while (!kbhit())
{
oldcol = col;
oldrow = row;
if (row == 1) rowinc = 1;
if (row == 23) rowinc = -1;
if ((lprow <= row && row < lprow+5) && col == 2) colinc = 1;
if ((rprow <= row && row < rprow+5) && col == 78) colinc = -1;
if (col == 1)
{
scorl += 1;
gotoxy (78,24); cout<<scorl;
if (scorl == 20)
{
gotoxy (22, 10); cout<<"The winner is the player on the right.";
_setcursortype(_NOCURSOR);
}//end if right wins statement
colinc = 1;
}//end if right scores statement
if (col == 80)
{
scorr += 1;
gotoxy (1,24); cout<<scorr;
if (scorr == 20)
{
gotoxy (22,10); cout<<"The winner is the player on the left.";
_setcursortype(_NOCURSOR);
}//end if left wins statement
colinc = -1;
}//end if left scores statement
//set coordinates for next ball to be drawn:
col += colinc;
row += rowinc;
gotoxy (col, row); cout <<"o";//draws new ball
gotoxy (oldcol, oldrow); cout <<" ";//erases old ball
delay (75);
}//end while loop
}//end ball_bounce function
//-------------------------------------------------------------------
void paddle_pong ()
{
unsigned ch;
ch = getch ();
if (ch == 13||ch==27)
{
gotoxy(10,10); cout<<"GAME OVER. Press any key to exit.";
getch();
_setcursortype(_NOCURSOR);
exit (0);
}
else if (ch != 0);
else
{
switch (getch ())
{
case 73:
{
if (1<lprow)
{
lprow -=1;
gotoxy (1, lprow); cout<<"|";
gotoxy (1, lprow+5); cout<<" ";
}//end if
break;
}//end case 73
case 81:
{
if (lprow<19)
{
lprow += 1;
gotoxy (1, lprow+4); cout<<"|";
gotoxy (1, lprow-1); cout<<" ";
}//end if
break;
}//end case 81
case 72:
{
if (1<rprow)
{
rprow -=1 ;
gotoxy (79, rprow); cout<<"|";
gotoxy (79, rprow+5); cout<<" ";
}//end if
break;
}//end case 72
case 80:
{
if (rprow<19)
{
rprow += 1;
gotoxy (79, rprow+4); cout<<"|";
gotoxy (79, rprow-1); cout<<" ";
}//end if
break;
}//end case 80
}//end switch
}//end else
}//end paddle function
//END OF PROGRAM BY EMILIE SUTTERLIN