class BlockModel{ // int mode = 0; public BlockModel(BlockViewInfo vInfo){ //ボールの横幅、縦幅 // int x0 = vInfo.getballRx(); // int y0 = vInfo.getballRy(); //描画領域の幅と高さ // int w = vInfo.getvWidth(); // int h = vInfo.getvHeight(); } public BlockViewInfo getNextInfomation(BlockViewInfo infomation){ int bx = infomation.getballX(); int by = infomation.getballY(); int bW = infomation.getballRx(); int bH = infomation.getballRy(); int rx = infomation.getcursorX(); int ry = infomation.getcursorY(); int rW = infomation.getcursorW(); int rH = infomation.getcursorH(); int viewW = infomation.getvWidth(); int viewH = infomation.getvHeight(); int dx = infomation.getDX(); int dy = infomation.getDY(); //行、列 の配列のサイズ int Bsize = infomation.getRow() * infomation.getCol(); // int i; // カウンター /* ラケットに当たったときの処理 */ if ( by + bH >= ry && by + bH <= ry+rH && bx + bW >= rx && bx <= rx+rW ) { /* ラケットに当たったら上へ返す */ dy = -2; if ( bx < rx || bx + bW > rx + rW ) { /* ラケットの端に当たった時 */ if ( dx == 0 ) { /* 垂直に来たボール */ if ( bx < rx ) { /* 左端に当たったら左斜め上に返す*/ dx = -2; // 左斜め上に返す  } if ( bx + bW > rx + rW ) { /* 右端に当たったら右斜め上に返す*/ dx = +2; } } else { /* 斜めに来たボールは垂直に返す */ dx = 0; } } } /* 左端、右端、上端に来たときの処理 */ if (bx < 0){ /* 左端に来たら反転 */ dx = 2; } if (bx + bW > viewW) { /* 右端に来たら反転 */ dx = -2; } if (by < 0) { /* 上端に来たら反転 */ dy = 2; } /* ブロックに当たったときの処理 */ for(int i = 0 ; i < Bsize ; i++ ){ if (infomation.getBlock()[i] == 1 ) { if ( by + bH >= infomation.getBy()[i] && by <= infomation.getBy()[i]+infomation.getBH() && bx + bW >= infomation.getBx()[i] && bx <= infomation.getBx()[i]+infomation.getBW()){ if(infomation.getMode()!=4){ //大筆ボタンの時ではないとき /* ブロックに当たったら反転 */ System.out.println(dy); dy = -dy; System.out.println(dy); } // ブロックを消す infomation.setBlockState(i); //ブロックの数をセット infomation.setSubTotalBlock(-1); // if ( 10 <= i && i < 20 ) { // speed = 15; // } else { // speed = 30; // } } } } /* ラケットの下へ行ったときの処理 */ if ( by + bH > viewH +100) { /* 下端に来たらモードを初期状態に*/ infomation.setMode(2); System.out.println("aaaaaaaa"); } bx = bx + dx; by = by + dy; // repaint(); //次のボールの位置のセット infomation.setballX(bx); infomation.setballY(by); //次のボールの増分量をセット infomation.setDX(dx); infomation.setDY(dy); //System.out.println(bx+","+by+",,"+dx+","+dy); if(infomation.getMode()==4){ //大筆ボタンの時 if (by < 0) { /* 上端に来たらset */ infomation.setballY(-50); infomation.setroketFlag(true); // infomation.setballX(-100); } else{infomation.setroketFlag(false);} } return infomation; }//getNextInfomationメソッドの終わり }