このサンプルでは以下の処理を行っています。
- 結果フレーム表示、クリアか失敗の表示、グラフ表示、ランク表示、ベスト更新をステートで管理
- 結果画面が開始されたらフレームアニメーションを開始する
- クリアか失敗のアニメ
- 各種ゲージグラフや数値などを表示
- ランクアニメ
- 順位やランクリスト、今回の追加ポイント数(通信プレイ時のみ)
- ランキング更新(更新された場合のみ表示する)
- フェードアウトして結果画面を終了する
RSST_START = 0;
RSST_RESULT = 1;
RSST_RESULT_WAIT = 2;
RSST_RESSTR = 3;
RSST_RESSTR_WAIT = 4;
RSST_UPD_BEST = 5;
RSST_UPD_WAIT = 6;
RSST_END = 7;
rs_pid_add_point = 0;
rs_pid_num_addpoint = 1;
rs_pid_num_rank = 2;
rs_pid_num_rank2 = 3;
rs_pid_num_sabun_minus = 4;
rs_pid_num_sabun_plus = 5;
rs_pid_num_score = 6;
rs_pid_rankfrm_01 = 7;
rs_pid_rankfrm_02 = 8;
rs_pid_rankfrm_03 = 9;
rs_pid_rankfrm_04 = 10;
rs_pid_sabun = 11;
rs_pid_sabun_minus = 12;
rs_pid_sabun_plus = 13;
rs_pid_scorebest_minus = 14;
rs_pid_scorebest_num = 15;
rs_pid_scorebest_plus = 16;
g_dwResState = RSST_START;
g_iResAlphaCount = 0;
g_iResGaugeGraphCount = -1;
g_iResExScoreGraphCount = -1;
g_iResNewRecordCount = -1;
g_iResNetRankCount = -1;
function OnStartResult()
game_info = hdxGetGameInfo();
result = hdxGetResult();
g_dwResState = RSST_START;
g_iResAlphaCount = 0;
g_iResGaugeGraphCount = -1;
g_iResExScoreGraphCount = -1;
g_iResNewRecordCount = -1;
g_iResNetRankCount = -1;
hdxLoadImage( 0,"res_object.tga" );
hdxSetPutRange( rs_pid_add_point ,0,464,160,350,28,0,0 );
hdxSetPutRange( rs_pid_num_addpoint ,0,8,288,240,30,0,0 );
hdxSetPutRange( rs_pid_num_rank ,0,838,160,168,20,0,0 );
hdxSetPutRange( rs_pid_num_rank2 ,0,8,160,432,50,0,0 );
hdxSetPutRange( rs_pid_num_sabun_minus ,0,344,260,312,30,0,0 );
hdxSetPutRange( rs_pid_num_sabun_plus ,0,8,234,312,30,0,0 );
hdxSetPutRange( rs_pid_num_score ,0,464,212,408,24,0,0 );
hdxSetPutRange( rs_pid_rankfrm_01 ,0,8,8,234,128,0,0 );
hdxSetPutRange( rs_pid_rankfrm_02 ,0,266,8,234,128,0,0 );
hdxSetPutRange( rs_pid_rankfrm_03 ,0,524,8,234,128,0,0 );
hdxSetPutRange( rs_pid_rankfrm_04 ,0,782,8,234,128,0,0 );
hdxSetPutRange( rs_pid_sabun ,0,896,204,44,26,0,0 );
hdxSetPutRange( rs_pid_sabun_minus ,0,272,288,26,30,0,0 );
hdxSetPutRange( rs_pid_sabun_plus ,0,964,204,26,30,0,0 );
hdxSetPutRange( rs_pid_scorebest_minus ,0,992,258,24,28,0,0 );
hdxSetPutRange( rs_pid_scorebest_num ,0,680,260,288,28,0,0 );
hdxSetPutRange( rs_pid_scorebest_plus ,0,992,310,24,28,0,0 );
hdxLoadAnime( 0,"res_bg.hda" );
hdxCtrlAnime( 0,CTRLMODE_AUTO_LOOP,0,40,-1 );
if( game_info["gmode"]==GAMEMODE_EXPERT ||
game_info["gmode"]==GAMEMODE_CLASS ||
game_info["opt_difficult"]==OPTDIFFICULT_HARD ) then
hdxLoadAnime( 1,"res_frame2.hda" );
else
hdxLoadAnime( 1,"res_frame1.hda" );
end
hdxCtrlAnime( 1,CTRLMODE_AUTO_END,0,0,35 );
if( result["clear"]==TRUE ) then
hdxLoadAnime( 2,"res_clear.hda" );
else
hdxLoadAnime( 2,"res_failed.hda" );
end
hdxCtrlAnime( 2,CTRLMODE_MANUAL,-1,0,-1 );
hdxLoadAnime( 3,"res_djlevel_"..result["rank"]..".hda" );
hdxCtrlAnime( 3,CTRLMODE_MANUAL,-1,0,-1 );
hdxLoadAnime( 4,"res_djlevel_small.hda" );
hdxCtrlAnime( 4,CTRLMODE_MANUAL,-1,0,-1 );
hdxLoadAnime( 5,"res_djlevel_normal.hda" );
hdxCtrlAnime( 5,CTRLMODE_MANUAL,-1,0,-1 );
hdxLoadAnime( 6,"res_fadeout.hda" );
hdxCtrlAnime( 6,CTRLMODE_MANUAL,-1,0,-1 );
hdxLoadAnime( 10,"res_rank_frm.hda" );
hdxCtrlAnime( 10,CTRLMODE_MANUAL,-1,0,-1 );
hdxLoadAnime( 11,"res_rank_list.hda" );
hdxCtrlAnime( 11,CTRLMODE_MANUAL,-1,0,-1 );
hdxCreateFont( 0, "メイリオ", 30, result["title"], 0xFFFFFFFF, 0xFFF080FF, 1, 0xFF000000 );
for i=0,result["ranking_count"]-1 do
hdxCreateFont( i+10, "メイリオ", 24, result["ranking_nickname"..i], 0xFFFFFF, 0xFFFFFF, 1, 0x360086 );
trace( "["..i.."] "..result["ranking_nickname"..i] );
end
if( result["clear"]==TRUE ) then
hdxLoadSound( 0,"res_clear.wav" );
else
hdxLoadSound( 0,"res_failed.wav" );
end
hdxPlaySound( 0,FALSE );
end
function OnRunResult( upd_frm )
local result = hdxGetResult();
if( g_dwResState==RSST_START ) then
if( hdxIsEndAnime(1)==TRUE ) then
hdxCtrlAnime( 2,CTRLMODE_AUTO_END,0,0,-1 );
g_iResGaugeGraphCount = 0;
g_iResExScoreGraphCount = 0;
g_dwResState = RSST_RESULT;
end
elseif( g_dwResState==RSST_RESULT ) then
if( hdxIsEndAnime(2)==TRUE ) then
g_dwResState = RSST_RESULT_WAIT;
end
elseif( g_dwResState==RSST_RESULT_WAIT ) then
elseif( g_dwResState==RSST_RESSTR ) then
if( hdxIsEndAnime(1)==TRUE ) then
g_dwResState = RSST_RESSTR_WAIT;
end
elseif( g_dwResState==RSST_RESSTR_WAIT ) then
elseif( g_dwResState==RSST_UPD_BEST ) then
if( hdxIsEndAnime(1)==TRUE ) then
g_dwResState = RSST_UPD_WAIT;
end
elseif( g_dwResState==RSST_UPD_WAIT ) then
elseif( g_dwResState==RSST_END ) then
if( hdxIsEndAnime(6)==TRUE ) then
trace( "結果画面終了" );
hdxNextScene();
end
end
if( upd_frm==TRUE ) then
if( g_iResGaugeGraphCount>=0 ) then
g_iResGaugeGraphCount = g_iResGaugeGraphCount + 1;
if( g_iResGaugeGraphCount>90 ) then
g_iResGaugeGraphCount = 90;
end
end
if( g_iResExScoreGraphCount>=0 ) then
g_iResExScoreGraphCount = g_iResExScoreGraphCount + 1;
if( g_iResExScoreGraphCount>90 ) then
g_iResExScoreGraphCount = 90;
end
end
if( g_iResNewRecordCount>=0 ) then
g_iResNewRecordCount = g_iResNewRecordCount + 1;
if( g_iResNewRecordCount>5 ) then
g_iResNewRecordCount = 5;
end
end
if( g_iResNetRankCount>=0 ) then
g_iResNetRankCount = g_iResNetRankCount + 1;
if( g_iResNetRankCount>15 ) then
g_iResNetRankCount = 15;
end
end
end
hdxDrawAnime( 0, 0, 0, 1.0, 1.0 );
hdxDrawAnime( 1, 0, 0, 1.0, 1.0 );
if( g_dwResState>=RSST_RESULT ) then
g_iResAlphaCount = g_iResAlphaCount + 1;
if( g_iResAlphaCount>15 ) then
g_iResAlphaCount = 15;
end
local alpha = g_iResAlphaCount / 15.0;
hdxPutInt( rs_pid_num_score, 447, 363, result["score"], alpha, ALIGNTYPE_RIGHTBOTTOM );
hdxPutInt( rs_pid_num_score, 379, 400, result["total_notes"], alpha, ALIGNTYPE_RIGHTBOTTOM );
hdxPutInt( rs_pid_num_score, 379, 437, result["maxcombo"], alpha, ALIGNTYPE_RIGHTBOTTOM );
hdxPutInt( rs_pid_num_score, 345, 474, result["pkgreat"], alpha, ALIGNTYPE_RIGHTBOTTOM );
hdxPutInt( rs_pid_num_score, 345, 511, result["great"], alpha, ALIGNTYPE_RIGHTBOTTOM );
hdxPutInt( rs_pid_num_score, 345, 548, result["good"], alpha, ALIGNTYPE_RIGHTBOTTOM );
hdxPutInt( rs_pid_num_score, 345, 585, result["bad"], alpha, ALIGNTYPE_RIGHTBOTTOM );
hdxPutInt( rs_pid_num_score, 345, 622, result["poor"], alpha, ALIGNTYPE_RIGHTBOTTOM );
hdxPutInt( rs_pid_num_score, 412, 664, result["total_exscore"], alpha, ALIGNTYPE_RIGHTBOTTOM );
hdxPutInt( rs_pid_num_score, 1108, 372, result["exscore"], alpha, ALIGNTYPE_RIGHTBOTTOM );
hdxPutInt( rs_pid_num_score, 1108, 420, result["target_exscore"], alpha, ALIGNTYPE_RIGHTBOTTOM );
hdxPutInt( rs_pid_num_score, 1108, 469, result["best_exscore"], alpha, ALIGNTYPE_RIGHTBOTTOM );
hdxSetPutStatus( rs_pid_sabun, alpha, 1.0, 1.0, 0.0 );
hdxPut( rs_pid_sabun, 1180, 360 );
_resDrawNum4( 1148,393,result["exscore"]-result["target_exscore"],alpha );
_resDrawNum4( 1148,443,result["exscore"]-result["best_exscore"],alpha );
hdxCtrlAnime( 4, CTRLMODE_MANUAL, result["rank"], 0, -1 );
hdxDrawAnime( 4, 1071, 506, alpha, 1.0 );
local sz = hdxGetFontSize(0);
if( sz["width"]<484 ) then
hdxDrawFont( 0, 640, 595, alpha, ALIGNTYPE_CENTER );
else
hdxSetFilterMode( FILTER_LINEAR );
hdxDrawFontEx( 0, 398, 580, 484, 30, alpha );
hdxSetFilterMode( FILTER_POINT );
end
end
if( g_iResGaugeGraphCount>=0 ) then
hdxSetViewport( 43, 38, 460, 260 );
hdxDrawResultGraph( GRAPHTYPE_GAUGE, 43, 38, 460, 260, g_iResGaugeGraphCount/90.0, 0, 6, 0x009230, 0xFF003E );
end
if( g_iResExScoreGraphCount>=0 ) then
hdxSetViewport( 0, 0, 0, 0 );
hdxDrawResultGraph( GRAPHTYPE_TARGET_EXSCORE, 785, 49, 430, 240, g_iResExScoreGraphCount/90.0, 0, 4, 0xFF3073, 0xFF3073 );
hdxDrawResultGraph( GRAPHTYPE_BEST_EXSCORE, 785, 49, 430, 240, g_iResExScoreGraphCount/90.0, 0, 4, 0x149B5B, 0x149B5B );
hdxDrawResultGraph( GRAPHTYPE_EXSCORE, 785, 49, 430, 240, g_iResExScoreGraphCount/90.0, 0, 4, 0x00F0FF, 0x00F0FF );
end
if( g_iResNewRecordCount>=0 ) then
local alpha = g_iResNewRecordCount / 5;
hdxCtrlAnime( 5,CTRLMODE_MANUAL,result["best_rank"],0,-1 );
hdxDrawAnime( 5, 202, 156, alpha, 1.0 );
hdxCtrlAnime( 5,CTRLMODE_MANUAL,result["rank"],0,-1 );
hdxDrawAnime( 5, 360, 156, alpha, 1.0 );
hdxPutInt( rs_pid_scorebest_num, 192, 226, result["best_exscore"], alpha, ALIGNTYPE_CENTER );
hdxPutInt( rs_pid_scorebest_num, 373, 226, result["exscore"], alpha, ALIGNTYPE_CENTER );
_resDrawCenterNum( 279, 273, result["exscore"]-result["best_exscore"] , alpha );
end
if( g_iResNetRankCount>=0 ) then
hdxDrawAnime2( 10, 1070, 620, 1.0, 1.0, "_resDrawRank" );
hdxDrawAnime2( 11, 771, 38, 1.0, 1.0, "_resDrawRankList" );
local alpha = g_iResNetRankCount / 15;
hdxSetPutStatus( rs_pid_add_point, alpha, 1, 1, 0 );
hdxPut( rs_pid_add_point, 550, 642 );
hdxPutInt( rs_pid_num_addpoint, 588, 638, result["add_point"], alpha, ALIGNTYPE_LEFTTOP );
local user_info = hdxGetUserInfo();
hdxPutInt( rs_pid_num_rank, 892, 668, user_info["point"], alpha, ALIGNTYPE_RIGHTBOTTOM );
end
hdxDrawAnime( 2, 640, 188, 1.0, 1.0 );
hdxDrawAnime( 3, 0, 0, 1.0, 1.0 );
hdxDrawAnime( 6, 0, 0, 1.0, 1.0 );
end
function _resDrawNum4( x,y,num,alpha )
local pid;
if( num<0 ) then
hdxPut( rs_pid_sabun_minus,x,y );
num = -num;
pid = rs_pid_num_sabun_minus;
else
hdxPut( rs_pid_sabun_plus,x,y );
pid = rs_pid_num_sabun_plus;
end
hdxPutInt( pid, x+22+20*0, y, (num/1000)%10, alpha, ALIGNTYPE_LEFTTOP );
hdxPutInt( pid, x+22+20*1, y, (num/100 )%10, alpha, ALIGNTYPE_LEFTTOP );
hdxPutInt( pid, x+22+20*2, y, (num/10 )%10, alpha, ALIGNTYPE_LEFTTOP );
hdxPutInt( pid, x+22+20*3, y, (num/1 )%10, alpha, ALIGNTYPE_LEFTTOP );
end
function _resDrawCenterNum( x,y,num,alpha )
local minus = FALSE;
if( num<0 ) then
num = -num;
minus = TRUE;
end
local keta = 1;
local num2 = num;
while num2>=10 do
keta = keta + 1;
num2 = math.floor(num2 / 10);
end
local w = (1 + keta) * 24;
x = x - w / 2;
y = y - 28 / 2;
if( minus==TRUE ) then
hdxSetPutStatus( rs_pid_scorebest_minus, alpha, 1, 1, 0 );
hdxPut( rs_pid_scorebest_minus, x, y );
else
hdxSetPutStatus( rs_pid_scorebest_plus, alpha, 1, 1, 0 );
hdxPut( rs_pid_scorebest_plus, x, y );
end
x = x + 24;
hdxPutInt( rs_pid_scorebest_num, x, y, num, alpha, ALIGNTYPE_LEFTTOP );
end
function _resDrawRank( layer,x,y,frm_x,frm_y,frm_sx,frm_sy,frm_alpha,frm_rot )
if( layer==0 ) then
local result = hdxGetResult();
local frm_id;
if( result["current_ranking"]==1 ) then
frm_id = rs_pid_rankfrm_01;
elseif( result["current_ranking"]==2 ) then
frm_id = rs_pid_rankfrm_02;
elseif( result["current_ranking"]==3 ) then
frm_id = rs_pid_rankfrm_03;
else
frm_id = rs_pid_rankfrm_04;
end
hdxSetPutStatus( frm_id, frm_alpha, frm_sx, frm_sy, frm_rot );
hdxPut( frm_id, x+frm_x-110, y+frm_y-57 );
hdxPutInt( rs_pid_num_rank2, x+frm_x, y+frm_y+20, result["current_ranking"], frm_alpha, ALIGNTYPE_CENTER );
return TRUE;
end
return FALSE;
end
function _resDrawRankList( layer,x,y,frm_x,frm_y,frm_sx,frm_sy,frm_alpha,frm_rot )
if( layer==1 ) then
local result = hdxGetResult();
for i=0,result["ranking_count"]-1 do
hdxPutInt( rs_pid_num_rank, x+frm_x+41, y+frm_y+44+i*22, result["ranking_num"..i], frm_alpha, ALIGNTYPE_CENTER );
hdxSetViewport( x+frm_x+61, y+frm_y+32, 280, 219 );
hdxDrawFont( i+10, x+frm_x+70, y+frm_y+30+i*22, frm_alpha, ALIGNTYPE_LEFTTOP );
hdxSetViewport( 0, 0, 0, 0 );
hdxPutInt( rs_pid_num_rank, x+frm_x+430, y+frm_y+54+i*22, result["ranking_exscore"..i], frm_alpha, ALIGNTYPE_RIGHTBOTTOM );
end
return TRUE;
end
return FALSE;
end
function OnEndResult()
local result = hdxGetResult();
if( g_dwResState==RSST_RESULT_WAIT ) then
hdxCtrlAnime( 1,CTRLMODE_AUTO_END,40,40,50 );
hdxCtrlAnime( 2,CTRLMODE_MANUAL,-1,0,-1 );
hdxCtrlAnime( 3,CTRLMODE_AUTO_END,0,0,-1 );
trace( "今回のランク : "..result["current_ranking"] );
if( result["current_ranking"]>0 ) then
g_iResNetRankCount = 0;
hdxCtrlAnime( 10,CTRLMODE_AUTO_END,0,0,-1 );
hdxCtrlAnime( 11,CTRLMODE_AUTO_END,0,0,-1 );
end
g_dwResState = RSST_RESSTR;
elseif( g_dwResState==RSST_RESSTR_WAIT ) then
if( result["best_exscore"]<result["exscore"] ) then
trace( "ベストスコア表示開始" );
hdxCtrlAnime( 1,CTRLMODE_AUTO_END,60,60,-1 );
hdxCtrlAnime( 3,CTRLMODE_MANUAL,-1,0,-1 );
g_iResGaugeGraphCount = -1;
g_iResNewRecordCount = 0;
g_dwResState = RSST_UPD_BEST;
else
trace( "ベストスコア更新ではないので終了" );
hdxCtrlAnime( 6,CTRLMODE_AUTO_END,0,0,-1 );
g_dwResState = RSST_END;
end
elseif( g_dwResState==RSST_UPD_WAIT ) then
hdxCtrlAnime( 6,CTRLMODE_AUTO_END,0,0,-1 );
g_dwResState = RSST_END;
end
end