home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1998 March / VPR9803A.ISO / Ffilly / Ss01p / 神経衰弱.tfy < prev    next >
Text File  |  1997-12-26  |  5KB  |  178 lines

  1. int pBack, pBase, pButton[], pCard[];
  2. int cBase, cCard[], cButton[];
  3. int pCard00;
  4. int nCardMax;
  5. int nRow, nColumn;
  6. int cDown;
  7. int wCard, hCard;
  8. int wBack, hBack;
  9.  
  10. main(){
  11.     init();
  12.     game();
  13. }
  14.  
  15. init(){
  16.     int pButton00, pButton01;
  17.     int wButton, hButton;
  18.     int xButton, yButton;
  19.     nRow=7;
  20.     nColumn = 4;
  21.     nCardMax = nRow * nColumn-2;
  22.     CapTitle( " 神経衰弱 Version 0.1" );
  23.     pBack = LoadPic( "back.bmp" );
  24.     wBack = PicWidth( pBack );
  25.     hBack = PicHeight( pBack );
  26.     pBase = CreatePic( pBack );
  27.     pCard[ nCardMax ] = LoadPic( "card0.bmp" );
  28.     pCard00 = LoadPic( "cardpic.bmp" );
  29.     wCard = PicWidth( pCard[ nCardMax ] );
  30.     hCard = PicHeight( pCard[ nCardMax ] );
  31.     pButton00 = LoadPic( "button0.bmp");
  32.     pButton01 = LoadPic( "button1.bmp");
  33.     wButton = PicWidth( pButton00 );
  34.     hButton = PicHeight( pButton00 ) / 2;
  35.     pButton[0] = CreatePic( pButton00, wButton, hButton );
  36.     pButton[10] = CreatePic( pButton01, wButton, hButton );
  37.     MovePic( pButton00, 0, 0, wButton, hButton, pButton[ 0 ] );
  38.     MovePic( pButton01, 0, 0, wButton, hButton, pButton[ 10 ] );
  39.     pButton[ 1 ] = CreatePic( pButton00, wButton, hButton );
  40.     pButton[ 11 ] = CreatePic( pButton01, wButton, hButton );
  41.     MovePic( pButton00, 0, hButton, wButton, hButton, pButton[ 1 ] );
  42.     MovePic( pButton01, 0, hButton, wButton, hButton, pButton[ 11 ] );
  43.     cBase = PutCast( pBack, pBase );
  44.     xButton = wBack - wButton - 10;
  45.     yButton = hBack - hButton * 2 - 30;
  46.     cButton[0] = PutCast( pButton[ 0 ], pBase, xButton, yButton );
  47.     cButton[1] = PutCast( pButton[ 1 ], pBase, xButton, yButton + hButton );
  48.     DelPic( pButton00 );
  49.     DelPic( pButton01 );
  50.     OpenWin( pBase );
  51. }
  52.  
  53. int game(){
  54.     int nCard, xCard[], yCard[];
  55.     int nDown[];
  56.     int sCard[],i;
  57.     int xOff, yOff;
  58.     int nScore, nHiScore, nPair, nCount, nMessage;
  59.     int cOldDown, nOldCard;
  60.     cOldDown = cBase;
  61.     xOff = 20;
  62.     yOff = 36;
  63.     for( nCard = 0; nCard < nCardMax; nCard = nCard + 1 ){
  64.         xCard[ nCard ] = ( nCard % nRow ) * ( wCard + 4 ) + xOff;
  65.         yCard[ nCard ] = ( nCard / nRow ) * ( hCard + 8 ) + yOff;
  66.         cCard[ nCard ] = PutCast( pCard[ nCardMax ], pBase, xCard[ nCard ], yCard[ nCard ], 0x00ff00, 0, 1, 1 );
  67.         repeat:;
  68.         sCard[ nCard ] = Random( nCardMax );
  69.         for(i = 0; i < nCard; i = i + 1 ){
  70.             if( sCard[ nCard ] == sCard[ i ] ) goto repeat;
  71.         }
  72.         pCard[ nCard ] = CreatePic( pCard00, wCard, hCard );
  73.         MovePic( pCard00, ( sCard[nCard] % 13 ) * wCard, ( sCard[nCard] / 13 ) * hCard, wCard, hCard, pCard[ nCard ] );
  74.         nDown[ nCard ] = 0;
  75.     }
  76.     RepaintCast( pBase, 0, 0, wBack, hBack );
  77.     nCount = 0;
  78.     nPair = 0;
  79.     nScore = 0;
  80.     nHiScore = GetIniInt( "record", "hiscore", 0, ".\神経衰弱.ini" );
  81.     BackMode( 0 );
  82.     SetFont( 28, "MSP ゴシック", 128 );
  83.     TextColor( 255, 255, 0 );
  84.     BgColor( 0, 0, 0 );
  85.     TextWrite( StrPrint( "%4ld", nScore ), pBase, 550, 226 );
  86.     TextWrite( StrPrint( "%4ld", nHiScore ), pBase, 550, 151 );
  87.     TextWrite( "normal", pBase, 530, 297 );
  88.     mes( LBDOWN ){
  89.         nMessage = GetMesNo( 0 );
  90.         cDown = HitCast( pBase, MesP2, MesP3);
  91.         if( cDown == cButton[ 0 ] ){
  92.             mes(TIME){
  93.                 step( 8 ){
  94.                     del_us;
  95.                     MoveCast( cButton[ 0 ], pButton[ 10 ] );
  96.                     ,
  97.                     MoveCast( cButton[ 0 ], pButton[ 0 ] );
  98.                     ,,
  99.                     for( nCard = 0; nCard < nCardMax; nCard = nCard + 1 ){
  100.                         DelCast( cCard[ nCard], 1 );
  101.                     }
  102.                     RepaintCast( pBase, 0, 0, wBack, hBack );
  103.                     game();
  104.                     del_me;
  105.                 }
  106.             }
  107.         }
  108.         else if( cDown == cButton[ 1 ] ){
  109.             mes(TIME){
  110.                 step( 8 ){
  111.                     del_us;
  112.                     MoveCast( cButton[ 1 ], pButton[ 11 ] );
  113.                     ,
  114.                     MoveCast( cButton[ 1 ], pButton[ 1 ] );
  115.                     ,,
  116.                     CloseWinAll();
  117.                     del_me;
  118.                 }
  119.             }
  120.         }
  121.         else if( cDown != cBase && cDown != cOldDown ){
  122.             FreezeMes( nMessage );
  123.             nCount = nCount + 1;
  124.             nCard = ( MesP2 - xOff ) / ( wCard + 4 ) + ( MesP3 - yOff ) / ( hCard + 8 ) * nRow;
  125.             nDown[ nCard ] = nDown[ nCard ] + 1;
  126.             MoveCast( cDown, pCard[ nCard ] );
  127.             if( nCount % 2 == 0 ){
  128.                 mes(TIME){
  129.                     step( 8 ){
  130.                         ,,,
  131.                         if(sCard[ nCard ] % 13 == sCard[ nOldCard ] % 13 ){
  132.                             MoveCast( cDown, pCard[ nCard ], wBack, 0 );
  133.                             MoveCast( cOldDown, pCard[ nOldCard ], wBack, 0 );
  134.                             nPair = nPair + 1;
  135.                             nScore = nScore + 2000 / ( nDown[ nCard ] + nDown[ nOldCard ] );
  136.                             BackMode( 0 );
  137.                             SetFont( 28, "MSP ゴシック", 128 );
  138.                             TextColor( 255, 255, 0 );
  139.                             BgColor( 0, 0, 0 );
  140.                             TextWrite( StrPrint( "%4ld", nScore ), pBase, 550, 226 );
  141. //                            if( nPair ==  1 ){
  142.                             if( nPair == nCardMax / 2 ){
  143.                                 BackMode( 1 );
  144.                                 SetFont( 42, "MSP ゴシック", 128 );
  145.                                 TextColor( 255, 255, 255 );
  146.                                 TextWrite( "Congratulations!", pBase, 102, 212 );
  147.                                 TextColor( 255, 0, 0 );
  148.                                 TextWrite( "Congratulations!", pBase, 100, 210 );
  149.                                 if( nScore > nHiScore ){
  150.                                     nHiScore = nScore;
  151.                                     WriteIniInt( "record", "hiscore", nHiScore, ".\神経衰弱.ini" );
  152.                                     BackMode( 0 );
  153.                                     SetFont( 28, "MSP ゴシック", 128 );
  154.                                     TextColor( 255, 255, 0 );
  155.                                     BgColor( 0, 0, 0 );
  156.                                     TextWrite( StrPrint( "%4ld", nHiScore ), pBase, 550, 151 );
  157.                                 }
  158.                             }
  159.                         }
  160.                         else{
  161.                             MoveCast( cDown, pCard[ nCardMax ] );
  162.                             MoveCast( cOldDown, pCard[ nCardMax ] );
  163.                             cOldDown = cBase;
  164.                         }
  165.                         ActivateMes( nMessage );
  166.                         del_me;
  167.                     }
  168.                 }
  169.             }
  170.             else{
  171.                 nOldCard = nCard;
  172.                 cOldDown = cDown;
  173.                 ActivateMes( nMessage );
  174.             }
  175.         }
  176.     }
  177. }
  178.