// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // type.hsp // // a typing game for the hsp contest // // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //--------------------------------------------------------------------------------------------------- // // 定数の宣言 // //--------------------------------------------------------------------------------------------------- ; #include "debug.as" #const global true 1 #const global false 0 #const global mainBufferID 0 #const global mainBufferWidth 640 #const global mainBufferHeight 480 #const global effectBufferID 1 #const global effectWidth 72 #const global effectHeight 72 #const global numberOfEffectFrame 4 #const global numberOfEffectType 2 #const global numberOfStackableCombo 16 #const global numberOfStackableEffect numberOfStackableCombo #const global effectBufferWidth effectWidth #const global effectBufferHeight effectHeight #const global pass 1 #const global fail 5 #const global backBufferID 11 #const global seeThroughColorRed 0 #const global seeThroughColorGreen 0 #const global seeThroughColorBlue 0 #const global taskFontSize 48 #const global nextTaskFontSize 24 #const global numberOfTaskScript 100 #const global nowTaskScriptPosX 240 #const global nowTaskScriptPosY 320 #const global nextTextPosX nowTaskScriptPosX + 10 #const global nextTextPosY nowTaskScriptPosY + 56 #const global effectPosY nowTaskScriptPosY - 16 #const global firstEffectPosX nowTaskScriptPosX - 24 #const global nextTaskScriptPosX nowTaskScriptPosX + 64 #const global nextTaskScriptPosY nowTaskScriptPosY + 48 #const global fontTypeItalicBold 2 | 16 #const global comboEffectHeadFontSize 15 #const global comboEffectFootFontSize 10 #const global ComboEffectPosY nowTaskScriptPosY - 16 #const global nowTaskScriptUnderLineHeadPosX nowTaskScriptPosX #const global nowTaskScriptUnderLineHeadPosY nowTaskScriptPosY + 44 #const global nowTaskScriptUnderLineFootPosX mainBufferWidth - 120 #const global nowTaskScriptUnderLineFootPosY nowTaskScriptUnderLineHeadPosY + 1 #const global nextTaskScriptUnderLineHeadPosX nowTaskScriptPosX + 4 #const global nextTaskScriptUnderLineHeadPosY nowTaskScriptPosY + 72 #const global nextTaskScriptUnderLineFootPosX mainBufferWidth - 120 + 12 #const global nextTaskScriptUnderLineFootPosY nextTaskScriptUnderLineHeadPosY + 1 #const global scorePosX mainBufferWidth - 124 #const global scorePosY 32 #const global timeMeterHeadPosX 56 #const global timeMeterHeadPosY 72 #const global timeMeterFootPosX timeMeterHeadPosX + 2 #const global timeMeterFootPosY 440 #const global timeMeterHeight 360 #const global timeMeterHeight_div60 timeMeterHeight / 60 #const global timeMeterCountPerHeight timeMeterHeight / 4 #const global timeMeterCountPosY 72 #const global timeMeterCountPosX timeMeterHeadPosX - 24 #const global backGroundColorRed 0xaa #const global backGroundColorGreen 0xdd #const global backGroundColorBlue 0xdd #const global onInitializing 3 #const global onJustTypingTask 0 #const global onTypingTask 1 #const global onJustCheckingResult 2 #const global pressSToStartPosX mainBufferWidth / 2 - 64 #const global pressStoStartPosY mainBufferHeight / 2 - 16 #const global confirmRetryPosX mainBufferWidth - 140 #const global confirmRetryPosY mainBufferHeight - 36 #const global countDownPosX mainBufferWidth / 2 - 32 #const global countDownPosY mainBufferHeight / 2 + 16 #ifndef gmode_gdi #const global gmode_gdi 0 #endif #ifndef gmode_rgb0alpha #const global gmode_rgb0alpha 4 #endif #ifndef ginfo_messize #const global ginfo_messize 7 #endif //--------------------------------------------------------------------------------------------------- // // 初期化 // //--------------------------------------------------------------------------------------------------- //--------------------------------------- 変数初期化 -------------------------------------// _MSGothic = "MS ゴシック" infoType = "WPM", "EPM", "Score", "HiScore" dim replayDataTimeCode, 1000 //--------------------------------------- 問題文展開 -------------------------------------// target = "assert,await,bcopy,bgscr,bload,break,boxf,buffer,button,chdir,chdpm,circle,clrobj,cls,cnt,color,combox,ddim,delete,dialog,dim,dimtype,dirinfo,double,dup,end,exec,exgoto,exist,font,foreach,gcopy,getpath,getstr,ginfo,gmode,gosub,goto,grotate,gsel,gzoom,hspver,hdc,if,input,instr,int,iparam,length,limitf,line,logf,logmes,loop,lpeek,mcall,mci,memcpy,memset,mes,mesbox,mkdir,mmstop,mouse,newcom,newmod,noteadd,notesel,objinfo,objprm,on,oncmd,palette,pget,picload,pos,pset,redraw,refstr,repeat,return,rnd,run,screen,sdim,sin,sqrt,stat,stick,stop,strlen,strsize,sysfont,sysinfo,title,varptr,wait,width,winobj,wpoke" repeat 100 getstr taskScript.cnt, target, idx, ',' idx += strsize loop //------------------------------------- バッファ初期化 ------------------------------------// //- - - - - - - - - - - - - - - - - - エフェクト用バッファ - - - - - - - - - - - - - - - // repeat numberOfEffectFrame foo = cnt * ( cnt + 2 ) bar++ repeat numberOfEffectType baz = cnt buffer baz * 4 + bar, effectWidth, effectHeight color boxf repeat 2 color baz * 0xff, 0x00, 0xff + cnt hoge = cnt + foo piyo = effectWidth - hoge boxf hoge, hoge, piyo, piyo loop loop loop //- - - - - - - - - - - - - - - - - - - 初期化用バッファ - - - - - - - - - - - - - - - - // buffer backBufferID color 140, 192, 192 boxf color backGroundColorRed, backGroundColorGreen, backGroundColorBlue boxf 80, 62, 604, 444 pos 216, 14 font _MSGothic, 32, 3 mes "HotSoupTyping" color 24, 128 // - - - - - - 今やってる問題に惹かれる下線 - - - - - // boxf nowTaskScriptUnderLineHeadPosX, nowTaskScriptUnderLineHeadPosY, nowTaskScriptUnderLineFootPosX, nowTaskScriptUnderLineFootPosY // - - - - - - 次の問題の下線と'next ->'文字列 - - - - - // font _MSGothic, 14, 17 pos nextTextPosX, nextTextPosY mes "next->" boxf nextTaskScriptUnderLineHeadPosX, nextTaskScriptUnderLineHeadPosY, nextTaskScriptUnderLineFootPosX, nextTaskScriptUnderLineFootPosY // - - - - - - 左のメータの数字 - - - - - - // color , 72 repeat 5 pos timeMeterCountPosX, 426 - cnt * 86 mes cnt * 15 loop pos 16, 456 mes "Remain(s)" //--------------------------------------------------------------------------------------------------- // // メイン部分 // //--------------------------------------------------------------------------------------------------- //------------------------------------- 初期化 -----------------------------------------------// gsel gosub*_initializeVariable replay++ onkey gosub*onKeyPressed //--------------------------------- ゲームのメイン ------------------------------------------// *main // - - - - - 画面初期化 - - - - - // redraw : await 15 : redraw 0 currentTimeMilliSeconds = getTime( 7 ) differentTimeSeconds = ( ( currentTimeMilliSeconds <= oldTimeMilliSeconds ) + 59 - getTime( 6 ) + oldTimeSeconds ) \ 60 differentTimeMilliSeconds = ( 1000 - currentTimeMilliSeconds + oldTimeMilliSeconds ) \ 1000 // - - - - - 画面初期化 - - - - - // pos 0, 0 gmode gmode_gdi, mainBufferWidth, mainBufferHeight gcopy backBufferID // ------------- デバッグ用 -------------// #ifdef debugable stick kkk if( kkk == 16 ) { totalStatus = onJustCheckingResult } #endif // ------------- リプレイ時に -------------// font _MSGothic, 24 key = pressedKeyCode == 'Y' if replay { if key { dim replay dim totalStatus } if( totalStatus != onJustCheckingResult ) * ( differentTimeMilliSeconds & 0x100 ) { color pos pressSToStartPosX, pressSToStartPosX mes "Press Y" } } if( totalStatus - replay ) : else : if( key | startable ) { dim pressedKeyCode redraw repeat 3 // カウントダウン開始 , メインループ無視中 pos 0, 0 gcopy backBufferID color pos countDownPosX, countDownPosY mes 3 - cnt if( pressedKeyCode ) { wait 15 } else { wait 100 } loop gosub*_initializeVariable seed = oldTimeMilliSeconds totalStatus++ dim startable dim pressedKeyCode } if totalStatus == onTypingTask { // ブロックが相当長いので注意 //------------------------------- onTypingTask ----------------------------------------// if differentTimeSeconds - _differentTimeSeconds > 3 { totalStatus++ } _differentTimeSeconds = differentTimeSeconds // - - - - - キー入力とその処理 - - - - - // if replay { if( differentTimeSeconds * 1000 + differentTimeMilliSeconds < replayDataTimeCode.nowReplayIndex ) { _pressedKeyCode = replayDataKeyCode.nowReplayIndex nowReplayIndex++ } else { dim _pressedKeyCode } } else { _pressedKeyCode = pressedKeyCode // やりなおし if( pressedKeyCode == 27 ) { // ESC dim totalStatus startable++ } } if _pressedKeyCode { if replay == false { replayDataTimeCode.replayWriteIndex = differentTimeSeconds * 1000 + differentTimeMilliSeconds replayDataKeyCode.replayWriteIndex = _pressedKeyCode replayWriteIndex++ } effectCount.effectID = 0 effectXof.effectID = clearedTask if _pressedKeyCode + 32 == peek( taskScriptNowTask, clearedTask ) { // 正しいキー currentCombo++ clearedTask++ missedCharIndex = 0xff score += currentCombo / 4 + 511 numberOfTrueType++ effectType.effectID = pass if clearedTask == strlen( taskScriptNowTask ) { // 今売ってる単語は終了 nowTask = nextTask dup taskScriptNowTask, taskScript.nowTask nextTask = rnd( 100 ) dim clearedTask } } else { // 間違ったキー effectType.effectID = fail missedCharIndex = clearedTask dim currentCombo numberOfMiss++ score -= 511 } effectID = ( effectID + 1 ) \ numberOfStackableEffect // "次の"エフェクトIDにおくる } // - - - - - 情報 - - - - - // font _MSGothic, nextTaskFontSize, 17 color , 72 pos scorePosX, scorePosY mes strf( "%7d", score ) // - - - - - 経過時間出力 - - - - - // boxf timeMeterHeadPosX, timeMeterFootPosY, timeMeterFootPosX, timeMeterFootPosY - differentTimeSeconds * timeMeterHeight_div60 // - - - - - 次の問題 - - - - - // color 24, 128 pos nextTaskScriptPosX, nextTaskScriptPosY mes taskScript.nextTask // - - - - - 今の問題(全部) - - - - - // font _MSGothic, taskFontSize, 17 pos nowTaskScriptPosX, nowTaskScriptPosY mes taskScriptNowTask // - - - - - クリア済みの部分 - - - - - // color 0, 64, 192 pos nowTaskScriptPosX, nowTaskScriptPosY mes strMid( taskScriptNowTask, 0, clearedTask ) // - - - - - ミスした部分 - - - - - // if missedCharIndex != 0xff { color 212, 92 pos missedCharIndex * 25 + nowTaskScriptPosX, nowTaskScriptPosY mes strMid( taskScriptNowTask, missedCharIndex, 1 ) } // - - - - - エフェクト準備 - - - - - // gmode gmode_rgb0alpha, effectWidth, effectHeight, 0x33 dim foo repeat numberOfStackableEffect dup effectCountPtr, effectCount.cnt if effectCountPtr < numberOfStackableEffect { // - - - - - キー入力時に文字の周りに表示されるあれ - - - - - // color pos effectXof.cnt * 24 + firstEffectPosX, effectPosY gcopy effectCountPtr / 4 + effectType.cnt // - - - - - コンボ数表示 - - - - - // if missedCharIndex == 0xff { pos , comboEffectPosY - effectCountPtr color 225 -4 * effectCountPtr, 5 * effectCountPtr + 135, 0xe * effectCountPtr font _MSGothic, comboEffectHeadFontSize, fontTypeItalicBold mes currentCombo // - - - - - とスコア操作 - - - - - // foo++ score += foo } effectCountPtr++ } loop } if totalStatus == onJustCheckingResult { //------------------------- onJustCheckingResult --------------------------// if score > hiscore : if replay : else : hiscore = score infoValue = numberOfTrueType, numberOfMiss, score, hiscore font _MSGothic, 24, 17 color feedCount++ repeat 4 if( feedCount / 16 > cnt ) { pos 240, cnt * 32 + 156 mes infoType.cnt + ": " + infoValue.cnt } loop if differentTimeMilliSeconds & 0x100 { pos confirmRetryPosX, confirmRetryPosY mes "Retry? Y/N" } if feedCount > 64 { dim startable if key { dim totalStatus startable++ } if pressedKeyCode == 'N' { totalStatus-- replay++ gosub*_initializeVariable randomize seed gosub*__initializeVariable } } } dim pressedKeyCode goto*main //--------------------------------------------------------------------------------------------------- // // ラベル群 // 主に軽量化のためにここにまとめとく // //--------------------------------------------------------------------------------------------------- *_initializeVariable dim effectCount, 16 memset effectCount, 1, 64 missedCharIndex = 0xff dim currentCombo dim numberOfMiss dim numberOfTrueType dim score oldTimeSeconds = getTime( 6 ) oldTimeMilliSeconds = getTime( 7 ) wait 3 randomize oldTimeMilliSeconds dim replayWriteIndex dim nowReplayIndex dim feedCount dim clearedTask _differentTimeSeconds = 59 differentTimeSeconds = 59 *__initializeVariable nowTask = rnd( 100 ) nextTask = rnd( 100 ) dup taskScriptNowTask, taskScript.nowTask return *onKeyPressed pressedKeyCode = wparam return