// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // block.hsp // // this is block break game for the program contest // // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - // definition of const // - - - - - - - - - - - - - - - - - - - // - - - - - for debug - - - - - - // //#define _debug_ // - - - - - - - - - - - - - - - - // // - - - - - about main window - - - - // #const MAIN_BUFFER_ID 0 #const MAIN_BUFFER_WIDTH 640 #const MAIN_BUFFER_HEIGHT 480 // - - - - about work area - - - - // #const WORK_AREA_HEAD_POS_X 0 #const WORK_AREA_HEAD_POS_Y 0 #const WORK_AREA_FOOT_POS_X MAIN_BUFFER_WIDTH - 192 #const WORK_AREA_FOOT_POS_Y MAIN_BUFFER_HEIGHT // - - - - about block - - - - // #const BLOCK_BUFFER_ID 16 #const NUM_BLOCK_LEVEL 8 #const BLOCK_POS_X WORK_AREA_HEAD_POS_X - 12 #const BLOCK_POS_Y WORK_AREA_HEAD_POS_Y #const BLOCK_WIDTH 48 #const BLOCK_WIDTH_MIN1 BLOCK_WIDTH - 1 #const BLOCK_WIDTH_MIN2 BLOCK_WIDTH - 2 #const BLOCK_HEIGHT 12 #const BLOCK_HEIGHT_MIN1 BLOCK_HEIGHT - 1 #const BLOCK_HEIGHT_MIN2 BLOCK_HEIGHT - 2 #const NUM_BLOCK_X 10 #const NUM_BLOCK_Y 8 #const NUM_BLOCK NUM_BLOCK_X * NUM_BLOCK_Y #const NUM_BLOCK_X_DIV2 NUM_BLOCK_X / 2 #const NUM_BLOCK_Y_DIV2 NUM_BLOCK_Y / 2 #const NUM_BLOCK_X_MIN2 NUM_BLOCK_X - 2 #const NUM_BLOCK_Y_MIN2 NUM_BLOCK_Y - 2 #const NUM_BLOCK_MIN2 NUM_BLOCK_X_MIN2 * NUM_BLOCK_Y_MIN2 // - - - - about ball - - - - // #const BALL_BUFFER_ID 3 #const BALL_SIZE 3 #const BALL_REFRECT_POSX WORK_AREA_FOOT_POS_X - BALL_SIZE #const BALL_REFRECT_POSX_DIV2 BALL_REFRECT_POSX / 2 // - - - - about bar - - - - // #const BAR_WIDTH 64 #const BAR_WIDTH_DIV2 BAR_WIDTH / 2 #const BAR_HEIGHT 3 #const BAR_WORKABLE_AREA_HEAD_POS_X WORK_AREA_HEAD_POS_X #const BAR_WORKABLE_AREA_HEAD_POS_Y WORK_AREA_FOOT_POS_Y - BAR_HEIGHT - 64 #const BAR_WORKABLE_AREA_FOOT_POS_X WORK_AREA_FOOT_POS_X - BAR_WIDTH #const BAR_WORKABLE_AREA_FOOT_POS_Y WORK_AREA_FOOT_POS_Y - BAR_HEIGHT // - - - - phase - - - - // #enum ON_TITLE = 0 #enum ON_STARTING #enum ON_GAMING #enum ON_CLEARED #enum ON_NEW_RECORD // - - - - .ext - - - - // #const SKILL_USABLE_POS_Y ( WORK_AREA_HEAD_POS_Y + WORK_AREA_FOOT_POS_Y ) / 2 #const NUMBER_OF_STAGE 3 #const NUM_ALIVE_MAX 5 // - - - - - - - - - - - - - - - - - - - // definition of method // - - - - - - - - - - - - - - - - - - - if 0 { #deffunc sepColor int c color c, c, c return } // - - - - - - - - - - - - - - - - - - - // begin of program // - - - - - - - - - - - - - - - - - - - // - - - - initialize variable - - - - // // - - for cracking size - - // _MSGothic = "‚l‚r ƒSƒVƒbƒN" min1-- // - - stage date ( compressed ) - - // stage = ")*)**)*)*)*))*)*)*)**)*)*)*))*)*)*)**)*)*)*))*)*,,,,,,,,*)*))*)*)*)**)*)*)*))*)*)*)**)*),,,,,,,,****************************************////////" // - - - - make buffer for block - - - - // repeat NUM_BLOCK_LEVEL buffer BLOCK_BUFFER_ID + cnt, BLOCK_WIDTH_MIN1, BLOCK_HEIGHT_MIN1 sepColor 255 - cnt * 30 boxf 1, 1 loop // - - - - set target window id - - - - // gsel // - - - - main loop - - - - // repeat // - - - - - - - - COMMON _ ROOTEN - - - - - - - - // // - - - - initialize - - - - // redraw : await 10 : redraw 0 sepColor 192 boxf sepcolor 255 boxf WORK_AREA_HEAD_POS_X, WORK_AREA_HEAD_POS_Y, WORK_AREA_FOOT_POS_X, WORK_AREA_FOOT_POS_Y // - - - - - - caluculate - - - - - - // // - - - - bar - - - - // __barPosX = _barPosX __barPosY = _barPosY _barPosX = barPosX _barPosY = barPosY // - - corrected mouse position - - // _x = limit( mouseX, BAR_WORKABLE_AREA_HEAD_POS_X, BAR_WORKABLE_AREA_FOOT_POS_X ) _y = limit( mouseY, BAR_WORKABLE_AREA_HEAD_POS_Y, BAR_WORKABLE_AREA_FOOT_POS_Y ) // - - set bar position - - // if( missCount ) { // on miss barPosX++ barPosY += missCount - 30 missCount += 2 ballPosY -= 5000 if( missCount > 96 ) { // time is up numAlive-- dim clearedCount gosub*initBar dim missCount goto*draw // skip calucuration } } else : if( barFadeCnt ) { // on fading barFadeCnt-- barPosX = _x - barFadeCnt * barFadeCnt barPosY = _y } else { // do not fade and miss barPosX = _x barPosY = _y } barMoveX = ( __barPosX - barPosX ) / 2 barMoveY = ( __barPosY - barPosY ) / 2 // - - - - key - - - - // rClickedObjAge++ stick key lClicked = key & 256 if( key & 512 ) { dim rClickedObjAge } // - - - - - - - - ON _ TITLE - - - - - - - - // if( rootPhase ) : else { sepcolor if( cnt & 16 ) { // blink pos 200, 320 font _MSGothic, 18 mes "Click to start" } pos 40, 40 font _MSGothic, 32, 17 mes "Gb Block Break" dim clearedCount if( lClicked ) { numAlive = NUM_ALIVE_MAX dim currentStage dim score dim scorePool gosub*nextStage } } // - - - - - - - - ON _ STARTING - - - - - - - - // if( rootPhase == ON_STARTING ) { dim clearedCount if( startCount > 64 ) { ballPosX = barPosX + BAR_WIDTH_DIV2 rootPhase++ } else { pos 220, 240 sepcolor startCount * 4 mes "Stage " + currentStage } } // - - - - - - - - ON _ GAMING - - - - - - - - // if( rootPhase == ON_GAMING ) { if( startCount < 110 ) { foo = limit( startCount - 96, 0, 511 ) pos 220 + foo * foo, 240 sepColor font _MSGothic, 18 mes "Start" } // - - - - ball - - - - // // - - is hit with wall ? - - // if( ( ballPosX + ballSpeedX - BALL_REFRECT_POSX_DIV2 ) / ( BALL_REFRECT_POSX_DIV2 ) ) { // side wall ballSpeedX *= min1 } if( ballPosY > WORK_AREA_FOOT_POS_Y ) { // miss dim chainCount scorePool -= 45 missCount++ } if( ballPosY < 0 ) { // top wall ballSpeedY *= min1 } // - - is hit with bar ? - - // if( ( ballPosY + ballSpeedY >= barPosY ) & ( ballPosY <= _barPosY ) & ( ( barPosX <= ballPosX ) & ( ballPosX <= barPosX + BAR_WIDTH ) ) ) { // on hit bar dim chainCount ballPiecable = rClickedObjAge <= 8 ballPosY = barPosY ballSpeedY = -limit( ballSpeedY * 3 / 4 + barMoveY / 2, 2, 8 ) ballSpeedX = limit( ( ballSpeedX - barMoveX ) / 2 ,-8, 8 ) } if( ballCatched ) { ballPosX = barPosX + BAR_WIDTH_DIV2 ballPosY = barPosY - BALL_SIZE if( lClicked ) { // ball released ballSpeedX = limitf( -barMoveX, -8.0, 8.0 ) ballSpeedY = -6.0 dim ballCatched } } else { ballPosX += ballSpeedX ballPosY += ballSpeedY } // - - is hit with block ? - - // // set variable for hack hoge = ballPosX + ballSpeedX xof = ( hoge - BLOCK_POS_X ) / BLOCK_WIDTH piyo = ballPosY + ballSpeedY yof = ( piyo - BLOCK_POS_Y ) / BLOCK_HEIGHT if( ( ( xof - NUM_BLOCK_X_DIV2 ) / NUM_BLOCK_X_DIV2 | ( yof - NUM_BLOCK_Y_DIV2 ) / NUM_BLOCK_Y_DIV2 ) ) { // not in block's area goto*@f } else { if( blockLife.yof.xof ) { // hit with block if( lClicked ) { // break blockLife.yof.xof = 0 } else : if( ( _xof != xof ) | ( _yof != yof ) ) { blockLife.yof.xof-- } if( blockLife.yof.xof ) : else { score += scorePool scorePool = 15 + ( chainCount ) if( ballPiecable ) : else { chainCount++ breakX = ballPosX breakY = ballPosY breakCount = 24 } } _xof = xof _yof = yof if( ballPiecable ) {} else { // set target position targetPosX = BLOCK_POS_X + BLOCK_WIDTH * ( xof + ( ballSpeedX < 0 ) ) targetPosY = BLOCK_POS_Y + BLOCK_HEIGHT * ( yof + ( ballSpeedY < 0 ) ) // horizon if( ( ballPosX <= targetPosX & hoge >= targetPosX ) | ( ballPosX >= targetPosX & hoge <= targetPosX ) ) { ballSpeedX *= min1 } // vertical if( ( ballPosY <= targetPosY & piyo >= targetPosY ) | ( ballPosY >= targetPosY & piyo <= targetPosY ) ) { ballSpeedY *= min1 } } } else { *@ if( ( rClickedObjAge <= 8 ) & ( ballPosY < SKILL_USABLE_POS_Y ) ) { dim ballPiecable } dim _xof } } #ifdef _debug_ if( key & 16) { // space bar // init stage date repeat NUM_BLOCK x = cnt \ NUM_BLOCK_X y = cnt / NUM_BLOCK_X blockLife.y.x = 0 loop } #endif // - - score - - // if( scorePool ) { if( scorePool > 0 ) { scorePool-- score++ } else { scorePool++ score-- } } *draw // - - - - - - draw - - - - - - // // - - - - draw block and check cleared or not - - - - // dim f repeat NUM_BLOCK_Y _cnt = cnt repeat NUM_BLOCK_X pos BLOCK_POS_X + cnt * BLOCK_WIDTH, BLOCK_POS_Y + _cnt * BLOCK_HEIGHT gmode 4, BLOCK_WIDTH, BLOCK_HEIGHT, 255 sepColor 0xff gcopy BLOCK_BUFFER_ID + blockLife._cnt.cnt f |= blockLife._cnt.cnt loop loop if( f ) : else : rootPhase++ // cleare } pos 220, 240 sepColor 255 - clearedCount // - - game over - - // if( numAlive ) : else { mes "Game over" clearedCount += 4 goto*@f } if( rootPhase = ON_CLEARED ) { clearedCount += 4 if( currentStage == NUMBER_OF_STAGE ) { mes "Clear" *@ if( clearedCount > 250 ) { score += scorePool if( hiscore < score ) { hiscore = score rootPhase = ON_NEW_RECORD } else { dim rootPhase } } } else { mes "Complete" if( clearedCount > 250 ) { gosub*nextStage rootPhase = ON_STARTING } } } if( rootPhase = ON_NEW_RECORD ) { clearedCount += 2 pos 200, 240 sepcolor 255 - ( clearedCount - 250 ) mes "New record : " + hiscore if( clearedCount > 500 ) : dim rootPhase } else { // - - - - - - common rooten ( foot ver ) - - - - - - // // - - prev val - - // startCount++ // - - draw bar - - // sepColor 128// + ( clearedCount / 2 ) boxf barPosX, barPosY, barPosX + BAR_WIDTH, barPosY + BAR_HEIGHT // - - draw ball - - // if( rootPhase == ON_GAMING ) { color ballPiecable * 255 boxf ballPosX, ballPosY, ballPosX + BALL_SIZE, ballPosY + BALL_SIZE } } // - - inforametion - - // sepColor font _MSGothic, 18 pos 460, 4 mes strf( "Score : %9d", score ) mes strf( "Hiscore : %9d", hiscore ) mes strf( "Remain : %9d", numAlive ) // - - combo - - // if( breakCount > 0 ) { pos breakX - breakCount, breakY - 64 + ( ( 16 - breakCount ) * ( 16 - breakCount ) ) sepcolor 128 font _MSGothic, 13, 2 mes "" + chainCount + "combo" breakCount-- } loop *nextStage dim startCount // uncompress stage date dim blockLife, NUM_BLOCK_Y, NUM_BLOCK_X repeat NUM_BLOCK_MIN2 x = cnt \ NUM_BLOCK_X_MIN2 + 1 blockLife.(cnt/NUM_BLOCK_X_MIN2+1).x = peek( stage, cnt + currentStage * NUM_BLOCK_MIN2 ) - 40 loop rootPhase = ON_STARTING currentStage++ *initBar barFadeCnt = sqrt( mousex ) ballCatched++ return