X operations(XOPS)に非常に近いFPSゲームを制作・リメイクし、成果物をオープンソースとして公開することを目的としたプロジェクトです。
| Revision | 221 (tree) |
|---|---|
| Time | 2019-05-25 09:57:58 |
| Author | |
中央寄せによるテクスチャフォント描画を関数化
| @@ -1644,6 +1644,19 @@ | ||
| 1644 | 1644 | End2DRender(); |
| 1645 | 1645 | } |
| 1646 | 1646 | |
| 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 | + | |
| 1647 | 1660 | #ifdef ENABLE_DEBUGCONSOLE |
| 1648 | 1661 | //! @brief 文字を表示(デバック用フォント使用) |
| 1649 | 1662 | //! @param x x座標 |
| @@ -2518,6 +2518,19 @@ | ||
| 2518 | 2518 | delete [] TexCoordAry; |
| 2519 | 2519 | } |
| 2520 | 2520 | |
| 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 | + | |
| 2521 | 2534 | #ifdef ENABLE_DEBUGCONSOLE |
| 2522 | 2535 | //! @brief 文字を表示(デバック用フォント使用) |
| 2523 | 2536 | //! @param x x座標 |
| @@ -301,6 +301,7 @@ | ||
| 301 | 301 | void Draw2DMSFontText(int x, int y, char *str, int color); |
| 302 | 302 | void Draw2DMSFontTextCenter(int x, int y, int w, int h, char *str, int color); |
| 303 | 303 | 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); | |
| 304 | 305 | #ifdef ENABLE_DEBUGCONSOLE |
| 305 | 306 | void Draw2DTextureDebugFontText(int x, int y, char *str, int color); |
| 306 | 307 | #endif |
| @@ -388,7 +388,7 @@ | ||
| 388 | 388 | sprintf(str, "%s project", GAMENAME); |
| 389 | 389 | if( framecnt < (int)(1.5f*GAMEFPS) ){ effectA = GetEffectAlpha(framecnt, 1.0f, 1.0f, 0.5f, false); } |
| 390 | 390 | 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); | |
| 392 | 392 | } |
| 393 | 393 | |
| 394 | 394 | //スタッフ名・その1 |
| @@ -429,7 +429,7 @@ | ||
| 429 | 429 | if( framecnt < (int)(13.0f*GAMEFPS) ){ effectA = GetEffectAlpha(framecnt, 1.0f, 1.0f, 12.0f, false); } |
| 430 | 430 | if( ((int)(15.0f*GAMEFPS) < framecnt)&&(framecnt < (int)(16.0f*GAMEFPS)) ){ effectA = GetEffectAlpha(framecnt, 1.0f, 1.0f, 15.0f, true); } |
| 431 | 431 | 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); | |
| 433 | 433 | } |
| 434 | 434 | } |
| 435 | 435 |
| @@ -1020,7 +1020,7 @@ | ||
| 1020 | 1020 | //メモ:背景画像の描画は、自動的に行われる。 |
| 1021 | 1021 | |
| 1022 | 1022 | //固定文字表示 |
| 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); | |
| 1024 | 1024 | d3dg->Draw2DTextureFontText(SCREEN_WIDTH - 210 - effectB_sizeW*20/2, SCREEN_HEIGHT - 37 - effectB_sizeH/2, |
| 1025 | 1025 | "LEFT CLICK TO BEGIN", d3dg->GetColorCode(1.0f,1.0f,1.0f,effectB), effectB_sizeW, effectB_sizeH); |
| 1026 | 1026 | 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 @@ | ||
| 1046 | 1046 | else{ |
| 1047 | 1047 | strcpy(mname, MIFdata.GetMissionFullname()); |
| 1048 | 1048 | } |
| 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); | |
| 1050 | 1050 | |
| 1051 | 1051 | //ミッション説明を表示 |
| 1052 | 1052 | d3dg->Draw2DMSFontText(230, 180, MIFdata.GetBriefingText(), d3dg->GetColorCode(1.0f,1.0f,1.0f,1.0f)); |
| @@ -2382,14 +2382,14 @@ | ||
| 2382 | 2382 | |
| 2383 | 2383 | //リロード表示 |
| 2384 | 2384 | 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); | |
| 2387 | 2387 | } |
| 2388 | 2388 | |
| 2389 | 2389 | //武器切り替え表示 |
| 2390 | 2390 | 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); | |
| 2393 | 2393 | } |
| 2394 | 2394 | |
| 2395 | 2395 | //照準表示 |
| @@ -2421,9 +2421,9 @@ | ||
| 2421 | 2421 | 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)); |
| 2422 | 2422 | |
| 2423 | 2423 | 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); | |
| 2425 | 2425 | 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); | |
| 2427 | 2427 | } |
| 2428 | 2428 | } |
| 2429 | 2429 | } |
| @@ -2433,8 +2433,8 @@ | ||
| 2433 | 2433 | if( tag == true ){ |
| 2434 | 2434 | int color; |
| 2435 | 2435 | 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); | |
| 2438 | 2438 | } |
| 2439 | 2439 | } |
| 2440 | 2440 |
| @@ -2546,10 +2546,10 @@ | ||
| 2546 | 2546 | } |
| 2547 | 2547 | |
| 2548 | 2548 | 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); | |
| 2550 | 2550 | } |
| 2551 | 2551 | 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); | |
| 2553 | 2553 | } |
| 2554 | 2554 | } |
| 2555 | 2555 |
| @@ -3933,7 +3933,7 @@ | ||
| 3933 | 3933 | //メモ:背景画像の描画は、自動的に行われる。 |
| 3934 | 3934 | |
| 3935 | 3935 | //固定文字表示 |
| 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); | |
| 3937 | 3937 | |
| 3938 | 3938 | //ミッション名を取得し表示 |
| 3939 | 3939 | if( MIFdata.GetFiletype() == false ){ |
| @@ -3942,27 +3942,27 @@ | ||
| 3942 | 3942 | else{ |
| 3943 | 3943 | strcpy(mname, MIFdata.GetMissionFullname()); |
| 3944 | 3944 | } |
| 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); | |
| 3946 | 3946 | |
| 3947 | 3947 | //ミッションクリアーの有無 |
| 3948 | 3948 | 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); | |
| 3950 | 3950 | } |
| 3951 | 3951 | 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); | |
| 3953 | 3953 | } |
| 3954 | 3954 | |
| 3955 | 3955 | //結果表示 |
| 3956 | 3956 | 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); | |
| 3958 | 3958 | 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); | |
| 3960 | 3960 | 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); | |
| 3962 | 3962 | 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); | |
| 3964 | 3964 | 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); | |
| 3966 | 3966 | } |
| 3967 | 3967 | |
| 3968 | 3968 | //! @brief screen派生クラスの初期化(クラスの設定) |