X operations(XOPS)に非常に近いFPSゲームを制作・リメイクし、成果物をオープンソースとして公開することを目的としたプロジェクトです。
| Revision | 127 (tree) |
|---|---|
| Time | 2016-03-21 19:30:38 |
| Author | |
銃弾と手榴弾(オブジェクト)のリソース管理を改善
| @@ -39,6 +39,7 @@ | ||
| 39 | 39 | #define TOTAL_HUMANTEXTURE 30 //!< 人のテクスチャの合計枚数 |
| 40 | 40 | #define TOTAL_PARAMETERINFO_WEAPON 23 //!< 武器の設定数 |
| 41 | 41 | #define TOTAL_PARAMETERINFO_SMALLOBJECT 12 //!< 小物の設定数 |
| 42 | +#define TOTAL_PARAMETERINFO_BULLET 2 //!< 銃弾オブジェクトの設定数 | |
| 42 | 43 | #define TOTAL_OFFICIALMISSION 58 //!< 標準ミッションの数 |
| 43 | 44 | #define TOTAL_PARAMETERINFO_AILEVEL 6 //!< AIレベルの設定数 |
| 44 | 45 |
| @@ -46,6 +47,8 @@ | ||
| 46 | 47 | #define ID_WEAPON_GRENADE 13 //!< 手榴弾として取り扱う武器番号 |
| 47 | 48 | #define ID_WEAPON_CASE 15 //!< ケースとして取り扱う武器番号 |
| 48 | 49 | |
| 50 | +#define SMALLOBJECT_SCALE 5.0f //!< 小物の表示倍率 | |
| 51 | + | |
| 49 | 52 | #ifndef H_LAYERLEVEL |
| 50 | 53 | #define H_LAYERLEVEL 1 //!< Select include file. |
| 51 | 54 | #endif |
| @@ -107,6 +110,13 @@ | ||
| 107 | 110 | int jump; //!< 飛び具合 |
| 108 | 111 | }; |
| 109 | 112 | |
| 113 | +//! 銃弾オブジェクト用の構造体 | |
| 114 | +struct BulletParameter{ | |
| 115 | + char *model; //!< モデル名 | |
| 116 | + char *texture; //!< テクスチャ名 | |
| 117 | + float size; //!< 表示倍率 | |
| 118 | +}; | |
| 119 | + | |
| 110 | 120 | //! AIレベルによる設定(性能値)用構造体 |
| 111 | 121 | struct AIParameter{ |
| 112 | 122 | int aiming; //!< エイミング能力 |
| @@ -124,6 +134,7 @@ | ||
| 124 | 134 | char *HumanTexturePath[TOTAL_HUMANTEXTURE]; //!< 人のテクスチャを格納するポインタ |
| 125 | 135 | WeaponParameter *Weapon; //!< 武器の情報を格納するポインタ |
| 126 | 136 | SmallObjectParameter *SmallObject; //!< 小物の情報を格納するポインタ |
| 137 | + BulletParameter *Bullet; //!< 銃弾オブジェクトの情報を格納するポインタ | |
| 127 | 138 | char *missionname[TOTAL_OFFICIALMISSION]; //!< 標準ミッションのミッション識別名 |
| 128 | 139 | char *missionfullname[TOTAL_OFFICIALMISSION]; //!< 標準ミッションのミッション正式名称 |
| 129 | 140 | char *missiondirectory[TOTAL_OFFICIALMISSION]; //!< 標準ミッションのデータディレクトリ |
| @@ -139,6 +150,7 @@ | ||
| 139 | 150 | int GetHumanTexturePath(int id, char *out_str); |
| 140 | 151 | int GetWeapon(int id, WeaponParameter *out_data); |
| 141 | 152 | int GetSmallObject(int id, SmallObjectParameter *out_data); |
| 153 | + int GetBullet(int id, BulletParameter *out_data); | |
| 142 | 154 | int GetOfficialMission(int id, char *name, char *fullname, char* directory, char *txt); |
| 143 | 155 | int GetAIlevel(int level, AIParameter **out_AIlevel); |
| 144 | 156 | }; |
| @@ -66,12 +66,12 @@ | ||
| 66 | 66 | int smallobject_model[TOTAL_PARAMETERINFO_SMALLOBJECT+1]; //!< 小物のモデル認識番号 |
| 67 | 67 | int smallobject_texture[TOTAL_PARAMETERINFO_SMALLOBJECT+1]; //!< 小物のテクスチャ認識番号 |
| 68 | 68 | int smallobject_sound[TOTAL_PARAMETERINFO_SMALLOBJECT+1]; //!< 小物のサウンド認識番号 |
| 69 | + int bullet_model[TOTAL_PARAMETERINFO_BULLET]; //!< 弾のモデル | |
| 70 | + int bullet_texture[TOTAL_PARAMETERINFO_BULLET]; //!< 弾のテクスチャ | |
| 69 | 71 | |
| 70 | 72 | int scopetexture; //!< スコープのテクスチャ |
| 71 | 73 | int skymodel; //!< 空背景のモデル |
| 72 | 74 | int skytexture; //!< 空背景のテクスチャ |
| 73 | - int bulletmodel; //!< 弾のモデル | |
| 74 | - int bullettexture; //!< 弾のテクスチャ | |
| 75 | 75 | int bullet_hitsoundA; //!< 弾のヒットサウンド(A) |
| 76 | 76 | int bullet_hitsoundB; //!< 弾のヒットサウンド(B) |
| 77 | 77 | int bullet_humanhitsound; //!< 弾のヒットサウンド(人) |
| @@ -108,6 +108,9 @@ | ||
| 108 | 108 | int LoadSmallObjectSound(); |
| 109 | 109 | int GetSmallObjectSound(int id); |
| 110 | 110 | int LoadAddSmallObject(char *modelpath, char *texturepath, char *soundpath); |
| 111 | + int LoadBulletModelTexture(); | |
| 112 | + int GetBulletModelTexture(int id, int *model, int *texture); | |
| 113 | + void CleanupBulletModelTexture(); | |
| 111 | 114 | |
| 112 | 115 | int LoadScopeTexture(); |
| 113 | 116 | int GetScopeTexture(); |
| @@ -115,9 +118,6 @@ | ||
| 115 | 118 | int LoadSkyModelTexture(int id); |
| 116 | 119 | void GetSkyModelTexture(int *model, int *texture); |
| 117 | 120 | void CleanupSkyModelTexture(); |
| 118 | - int LoadBulletModelTexture(); | |
| 119 | - void GetBulletModelTexture(int *model, int *texture); | |
| 120 | - void CleanupBulletModelTexture(); | |
| 121 | 121 | int LoadBulletSound(); |
| 122 | 122 | void GetBulletSound(int *hitsoundA, int *hitsoundB, int *humanhitsound, int *passingsound, int *grenadebang, int *grenadecco); |
| 123 | 123 | int LoadEffectTexture(); |
| @@ -40,9 +40,6 @@ | ||
| 40 | 40 | #define MAX_GRENADE 32 //!< 手榴弾の最大数 |
| 41 | 41 | #define MAX_EFFECT 256 //!< エフェクトの最大数 |
| 42 | 42 | |
| 43 | -#define SMALLOBJECT_SCALE 5.0f //!< 小物の表示倍率 | |
| 44 | -#define BULLET_SCALE 1.0f //!< 銃弾の表示倍率 | |
| 45 | - | |
| 46 | 43 | #define WEAPONSHOT_HEIGHT (VIEW_HEIGHT) //!< 弾を発射する高さ |
| 47 | 44 | |
| 48 | 45 | #define TOTAL_WEAPON_AUTOBULLET 3 //!< 初期化時に自動的に補てんされる弾数(装弾数の何倍か) |
| @@ -43,6 +43,7 @@ | ||
| 43 | 43 | } |
| 44 | 44 | Weapon = NULL; |
| 45 | 45 | SmallObject = NULL; |
| 46 | + Bullet = NULL; | |
| 46 | 47 | for(int i=0; i<TOTAL_OFFICIALMISSION; i++){ |
| 47 | 48 | missionname[i] = '\0'; |
| 48 | 49 | missionfullname[i] = '\0'; |
| @@ -70,6 +71,7 @@ | ||
| 70 | 71 | Human = new HumanParameter[TOTAL_PARAMETERINFO_HUMAN]; |
| 71 | 72 | Weapon = new WeaponParameter[TOTAL_PARAMETERINFO_WEAPON]; |
| 72 | 73 | SmallObject = new SmallObjectParameter[TOTAL_PARAMETERINFO_SMALLOBJECT]; |
| 74 | + Bullet = new BulletParameter[TOTAL_PARAMETERINFO_BULLET]; | |
| 73 | 75 | AIlevel = new AIParameter[TOTAL_PARAMETERINFO_AILEVEL]; |
| 74 | 76 | |
| 75 | 77 | //特殊 黒 A |
| @@ -1273,6 +1275,16 @@ | ||
| 1273 | 1275 | SmallObject[11].jump = 7; |
| 1274 | 1276 | |
| 1275 | 1277 | |
| 1278 | + //銃弾オブジェクト | |
| 1279 | + Bullet[0].model = "./data/model/bullet.x"; | |
| 1280 | + Bullet[0].texture = "./data/model/bullet.bmp"; | |
| 1281 | + Bullet[0].size = 1.0f; | |
| 1282 | + //手榴弾オブジェクト | |
| 1283 | + Bullet[1].model = Weapon[ID_WEAPON_GRENADE].model; | |
| 1284 | + Bullet[1].texture = Weapon[ID_WEAPON_GRENADE].texture; | |
| 1285 | + Bullet[1].size = Weapon[ID_WEAPON_GRENADE].size; | |
| 1286 | + | |
| 1287 | + | |
| 1276 | 1288 | missionname[0] = "TRAINING YARD"; |
| 1277 | 1289 | missionfullname[0] = "TRAINING YARD training"; |
| 1278 | 1290 | missiondirectory[0] = "data\\map0\\"; |
| @@ -1559,6 +1571,10 @@ | ||
| 1559 | 1571 | delete [] SmallObject; |
| 1560 | 1572 | SmallObject = NULL; |
| 1561 | 1573 | } |
| 1574 | + if( Bullet != NULL ){ | |
| 1575 | + delete [] Bullet; | |
| 1576 | + Bullet = NULL; | |
| 1577 | + } | |
| 1562 | 1578 | if( AIlevel != NULL ){ |
| 1563 | 1579 | delete [] AIlevel; |
| 1564 | 1580 | AIlevel = NULL; |
| @@ -1619,6 +1635,18 @@ | ||
| 1619 | 1635 | return 0; |
| 1620 | 1636 | } |
| 1621 | 1637 | |
| 1638 | +//! @brief 銃弾オブジェクトの設定を取得 | |
| 1639 | +//! @param id 番号 | |
| 1640 | +//! @param out_data 受け取るBulletParameter型ポインタ | |
| 1641 | +//! @return 成功:0 失敗:1 | |
| 1642 | +int ParameterInfo::GetBullet(int id, BulletParameter *out_data) | |
| 1643 | +{ | |
| 1644 | + if( (id < 0)||((TOTAL_PARAMETERINFO_BULLET -1) < id ) ){ return 1; } | |
| 1645 | + | |
| 1646 | + *out_data = Bullet[id]; | |
| 1647 | + return 0; | |
| 1648 | +} | |
| 1649 | + | |
| 1622 | 1650 | //! @brief 標準ミッションを取得 |
| 1623 | 1651 | //! @param id 番号 |
| 1624 | 1652 | //! @param name ミッション識別名を受け取るポインタ (NULL可) |
| @@ -65,12 +65,14 @@ | ||
| 65 | 65 | smallobject_texture[i] = -1; |
| 66 | 66 | smallobject_sound[i] = -1; |
| 67 | 67 | } |
| 68 | + for(int i=0; i<TOTAL_PARAMETERINFO_BULLET; i++){ | |
| 69 | + bullet_model[i] = -1; | |
| 70 | + bullet_texture[i] = -1; | |
| 71 | + } | |
| 68 | 72 | |
| 69 | 73 | scopetexture = -1; |
| 70 | 74 | skymodel = -1; |
| 71 | 75 | skytexture = -1; |
| 72 | - bulletmodel = -1; | |
| 73 | - bullettexture = -1; | |
| 74 | 76 | bullet_hitsoundA = -1; |
| 75 | 77 | bullet_hitsoundB = -1; |
| 76 | 78 | bullet_humanhitsound = -1; |
| @@ -529,6 +531,58 @@ | ||
| 529 | 531 | return cnt; |
| 530 | 532 | } |
| 531 | 533 | |
| 534 | +//! @brief 弾のモデルとテクスチャを読み込む | |
| 535 | +//! @return 成功:0 失敗:1以上 | |
| 536 | +int ResourceManager::LoadBulletModelTexture() | |
| 537 | +{ | |
| 538 | + int cnt = 0; | |
| 539 | + | |
| 540 | + if( d3dg == NULL ){ return 1; } | |
| 541 | + | |
| 542 | + for(int i=0; i<TOTAL_PARAMETERINFO_BULLET; i++){ | |
| 543 | + BulletParameter data; | |
| 544 | + if( ParamInfo->GetBullet(i, &data) == 0 ){ | |
| 545 | + //モデルとテクスチャを読み込み、エラーが出ればカウントする。 | |
| 546 | + bullet_model[i] = d3dg->LoadModel(data.model); | |
| 547 | + bullet_texture[i] = d3dg->LoadTexture(data.texture, false, false); | |
| 548 | + if( bullet_model[i] == -1 ){ cnt += 1; } | |
| 549 | + if( bullet_texture[i] == -1 ){ cnt += 1; } | |
| 550 | + } | |
| 551 | + else{ | |
| 552 | + //設定データがおかしければ、モデルとテクスチャ 2つともエラー。 | |
| 553 | + cnt += 2; | |
| 554 | + } | |
| 555 | + } | |
| 556 | + | |
| 557 | + return cnt; | |
| 558 | +} | |
| 559 | + | |
| 560 | +//! @brief 弾のモデルとテクスチャを取得 | |
| 561 | +//! @return 成功:0 失敗:1 | |
| 562 | +int ResourceManager::GetBulletModelTexture(int id, int *model, int *texture) | |
| 563 | +{ | |
| 564 | + if( (id < 0)||((TOTAL_PARAMETERINFO_BULLET -1) < id ) ){ return 1; } | |
| 565 | + | |
| 566 | + *model = bullet_model[id]; | |
| 567 | + *texture = bullet_texture[id]; | |
| 568 | + | |
| 569 | + return 0; | |
| 570 | +} | |
| 571 | + | |
| 572 | +//! @brief 弾のモデルとテクスチャを解放 | |
| 573 | +void ResourceManager::CleanupBulletModelTexture() | |
| 574 | +{ | |
| 575 | + if( d3dg == NULL ){ return; } | |
| 576 | + | |
| 577 | + for(int i=0; i<TOTAL_PARAMETERINFO_BULLET; i++){ | |
| 578 | + d3dg->CleanupModel(bullet_model[i]); | |
| 579 | + bullet_model[i] = -1; | |
| 580 | + | |
| 581 | + d3dg->CleanupTexture(bullet_texture[i]); | |
| 582 | + bullet_texture[i] = -1; | |
| 583 | + } | |
| 584 | +} | |
| 585 | + | |
| 532 | 586 | //! @brief スコープテクスチャを読み込む |
| 533 | 587 | //! @return 成功:0 失敗:1 |
| 534 | 588 | int ResourceManager::LoadScopeTexture() |
| @@ -595,43 +649,6 @@ | ||
| 595 | 649 | skytexture = -1; |
| 596 | 650 | } |
| 597 | 651 | |
| 598 | -//! @brief 弾のモデルとテクスチャを読み込む | |
| 599 | -//! @return 成功:0 失敗:1 | |
| 600 | -int ResourceManager::LoadBulletModelTexture() | |
| 601 | -{ | |
| 602 | - if( d3dg == NULL ){ return 1; } | |
| 603 | - | |
| 604 | - bulletmodel = d3dg->LoadModel("data\\model\\bullet.x"); | |
| 605 | - bullettexture = d3dg->LoadTexture("data\\model\\bullet.bmp", false, false); | |
| 606 | - | |
| 607 | - if( bulletmodel == -1 ){ return 1; } | |
| 608 | - if( bullettexture == -1 ){ return 1; } | |
| 609 | - return 0; | |
| 610 | -} | |
| 611 | - | |
| 612 | -//! @brief 弾のモデルとテクスチャを取得 | |
| 613 | -//! @return 成功:0 失敗:1 | |
| 614 | -void ResourceManager::GetBulletModelTexture(int *model, int *texture) | |
| 615 | -{ | |
| 616 | - *model = bulletmodel; | |
| 617 | - *texture = bullettexture; | |
| 618 | -} | |
| 619 | - | |
| 620 | -//! @brief 弾のモデルとテクスチャを解放 | |
| 621 | -void ResourceManager::CleanupBulletModelTexture() | |
| 622 | -{ | |
| 623 | - if( d3dg == NULL ){ return; } | |
| 624 | - | |
| 625 | - if( bulletmodel != -1 ){ | |
| 626 | - d3dg->CleanupModel(bulletmodel); | |
| 627 | - bulletmodel = -1; | |
| 628 | - } | |
| 629 | - if( bullettexture == -1 ){ | |
| 630 | - d3dg->CleanupTexture(bullettexture); | |
| 631 | - bullettexture = -1; | |
| 632 | - } | |
| 633 | -} | |
| 634 | - | |
| 635 | 652 | //! @brief 弾・手榴弾のサウンドを読み込む |
| 636 | 653 | //! @return 成功:0 失敗:1 |
| 637 | 654 | int ResourceManager::LoadBulletSound() |
| @@ -112,26 +112,24 @@ | ||
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | int bulletmodel, bullettexture; |
| 115 | - Resource->GetBulletModelTexture(&bulletmodel, &bullettexture); | |
| 116 | - for(int i=0; i<MAX_BULLET; i++){ | |
| 117 | - BulletIndex[i].SetModel(bulletmodel, BULLET_SCALE); | |
| 118 | - BulletIndex[i].SetTexture(bullettexture); | |
| 119 | - } | |
| 115 | + BulletParameter data; | |
| 120 | 116 | |
| 121 | - int grenademodel, grenadetexture; | |
| 122 | - float model_size = 1.0f; | |
| 123 | - WeaponParameter ParamData; | |
| 124 | - | |
| 125 | - //リソースとモデルサイズを取得 | |
| 126 | - Resource->GetWeaponModelTexture(ID_WEAPON_GRENADE, &grenademodel, &grenadetexture); | |
| 127 | - if( GameParamInfo->GetWeapon(ID_WEAPON_GRENADE, &ParamData) == 0 ){ | |
| 128 | - model_size = ParamData.size; | |
| 117 | + if( Resource->GetBulletModelTexture(0, &bulletmodel, &bullettexture) == 0 ){ | |
| 118 | + if( GameParamInfo->GetBullet(0, &data) == 0 ){ | |
| 119 | + for(int i=0; i<MAX_BULLET; i++){ | |
| 120 | + BulletIndex[i].SetModel(bulletmodel, data.size); | |
| 121 | + BulletIndex[i].SetTexture(bullettexture); | |
| 122 | + } | |
| 123 | + } | |
| 129 | 124 | } |
| 130 | 125 | |
| 131 | - //適用 | |
| 132 | - for(int i=0; i<MAX_GRENADE; i++){ | |
| 133 | - GrenadeIndex[i].SetModel(grenademodel, model_size); | |
| 134 | - GrenadeIndex[i].SetTexture(grenadetexture); | |
| 126 | + if( Resource->GetBulletModelTexture(1, &bulletmodel, &bullettexture) == 0 ){ | |
| 127 | + if( GameParamInfo->GetBullet(1, &data) == 0 ){ | |
| 128 | + for(int i=0; i<MAX_GRENADE; i++){ | |
| 129 | + GrenadeIndex[i].SetModel(bulletmodel, data.size); | |
| 130 | + GrenadeIndex[i].SetTexture(bullettexture); | |
| 131 | + } | |
| 132 | + } | |
| 135 | 133 | } |
| 136 | 134 | } |
| 137 | 135 |
| @@ -1376,27 +1374,27 @@ | ||
| 1376 | 1374 | } |
| 1377 | 1375 | } |
| 1378 | 1376 | |
| 1379 | - //銃弾適用 | |
| 1380 | 1377 | int bulletmodel, bullettexture; |
| 1381 | - Resource->GetBulletModelTexture(&bulletmodel, &bullettexture); | |
| 1382 | - for(int i=0; i<MAX_BULLET; i++){ | |
| 1383 | - BulletIndex[i].SetModel(bulletmodel, BULLET_SCALE); | |
| 1384 | - BulletIndex[i].SetTexture(bullettexture); | |
| 1385 | - } | |
| 1378 | + BulletParameter data; | |
| 1386 | 1379 | |
| 1387 | - //手榴弾のリソースとモデルサイズを取得 | |
| 1388 | - int grenademodel, grenadetexture; | |
| 1389 | - float model_size = 1.0f; | |
| 1390 | - WeaponParameter ParamData; | |
| 1391 | - Resource->GetWeaponModelTexture(ID_WEAPON_GRENADE, &grenademodel, &grenadetexture); | |
| 1392 | - if( GameParamInfo->GetWeapon(ID_WEAPON_GRENADE, &ParamData) == 0 ){ | |
| 1393 | - model_size = ParamData.size; | |
| 1380 | + //銃弾適用 | |
| 1381 | + if( Resource->GetBulletModelTexture(0, &bulletmodel, &bullettexture) == 0 ){ | |
| 1382 | + if( GameParamInfo->GetBullet(0, &data) == 0 ){ | |
| 1383 | + for(int i=0; i<MAX_BULLET; i++){ | |
| 1384 | + BulletIndex[i].SetModel(bulletmodel, data.size); | |
| 1385 | + BulletIndex[i].SetTexture(bullettexture); | |
| 1386 | + } | |
| 1387 | + } | |
| 1394 | 1388 | } |
| 1395 | 1389 | |
| 1396 | 1390 | //手榴弾適用 |
| 1397 | - for(int i=0; i<MAX_GRENADE; i++){ | |
| 1398 | - GrenadeIndex[i].SetModel(grenademodel, model_size); | |
| 1399 | - GrenadeIndex[i].SetTexture(grenadetexture); | |
| 1391 | + if( Resource->GetBulletModelTexture(1, &bulletmodel, &bullettexture) == 0 ){ | |
| 1392 | + if( GameParamInfo->GetBullet(1, &data) == 0 ){ | |
| 1393 | + for(int i=0; i<MAX_GRENADE; i++){ | |
| 1394 | + GrenadeIndex[i].SetModel(bulletmodel, data.size); | |
| 1395 | + GrenadeIndex[i].SetTexture(bullettexture); | |
| 1396 | + } | |
| 1397 | + } | |
| 1400 | 1398 | } |
| 1401 | 1399 | |
| 1402 | 1400 | //全てのエフェクトを無効化 |