; e3dhsp.dll test script #include "e3dhsp3.as" #module #deffunc waitbyfps int p1, var fps E3DWaitbyFPS@ p1, fps await 0 return #global dim keybuf, 256 screenw = 640 : screenh = 480 screen 0, screenw, screenh, 1 pointmax = 100 title "Easy3D for HSP3 sample" ;開発中は下の行のコメントアウトを外すことを推奨します。 ;E3DEnableDbgFile ;初期化 E3DInit 0, -1, 0, 16, 0, scid1 ;file のpath 用のバッファーの作成 pathlen = 2048 sdim mediadir, pathlen mediadir = dir_cur + "\\Media" sdim pathbuf, pathlen, 4 ; 音ファイルの読み込み pathbuf.0 = mediadir + "\\canyon.mid" pathbuf.1 = mediadir + "\\d_bang.wav" pathbuf.2 = mediadir + "\\sbounce.wav" pathbuf.3 = mediadir + "\\score.wav" E3DLoadSound pathbuf.0, soundid0 E3DLoadSound pathbuf.1, soundid1 E3DLoadSound pathbuf.2, soundid2 E3DLoadSound pathbuf.3, soundid3 ;BGM のループの設定と再生 E3DSetSoundLoop soundid0, 1 E3DPlaySound soundid0, 1 ;E3DSetSoundLoop soundid3, 1 volume = 0 tempo = 1.0 soundcnt = 0 *main ; keybuf変数は、メインループの外で、dim keybuf, 256 として、確保しておいてください。 E3DGetKeyboardState keybuf if keybuf.VK_ESCAPE = 1 : goto *bye ; [ESC]で終了 gosub *PlaySound E3DBeginScene scid1 gosub *DrawText E3DEndScene E3DPresent scid1 waitbyfps 100, chkfps1 goto *main *bye E3DBye end *PlaySound ; キーを押し続けた場合などに、音が重なって再生されないように、 ; キー5回に1回の割合で、音が、再生されるようにする。 ; この処理をしない場合は、同じ音が重なって、高音がつぶれたような音で聞こえてしまうので、 ; 注意してくださいませーー。 soundcnt += 1 divval = soundcnt / 5 restval = soundcnt - ( divval * 5 ) if ( restval = 0 ) { if keybuf.'Q' = 1 : E3DPlaySound soundid1, 0, DMUS_SEGF_GRID if keybuf.'W' = 1 : E3DPlaySound soundid2, 0, DMUS_SEGF_GRID if keybuf.'E' = 1 : E3DPlaySound soundid3, 0, DMUS_SEGF_GRID ;if keybuf.'R' = 1 : E3DStopSound soundid3 } ; 音量の変更 volumeflag = 0 if ( keybuf.'O' = 1 ) { volume += 10 if volume > 1000 : volume = 1000 volumeflag = 1 } if ( keybuf.'P' = 1 ) { volume -= 10 if volume < -10000 : volume = -10000 volumeflag = 1 } if volumeflag = 1 : E3DSetSoundVolume volume ; テンポの変更 tempoflag = 0 if ( keybuf.'K' = 1 ) { tempo += 0.05 if tempo > 10.0 : tempo = 10.0 tempoflag = 1 } if ( keybuf.'L' = 1 ) { tempo -= 0.05 if tempo < 0.01 : tempo = 0.01 tempoflag = 1 } if tempoflag = 1 : E3DSetSoundTempo tempo return *DrawText textr = 0 : textg = 255 : textb = 0 textscale = 1 textposx = 10 : textposy = 60 strchk1 = "chkFPS1 " + chkfps1 E3DDrawText textposx, textposy, textscale, textr, textg, textb, strchk1 textposx = 10 : textposy = 80 strchk2 = "volume " + volume + " tempo " + tempo E3DDrawText textposx, textposy, textscale, textr, textg, textb, strchk2 textposx = 10 : textposy = 120 strchk3 = "d_band.wav <-- Push Q key" E3DDrawText textposx, textposy, textscale, textr, textg, textb, strchk3 textposx = 10 : textposy = 140 strchk4 = "sbounce.wav <-- Push W key" E3DDrawText textposx, textposy, textscale, textr, textg, textb, strchk4 textposx = 10 : textposy = 160 strchk5 = "score.wav <-- Push E key" E3DDrawText textposx, textposy, textscale, textr, textg, textb, strchk5 textposx = 10 : textposy = 200 strchk6 = " volume UP <--- Push O key volume DOWN <--- Push P key" E3DDrawText textposx, textposy, textscale, textr, textg, textb, strchk6 textposx = 10 : textposy = 220 strchk7 = " tempo UP <--- Push K key tempo DOWN <--- Push L key" E3DDrawText textposx, textposy, textscale, textr, textg, textb, strchk7 return