/******************************** X De Block! gameBall programs. ********************************/ #include "gameheader.h" extern Display *display; /* global display */ extern Window mWin; /* global main window */ extern GC gc; /* global gc */ extern Pixmap offPixmap,backPicPixmap; /* global offscreen pixmaps */ extern XFontStruct *xfont; /* global font */ extern Colormap cmap; /* global cmap */ extern allDataRec nowDataRec; extern mapFilePtr nowMapFile; extern flgs gameMainFlg; void serveParamReSet(void) { /**** timer Counter Flg Setting ****/ nowDataRec.nowMap.nowFlg.timeFlg = True; gettimeofday(&nowDataRec.nowMap.prevTime,NULL); /**** stage Start Text reDraw ****/ if(gameMainFlg.clearString) { stringDrawUpData(); gameMainFlg.clearString = False; } /**** stage Picture Error Patch ****/ nowDataRec.nowMap.nowFlg.errPatch1 = True; } void serveBall(void) { register i,mvMax; serveParamReSet(); /**** serve Ball Setting ********/ if(nowDataRec.nowMap.mvBallNum < nowDataRec.nowMap.allBallNum) { mvMax = (++nowDataRec.nowMap.mvBallNum); statBallDraw(); for(i ^=i; i < mvMax; i++) if(nowDataRec.nowBall[i].nowFlg.life == False) { nowDataRec.nowMap.mvBallBox[mvMax-1] = i; break; } i = nowDataRec.nowMap.mvBallBox[mvMax-1]; /***** init Ball Params ******/ nowDataRec.nowBall[i].count = 0; nowDataRec.nowBall[i].nowFlg.life = True; nowDataRec.nowBall[i].nowRect.height = dInitBallLengh; nowDataRec.nowBall[i].nowRect.width = dInitBallLengh; nowDataRec.nowBall[i].nowRect.y = nowDataRec.nowBar.nowRect.y - 24; nowDataRec.nowBall[i].nowRect.x = nowDataRec.nowBar.nowRect.x +(nowDataRec.nowBar.nowRect.width - dInitBallLengh)/2; nowDataRec.nowBall[i].prevRect = nowDataRec.nowBall[i].nowRect; nowDataRec.nowBall[i].x_v = nowDataRec.nowBar.bar_v *dBallWeight; nowDataRec.nowBall[i].y_v = -8 *dBallWeight; nowDataRec.nowBall[i].x_a = nowDataRec.nowMap.stageX_a; nowDataRec.nowBall[i].y_a = nowDataRec.nowMap.stageY_a; } } void touchBarCheckBall(i) register i; { register tempx,barWid; if((nowDataRec.nowBall[i].nowRect.y >= ((dWinHeight - dBlockHeight*2) - nowDataRec.nowBall[i].nowRect.width)) &&(nowDataRec.nowBall[i].nowRect.y <= (dWinHeight - dBlockHeight*3/2))) if(nowDataRec.nowBall[i].y_v >=0) { tempx = nowDataRec.nowBall[i].nowRect.x - nowDataRec.nowBar.nowRect.x; barWid = nowDataRec.nowBar.nowRect.width - nowDataRec.nowBall[i].nowRect.width; /***** bound Bar Left ******/ if((tempx >-nowDataRec.nowBall[i].nowRect.width)&&(tempx <= 6)) { nowDataRec.nowBall[i].y_v = -nowDataRec.nowBall[i].y_v; if((nowDataRec.nowBall[i].x_v < dBallWeight)&& (nowDataRec.nowBall[i].x_v > - dBallWeight)) nowDataRec.nowBall[i].x_v -= 1*dBallWeight; else if(nowDataRec.nowBall[i].x_v > 0) nowDataRec.nowBall[i].x_v = -nowDataRec.nowBall[i].x_v; nowDataRec.nowBall[i].x_v += nowDataRec.nowBar.bar_v *dBallWeight; if(nowDataRec.nowBall[i].x_v < -8 *dBallWeight) nowDataRec.nowBall[i].x_v = -8 *dBallWeight; if(nowDataRec.nowBall[i].y_a) nowDataRec.nowBall[i].y_v = -11 *dBallWeight; } /***** bound Bar Centar *****/ else if((tempx >6)&&(tempx < barWid -6)) { nowDataRec.nowBall[i].y_v = -nowDataRec.nowBall[i].y_v; } /***** bound Bar Right *****/ else if((tempx >= barWid -6)&& (tempx <= barWid +nowDataRec.nowBall[i].nowRect.width)) { nowDataRec.nowBall[i].y_v = -nowDataRec.nowBall[i].y_v; if((nowDataRec.nowBall[i].x_v < dBallWeight)&& (nowDataRec.nowBall[i].x_v > - dBallWeight)) nowDataRec.nowBall[i].x_v += 1*dBallWeight; else if(nowDataRec.nowBall[i].x_v < 0) nowDataRec.nowBall[i].x_v = -nowDataRec.nowBall[i].x_v; nowDataRec.nowBall[i].x_v += nowDataRec.nowBar.bar_v *dBallWeight; if(nowDataRec.nowBall[i].x_v > 8*dBallWeight) nowDataRec.nowBall[i].x_v = 8*dBallWeight; if(nowDataRec.nowBall[i].y_a) nowDataRec.nowBall[i].y_v = -11 *dBallWeight; } } } void touchWallCheckBall(i) register i; { /******** check Left or Right wall ********/ if(nowDataRec.nowBall[i].nowRect.x < dWallLeft) { if(gameMainFlg.wallThrough) /** got wallThrough item (^^; **/ nowDataRec.nowBall[i].nowRect.x = dWallRight - nowDataRec.nowBall[i].nowRect.width; else { if(nowDataRec.nowBall[i].x_v < 0) nowDataRec.nowBall[i].x_v = -nowDataRec.nowBall[i].x_v; else if(nowDataRec.nowBall[i].x_v < 8) nowDataRec.nowBall[i].x_v += 4 *dBallWeight; } } else if((nowDataRec.nowBall[i].nowRect.x + nowDataRec.nowBall[i].nowRect.width) > dWallRight) { if(gameMainFlg.wallThrough) /** got wallThrough item (^^; **/ nowDataRec.nowBall[i].nowRect.x = dWallLeft; else { if(nowDataRec.nowBall[i].x_v > 0) nowDataRec.nowBall[i].x_v = -nowDataRec.nowBall[i].x_v; else if(nowDataRec.nowBall[i].x_v > -8) nowDataRec.nowBall[i].x_v -= 4 *dBallWeight; } } /********* check Top wall **********/ if(nowDataRec.nowBall[i].nowRect.y < dWallTop) { if(nowDataRec.nowBall[i].y_v < 0) nowDataRec.nowBall[i].y_v = -nowDataRec.nowBall[i].y_v; else if(nowDataRec.nowBall[i].y_v < 8) nowDataRec.nowBall[i].y_v += 10 *dBallWeight; } } void lostCheckAllBall(void) { if(nowDataRec.nowMap.allBallNum == 0) { nowDataRec.nowMap.nowFlg.life = False; nowDataRec.nowMap.nowFlg.gameOverFlg = False; } } void lostParamReSet(void) { if(nowDataRec.nowMap.mvBallNum < 1) { if(nowDataRec.nowBar.nowRect.width > dNormalBarWidth) { drawBack_Off(&nowDataRec.nowBar.nowRect); nowDataRec.nowBar.nowRect.width = dNormalBarWidth; drawBar(); } nowDataRec.nowMap.revFlg = 1; nowDataRec.nowMap.nowFlg.timeFlg = False; /**** item Param Reset ***/ gameMainFlg.wallThrough = False; /**** draw opening String ****/ gameMainFlg.clearString = True; openingString(); } } int lostCheckBall(i,boxNum) register i,boxNum; { if(nowDataRec.nowBall[i].nowRect.y >= (dWinHeight +8)) { nowDataRec.nowBall[i].nowFlg.life = False; nowDataRec.nowMap.mvBallBox[boxNum] = nowDataRec.nowMap.mvBallBox[nowDataRec.nowMap.mvBallNum-1]; nowDataRec.nowMap.allBallNum --; nowDataRec.nowMap.mvBallNum --; lostCheckAllBall(); lostParamReSet(); return(True); } return(False); } void moveAndCheckBall(void) { register i,j,maxNum; maxNum = nowDataRec.nowMap.mvBallNum; for(j ^=j ;j < maxNum; j++) { i = nowDataRec.nowMap.mvBallBox[j]; nowDataRec.nowBall[i].prev2_y = nowDataRec.nowBall[i].prev_y; nowDataRec.nowBall[i].prev2_x = nowDataRec.nowBall[i].prev_x; nowDataRec.nowBall[i].prev_y = nowDataRec.nowBall[i].nowRect.y; nowDataRec.nowBall[i].prev_x = nowDataRec.nowBall[i].nowRect.x; nowDataRec.nowBall[i].nowRect.y += (nowDataRec.nowBall[i].y_v += nowDataRec.nowBall[i].y_a) / dBallWeight; nowDataRec.nowBall[i].nowRect.x += (nowDataRec.nowBall[i].x_v += nowDataRec.nowBall[i].x_a) /dBallWeight; touchWallCheckBall(i); touchBarCheckBall(i); drawBall(i); nowDataRec.nowBall[i].prevRect = nowDataRec.nowBall[i].nowRect; if(lostCheckBall(i,j)) { maxNum--; j--; } } }