• R/O
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

X operations(XOPS)に非常に近いFPSゲームを制作・リメイクし、成果物をオープンソースとして公開することを目的としたプロジェクトです。


Commit MetaInfo

Revision221 (tree)
Time2019-05-25 09:57:58
Authorxops-mikan

Log Message

中央寄せによるテクスチャフォント描画を関数化

Change Summary

Incremental Difference

--- trunk/d3dgraphics-directx.cpp (revision 220)
+++ trunk/d3dgraphics-directx.cpp (revision 221)
@@ -1644,6 +1644,19 @@
16441644 End2DRender();
16451645 }
16461646
1647+//! @brief 中央寄せに文字を表示(テクスチャフォント使用)
1648+//! @param x x座標の加算分
1649+//! @param y y座標
1650+//! @param str 文字列 (改行コード:<b>不可</b>)
1651+//! @param color 色
1652+//! @param fontwidth 一文字の幅
1653+//! @param fontheight 一文字の高さ
1654+//! @attention 文字を二重に重ねて立体感を出さないと見にくくなります。
1655+void D3DGraphics::Draw2DTextureFontTextCenter(int x, int y, char *str, int color, int fontwidth, int fontheight)
1656+{
1657+ Draw2DTextureFontText((SCREEN_WIDTH - strlen(str)*fontwidth)/2 + x, y, str, color, fontwidth, fontheight);
1658+}
1659+
16471660 #ifdef ENABLE_DEBUGCONSOLE
16481661 //! @brief 文字を表示(デバック用フォント使用)
16491662 //! @param x x座標
--- trunk/d3dgraphics-opengl.cpp (revision 220)
+++ trunk/d3dgraphics-opengl.cpp (revision 221)
@@ -2518,6 +2518,19 @@
25182518 delete [] TexCoordAry;
25192519 }
25202520
2521+//! @brief 中央寄せに文字を表示(テクスチャフォント使用)
2522+//! @param x x座標の加算分
2523+//! @param y y座標
2524+//! @param str 文字列 (改行コード:<b>不可</b>)
2525+//! @param color 色
2526+//! @param fontwidth 一文字の幅
2527+//! @param fontheight 一文字の高さ
2528+//! @attention 文字を二重に重ねて立体感を出さないと見にくくなります。
2529+void D3DGraphics::Draw2DTextureFontTextCenter(int x, int y, char *str, int color, int fontwidth, int fontheight)
2530+{
2531+ Draw2DTextureFontText((SCREEN_WIDTH - strlen(str)*fontwidth)/2 + x, y, str, color, fontwidth, fontheight);
2532+}
2533+
25212534 #ifdef ENABLE_DEBUGCONSOLE
25222535 //! @brief 文字を表示(デバック用フォント使用)
25232536 //! @param x x座標
--- trunk/d3dgraphics.h (revision 220)
+++ trunk/d3dgraphics.h (revision 221)
@@ -301,6 +301,7 @@
301301 void Draw2DMSFontText(int x, int y, char *str, int color);
302302 void Draw2DMSFontTextCenter(int x, int y, int w, int h, char *str, int color);
303303 void Draw2DTextureFontText(int x, int y, char *str, int color, int fontwidth, int fontheight);
304+ void Draw2DTextureFontTextCenter(int x, int y, char *str, int color, int fontwidth, int fontheight);
304305 #ifdef ENABLE_DEBUGCONSOLE
305306 void Draw2DTextureDebugFontText(int x, int y, char *str, int color);
306307 #endif
--- trunk/gamemain.cpp (revision 220)
+++ trunk/gamemain.cpp (revision 221)
@@ -388,7 +388,7 @@
388388 sprintf(str, "%s project", GAMENAME);
389389 if( framecnt < (int)(1.5f*GAMEFPS) ){ effectA = GetEffectAlpha(framecnt, 1.0f, 1.0f, 0.5f, false); }
390390 if( framecnt > (int)(3.0f*GAMEFPS) ){ effectA = GetEffectAlpha(framecnt, 1.0f, 1.0f, 3.0f, true); }
391- d3dg->Draw2DTextureFontText(SCREEN_WIDTH/2 - strlen(str)*22/2, SCREEN_HEIGHT - 140, str, d3dg->GetColorCode(1.0f,1.0f,1.0f,effectA), 22, 22);
391+ d3dg->Draw2DTextureFontTextCenter(0, SCREEN_HEIGHT - 140, str, d3dg->GetColorCode(1.0f,1.0f,1.0f,effectA), 22, 22);
392392 }
393393
394394 //スタッフ名・その1
@@ -429,7 +429,7 @@
429429 if( framecnt < (int)(13.0f*GAMEFPS) ){ effectA = GetEffectAlpha(framecnt, 1.0f, 1.0f, 12.0f, false); }
430430 if( ((int)(15.0f*GAMEFPS) < framecnt)&&(framecnt < (int)(16.0f*GAMEFPS)) ){ effectA = GetEffectAlpha(framecnt, 1.0f, 1.0f, 15.0f, true); }
431431 if( framecnt >= (int)(16.0f*GAMEFPS) ){ effectA = 0.0f; }
432- d3dg->Draw2DTextureFontText(SCREEN_WIDTH/2 - strlen(str)*22/2, (SCREEN_HEIGHT-11)/2, str, d3dg->GetColorCode(1.0f,0.0f,0.0f,effectA), 22, 22);
432+ d3dg->Draw2DTextureFontTextCenter(0, (SCREEN_HEIGHT-11)/2, str, d3dg->GetColorCode(1.0f,0.0f,0.0f,effectA), 22, 22);
433433 }
434434 }
435435
@@ -1020,7 +1020,7 @@
10201020 //メモ:背景画像の描画は、自動的に行われる。
10211021
10221022 //固定文字表示
1023- d3dg->Draw2DTextureFontText(SCREEN_WIDTH/2 - 60*4, 30, "BRIEFING", d3dg->GetColorCode(1.0f,1.0f,0.0f,effectA), 60, 42);
1023+ d3dg->Draw2DTextureFontTextCenter(0, 30, "BRIEFING", d3dg->GetColorCode(1.0f,1.0f,0.0f,effectA), 60, 42);
10241024 d3dg->Draw2DTextureFontText(SCREEN_WIDTH - 210 - effectB_sizeW*20/2, SCREEN_HEIGHT - 37 - effectB_sizeH/2,
10251025 "LEFT CLICK TO BEGIN", d3dg->GetColorCode(1.0f,1.0f,1.0f,effectB), effectB_sizeW, effectB_sizeH);
10261026 d3dg->Draw2DTextureFontText(SCREEN_WIDTH - 210 - 18*20/2, SCREEN_HEIGHT - 37 - 26/2, "LEFT CLICK TO BEGIN", d3dg->GetColorCode(1.0f,1.0f,1.0f,1.0f), 18, 26);
@@ -1046,7 +1046,7 @@
10461046 else{
10471047 strcpy(mname, MIFdata.GetMissionFullname());
10481048 }
1049- d3dg->Draw2DTextureFontText(SCREEN_WIDTH/2 - strlen(mname)*18/2, 90, mname, d3dg->GetColorCode(1.0f,0.5f,0.0f,1.0f), 18, 25);
1049+ d3dg->Draw2DTextureFontTextCenter(0, 90, mname, d3dg->GetColorCode(1.0f,0.5f,0.0f,1.0f), 18, 25);
10501050
10511051 //ミッション説明を表示
10521052 d3dg->Draw2DMSFontText(230, 180, MIFdata.GetBriefingText(), d3dg->GetColorCode(1.0f,1.0f,1.0f,1.0f));
@@ -2382,14 +2382,14 @@
23822382
23832383 //リロード表示
23842384 if( reloadcnt > 0 ){
2385- d3dg->Draw2DTextureFontText(SCREEN_WIDTH/2 - 145 +3, SCREEN_HEIGHT - 180+3, "RELOADING", d3dg->GetColorCode(0.2f,0.2f,0.2f,1.0f), 32, 34);
2386- d3dg->Draw2DTextureFontText(SCREEN_WIDTH/2 - 145, SCREEN_HEIGHT - 180, "RELOADING", d3dg->GetColorCode(1.0f,1.0f,1.0f,1.0f), 32, 34);
2385+ d3dg->Draw2DTextureFontTextCenter(3, SCREEN_HEIGHT - 180+3, "RELOADING", d3dg->GetColorCode(0.2f,0.2f,0.2f,1.0f), 32, 34);
2386+ d3dg->Draw2DTextureFontTextCenter(0, SCREEN_HEIGHT - 180, "RELOADING", d3dg->GetColorCode(1.0f,1.0f,1.0f,1.0f), 32, 34);
23872387 }
23882388
23892389 //武器切り替え表示
23902390 if( selectweaponcnt > 0 ){
2391- d3dg->Draw2DTextureFontText(SCREEN_WIDTH/2 - 130 +3, SCREEN_HEIGHT - 180+3, "CHANGING", d3dg->GetColorCode(0.2f,0.2f,0.2f,1.0f), 32, 34);
2392- d3dg->Draw2DTextureFontText(SCREEN_WIDTH/2 - 130, SCREEN_HEIGHT - 180, "CHANGING", d3dg->GetColorCode(1.0f,1.0f,1.0f,1.0f), 32, 34);
2391+ d3dg->Draw2DTextureFontTextCenter(3, SCREEN_HEIGHT - 180+3, "CHANGING", d3dg->GetColorCode(0.2f,0.2f,0.2f,1.0f), 32, 34);
2392+ d3dg->Draw2DTextureFontTextCenter(0, SCREEN_HEIGHT - 180, "CHANGING", d3dg->GetColorCode(1.0f,1.0f,1.0f,1.0f), 32, 34);
23932393 }
23942394
23952395 //照準表示
@@ -2421,9 +2421,9 @@
24212421 d3dg->Draw2DLine(SCREEN_WIDTH/2, SCREEN_HEIGHT/2+13, SCREEN_WIDTH/2, SCREEN_HEIGHT/2+3, d3dg->GetColorCode(1.0f,0.0f,0.0f,1.0f));
24222422
24232423 stru[0] = 0xBD; stru[1] = '\0'; //"ス"
2424- d3dg->Draw2DTextureFontText(SCREEN_WIDTH/2 - 16 - ErrorRange, SCREEN_HEIGHT/2 - 16, (char*)stru, d3dg->GetColorCode(1.0f,0.0f,0.0f,0.5f), 32, 32);
2424+ d3dg->Draw2DTextureFontTextCenter(ErrorRange * -1, SCREEN_HEIGHT/2 - 16, (char*)stru, d3dg->GetColorCode(1.0f,0.0f,0.0f,0.5f), 32, 32);
24252425 stru[0] = 0xBE; stru[1] = '\0'; //"セ"
2426- d3dg->Draw2DTextureFontText(SCREEN_WIDTH/2 - 16 + ErrorRange, SCREEN_HEIGHT/2 - 16, (char*)stru, d3dg->GetColorCode(1.0f,0.0f,0.0f,0.5f), 32, 32);
2426+ d3dg->Draw2DTextureFontTextCenter(ErrorRange, SCREEN_HEIGHT/2 - 16, (char*)stru, d3dg->GetColorCode(1.0f,0.0f,0.0f,0.5f), 32, 32);
24272427 }
24282428 }
24292429 }
@@ -2433,8 +2433,8 @@
24332433 if( tag == true ){
24342434 int color;
24352435 if( ObjMgr.GetObjectInfoTag(camera_x, camera_y, camera_z, camera_rx, camera_ry, &color, str) == true ){
2436- d3dg->Draw2DTextureFontText(SCREEN_WIDTH/2 - strlen(str)*14/2 + 1, SCREEN_HEIGHT/2 + 30 +1 , str, d3dg->GetColorCode(0.0f,0.0f,0.0f,1.0f), 14, 18);
2437- d3dg->Draw2DTextureFontText(SCREEN_WIDTH/2 - strlen(str)*14/2, SCREEN_HEIGHT/2 + 30, str, color, 14, 18);
2436+ d3dg->Draw2DTextureFontTextCenter(1, SCREEN_HEIGHT/2 + 30 +1 , str, d3dg->GetColorCode(0.0f,0.0f,0.0f,1.0f), 14, 18);
2437+ d3dg->Draw2DTextureFontTextCenter(0, SCREEN_HEIGHT/2 + 30, str, color, 14, 18);
24382438 }
24392439 }
24402440
@@ -2546,10 +2546,10 @@
25462546 }
25472547
25482548 if( GameInfoData.missioncomplete == true ){
2549- d3dg->Draw2DTextureFontText(SCREEN_WIDTH/2 - 252, SCREEN_HEIGHT/2 + 10, "objective complete", d3dg->GetColorCode(1.0f,0.5f,0.0f,effect), 28, 32);
2549+ d3dg->Draw2DTextureFontTextCenter(0, SCREEN_HEIGHT/2 + 10, "objective complete", d3dg->GetColorCode(1.0f,0.5f,0.0f,effect), 28, 32);
25502550 }
25512551 else{
2552- d3dg->Draw2DTextureFontText(SCREEN_WIDTH/2 - 210, SCREEN_HEIGHT/2 + 10, "mission failure", d3dg->GetColorCode(1.0f,0.0f,0.0f,effect), 28, 32);
2552+ d3dg->Draw2DTextureFontTextCenter(0, SCREEN_HEIGHT/2 + 10, "mission failure", d3dg->GetColorCode(1.0f,0.0f,0.0f,effect), 28, 32);
25532553 }
25542554 }
25552555
@@ -3933,7 +3933,7 @@
39333933 //メモ:背景画像の描画は、自動的に行われる。
39343934
39353935 //固定文字表示
3936- d3dg->Draw2DTextureFontText(SCREEN_WIDTH/2 - 50*3, 40, "RESULT", d3dg->GetColorCode(1.0f,0.0f,1.0f,effectA), 50, 42);
3936+ d3dg->Draw2DTextureFontTextCenter(0, 40, "RESULT", d3dg->GetColorCode(1.0f,0.0f,1.0f,effectA), 50, 42);
39373937
39383938 //ミッション名を取得し表示
39393939 if( MIFdata.GetFiletype() == false ){
@@ -3942,27 +3942,27 @@
39423942 else{
39433943 strcpy(mname, MIFdata.GetMissionFullname());
39443944 }
3945- d3dg->Draw2DTextureFontText(SCREEN_WIDTH/2 - strlen(mname)*18/2, 100, mname, d3dg->GetColorCode(0.5f,0.5f,1.0f,1.0f), 18, 25);
3945+ d3dg->Draw2DTextureFontTextCenter(0, 100, mname, d3dg->GetColorCode(0.5f,0.5f,1.0f,1.0f), 18, 25);
39463946
39473947 //ミッションクリアーの有無
39483948 if( GameInfoData.missioncomplete == true ){
3949- d3dg->Draw2DTextureFontText(SCREEN_WIDTH/2 - 216, 150, "mission successful", d3dg->GetColorCode(0.0f,1.0f,0.0f,1.0f), 24, 32);
3949+ d3dg->Draw2DTextureFontTextCenter(0, 150, "mission successful", d3dg->GetColorCode(0.0f,1.0f,0.0f,1.0f), 24, 32);
39503950 }
39513951 else{
3952- d3dg->Draw2DTextureFontText(SCREEN_WIDTH/2 - 180, 150, "mission failure", d3dg->GetColorCode(1.0f,0.0f,0.0f,1.0f), 24, 32);
3952+ d3dg->Draw2DTextureFontTextCenter(0, 150, "mission failure", d3dg->GetColorCode(1.0f,0.0f,0.0f,1.0f), 24, 32);
39533953 }
39543954
39553955 //結果表示
39563956 sprintf(str, "Time %dmin %dsec", GameInfoData.framecnt/(int)GAMEFPS/60, GameInfoData.framecnt/(int)GAMEFPS%60);
3957- d3dg->Draw2DTextureFontText(SCREEN_WIDTH/2-strlen(str)*20/2, 210, str, d3dg->GetColorCode(1.0f,1.0f,1.0f,1.0f), 20, 32);
3957+ d3dg->Draw2DTextureFontTextCenter(0, 210, str, d3dg->GetColorCode(1.0f,1.0f,1.0f,1.0f), 20, 32);
39583958 sprintf(str, "Rounds fired %d", GameInfoData.fire);
3959- d3dg->Draw2DTextureFontText(SCREEN_WIDTH/2-strlen(str)*20/2, 260, str, d3dg->GetColorCode(1.0f,1.0f,1.0f,1.0f), 20, 32);
3959+ d3dg->Draw2DTextureFontTextCenter(0, 260, str, d3dg->GetColorCode(1.0f,1.0f,1.0f,1.0f), 20, 32);
39603960 sprintf(str, "Rounds on target %d", intontarget);
3961- d3dg->Draw2DTextureFontText(SCREEN_WIDTH/2-strlen(str)*20/2, 310, str, d3dg->GetColorCode(1.0f,1.0f,1.0f,1.0f), 20, 32);
3961+ d3dg->Draw2DTextureFontTextCenter(0, 310, str, d3dg->GetColorCode(1.0f,1.0f,1.0f,1.0f), 20, 32);
39623962 sprintf(str, "Accuracy rate %.1f%%", rate);
3963- d3dg->Draw2DTextureFontText(SCREEN_WIDTH/2-strlen(str)*20/2, 360, str, d3dg->GetColorCode(1.0f,1.0f,1.0f,1.0f), 20, 32);
3963+ d3dg->Draw2DTextureFontTextCenter(0, 360, str, d3dg->GetColorCode(1.0f,1.0f,1.0f,1.0f), 20, 32);
39643964 sprintf(str, "Kill %d / HeadShot %d", GameInfoData.kill, GameInfoData.headshot);
3965- d3dg->Draw2DTextureFontText(SCREEN_WIDTH/2-strlen(str)*20/2, 410, str, d3dg->GetColorCode(1.0f,1.0f,1.0f,1.0f), 20, 32);
3965+ d3dg->Draw2DTextureFontTextCenter(0, 410, str, d3dg->GetColorCode(1.0f,1.0f,1.0f,1.0f), 20, 32);
39663966 }
39673967
39683968 //! @brief screen派生クラスの初期化(クラスの設定)