• 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

Revision178 (tree)
Time2017-06-16 00:42:10
Authorxops-mikan

Log Message

方向キーでの視点操作および三人称視点を改良、viewコマンドの操作性改善

Change Summary

Incremental Difference

--- trunk/gamemain.cpp (revision 177)
+++ trunk/gamemain.cpp (revision 178)
@@ -1067,6 +1067,8 @@
10671067 //! @brief コンストラクタ
10681068 maingame::maingame()
10691069 {
1070+ add_camera_rx = 0.0f;
1071+ add_camera_ry = 0.0f;
10701072 ShowInfo_Debugmode = false;
10711073 Camera_F2mode = 0;
10721074 Camera_HOMEmode = false;
@@ -1176,6 +1178,8 @@
11761178
11771179 view_rx = 0.0f;
11781180 view_ry = 0.0f;
1181+ add_camera_rx = 0.0f;
1182+ add_camera_ry = 0.0f;
11791183 Camera_Debugmode = false;
11801184 tag = false;
11811185 radar = false;
@@ -1351,7 +1355,6 @@
13511355
13521356 //プレイヤーのクラスを取得
13531357 human *myHuman = ObjMgr.GetPlayerHumanObject();
1354- int PlayerID = ObjMgr.GetPlayerID();
13551358
13561359 //キー入力を取得
13571360 inputCtrl->GetInputState(true);
@@ -1374,45 +1377,6 @@
13741377 y *= -1;
13751378 }
13761379
1377- if( Camera_Debugmode == false ){ //通常モードならば
1378- if( myHuman->GetHP() > 0 ){
1379- //マウスによる向きを計算
1380- mouse_rx += x * MouseSensitivity;
1381- mouse_ry -= y * MouseSensitivity;
1382-
1383- //キー操作による向きを計算
1384- if( CheckInputControl(KEY_TURNUP, 0) ){ mouse_ry += DegreeToRadian(3); } // 標準:[↑]
1385- if( CheckInputControl(KEY_TURNDOWN, 0) ){ mouse_ry -= DegreeToRadian(3); } // 標準:[↓]
1386- if( CheckInputControl(KEY_TURNLEFT, 0) ){ mouse_rx -= DegreeToRadian(3); } // 標準:[←]
1387- if( CheckInputControl(KEY_TURNRIGHT, 0) ){ mouse_rx += DegreeToRadian(3); } // 標準:[→]
1388-
1389- if( mouse_ry > DegreeToRadian(70) ) mouse_ry = DegreeToRadian(70);
1390- if( mouse_ry < DegreeToRadian(-70) ) mouse_ry = DegreeToRadian(-70);
1391- }
1392- }
1393- else{ //デバックモードならば
1394- //キー操作によりカメラ座標を計算
1395- if( inputCtrl->CheckKeyNow(OriginalkeycodeToDinputdef(0x00)) ){ camera_x += 2.0f; } // [↑]
1396- if( inputCtrl->CheckKeyNow(OriginalkeycodeToDinputdef(0x01)) ){ camera_x -= 2.0f; } // [↓]
1397- if( inputCtrl->CheckKeyNow(OriginalkeycodeToDinputdef(0x02)) ){ camera_z += 2.0f; } // [←]
1398- if( inputCtrl->CheckKeyNow(OriginalkeycodeToDinputdef(0x03)) ){ camera_z -= 2.0f; } // [→]
1399- if( inputCtrl->CheckKeyNow(OriginalkeycodeToDinputdef(0x48)) ){ camera_y += 2.0f; } //[NUM +]
1400- if( inputCtrl->CheckKeyNow(OriginalkeycodeToDinputdef(0x49)) ){ camera_y -= 2.0f; } //[NUM -]
1401-
1402- //マウス移動をカメラの向きとして適用
1403- //camera_rx -= x*0.0025f;
1404- //camera_ry -= y*0.0025f;
1405- camera_rx -= x * MouseSensitivity;
1406- camera_ry -= y * MouseSensitivity;
1407- if( camera_ry > DegreeToRadian(70) ) camera_ry = DegreeToRadian(70);
1408- if( camera_ry < DegreeToRadian(-70) ) camera_ry = DegreeToRadian(-70);
1409- }
1410-
1411- //プレイヤー(オブジェクト)の向きを設定
1412- if( (PlayerAI == false)&&(myHuman->GetHP() > 0) ){
1413- myHuman->SetRxRy(mouse_rx, mouse_ry);
1414- }
1415-
14161380 if( inputCtrl->CheckKeyDown(GetEscKeycode()) ){ //ゲーム終了操作かチェック
14171381 GameState->PushBackSpaceKey();
14181382 GameSpeed = 1;
@@ -1422,20 +1386,6 @@
14221386 GameSpeed = 1;
14231387 }
14241388
1425- //カメラ表示モード変更操作かチェック
1426- if( inputCtrl->CheckKeyDown( GetFunctionKeycode(1) ) ){
1427- if( Camera_F1mode == false ){
1428- Camera_F1mode = true;
1429- view_rx = 0.0f;
1430- view_ry = DegreeToRadian(-22.5f);
1431- }
1432- else{
1433- Camera_F1mode = false;
1434- view_rx = 0.0f;
1435- view_ry = 0.0f;
1436- }
1437- }
1438-
14391389 //画面のUI変更操作かチェック
14401390 if( inputCtrl->CheckKeyDown( GetFunctionKeycode(2) ) ){
14411391 if( Camera_F2mode == 2 ){
@@ -1447,6 +1397,21 @@
14471397 }
14481398
14491399 #ifdef ENABLE_DEBUGCONSOLE
1400+ if( Show_Console == false ){
1401+#endif
1402+
1403+ if( Camera_Debugmode == false ){ //通常モードならば
1404+ if( PlayerAI == false ){
1405+ InputPlayer(myHuman, x, y, MouseSensitivity);
1406+ }
1407+ }
1408+ else{ //デバックモードならば
1409+ InputViewCamera(x, y, MouseSensitivity);
1410+ }
1411+
1412+#ifdef ENABLE_DEBUGCONSOLE
1413+ }
1414+
14501415 //デバック用コンソールの表示操作かチェック
14511416 if( inputCtrl->CheckKeyDown( GetFunctionKeycode(11) ) ){
14521417 if( Show_Console == false ){
@@ -1459,287 +1424,381 @@
14591424 }
14601425 }
14611426
1462- if( Show_Console == false ){
1427+ if( Show_Console == true ){
1428+ InputConsole();
1429+ }
14631430 #endif
14641431
1465- if( PlayerAI == false ){
1432+ time_input = GetTimeMS() - time;
1433+}
14661434
1467- //前後左右の移動(走り)操作かチェック
1468- if( CheckInputControl(KEY_MOVEFORWARD, 0) ){
1469- ObjMgr.MoveForward(PlayerID);
1435+//! @brief プレイヤー操作系の入力処理
1436+//! @param myHuman プレイヤーのクラス
1437+//! @param mouse_x マウスのX座標
1438+//! @param mouse_y マウスのY座標
1439+//! @param MouseSensitivity 視点の移動量計算
1440+void maingame::InputPlayer(human *myHuman, int mouse_x, int mouse_y, float MouseSensitivity)
1441+{
1442+ int PlayerID = ObjMgr.GetPlayerID();
1443+
1444+ if( myHuman->GetHP() > 0 ){
1445+
1446+ //マウスによる向きを計算
1447+ mouse_rx += mouse_x * MouseSensitivity;
1448+ mouse_ry -= mouse_y * MouseSensitivity;
1449+
1450+ //キー操作による向きを計算
1451+ if( (CheckInputControl(KEY_TURNUP, 0) == true)&&(CheckInputControl(KEY_TURNDOWN, 0) == false) ){ add_camera_ry += (INPUT_ARROWKEYS_ANGLE - add_camera_ry)*0.2f; } // 標準:[↑]
1452+ else if( (CheckInputControl(KEY_TURNDOWN, 0) == true)&&(CheckInputControl(KEY_TURNUP, 0) == false) ){ add_camera_ry += (INPUT_ARROWKEYS_ANGLE*-1 - add_camera_ry)*0.2f; } // 標準:[↓]
1453+ else { add_camera_ry = 0.0f; }
1454+ if( (CheckInputControl(KEY_TURNLEFT, 0) == true)&&(CheckInputControl(KEY_TURNRIGHT, 0) == false) ){ add_camera_rx += (INPUT_ARROWKEYS_ANGLE*-1 - add_camera_rx)*0.2f; } // 標準:[←]
1455+ else if( (CheckInputControl(KEY_TURNRIGHT, 0) == true)&&(CheckInputControl(KEY_TURNLEFT, 0) == false) ){ add_camera_rx += (INPUT_ARROWKEYS_ANGLE - add_camera_rx)*0.2f; } // 標準:[→]
1456+ else { add_camera_rx = 0.0f; }
1457+ mouse_rx += add_camera_rx;
1458+ mouse_ry += add_camera_ry;
1459+
1460+ if( mouse_ry > DegreeToRadian(70) ) mouse_ry = DegreeToRadian(70);
1461+ if( mouse_ry < DegreeToRadian(-70) ) mouse_ry = DegreeToRadian(-70);
1462+
1463+
1464+ //プレイヤー(オブジェクト)の向きを設定
1465+ myHuman->SetRxRy(mouse_rx, mouse_ry);
1466+
1467+
1468+ //前後左右の移動(走り)操作かチェック
1469+ if( CheckInputControl(KEY_MOVEFORWARD, 0) ){
1470+ ObjMgr.MoveForward(PlayerID);
1471+ }
1472+ else{
1473+ if( CheckInputControl(KEY_MOVEBACKWARD, 0) ){
1474+ ObjMgr.MoveBack(PlayerID);
14701475 }
1471- else{
1472- if( CheckInputControl(KEY_MOVEBACKWARD, 0) ){
1473- ObjMgr.MoveBack(PlayerID);
1474- }
1476+ }
1477+ if( CheckInputControl(KEY_MOVELEFT, 0) ){
1478+ ObjMgr.MoveLeft(PlayerID);
1479+ }
1480+ else{
1481+ if( CheckInputControl(KEY_MOVERIGHT, 0) ){
1482+ ObjMgr.MoveRight(PlayerID);
14751483 }
1476- if( CheckInputControl(KEY_MOVELEFT, 0) ){
1477- ObjMgr.MoveLeft(PlayerID);
1478- }
1479- else{
1480- if( CheckInputControl(KEY_MOVERIGHT, 0) ){
1481- ObjMgr.MoveRight(PlayerID);
1482- }
1483- }
1484+ }
14841485
1485- //歩き操作かチェック
1486- if( CheckInputControl(KEY_WALK, 0) ){
1487- ObjMgr.MoveWalk(PlayerID);
1488- }
1486+ //歩き操作かチェック
1487+ if( CheckInputControl(KEY_WALK, 0) ){
1488+ ObjMgr.MoveWalk(PlayerID);
1489+ }
14891490
1490- //ジャンプ操作かチェック
1491- if( CheckInputControl(KEY_JUMP, 1) ){
1492- ObjMgr.MoveJump(PlayerID);
1493- }
1491+ //ジャンプ操作かチェック
1492+ if( CheckInputControl(KEY_JUMP, 1) ){
1493+ ObjMgr.MoveJump(PlayerID);
1494+ }
14941495
1495- if( Camera_Debugmode == true ){ //デバックモードならば
1496- //
1497- }
1498- else{ //デバックモードでなければ
1499- HumanParameter humandata;
1500- int id_param;
1501- bool zombie;
1502- int keymode;
1496+ HumanParameter humandata;
1497+ int id_param;
1498+ bool zombie;
1499+ int keymode;
15031500
1504- //ゾンビかどうか判定
1505- myHuman->GetParamData(&id_param, NULL, NULL, NULL);
1506- GameParamInfo.GetHuman(id_param, &humandata);
1507- if( humandata.type == 2 ){
1508- zombie = true;
1509- }
1510- else{
1511- zombie = false;
1512- }
1501+ //ゾンビかどうか判定
1502+ myHuman->GetParamData(&id_param, NULL, NULL, NULL);
1503+ GameParamInfo.GetHuman(id_param, &humandata);
1504+ if( humandata.type == 2 ){
1505+ zombie = true;
1506+ }
1507+ else{
1508+ zombie = false;
1509+ }
15131510
1514- //連射モードを取得
1515- if( zombie == true ){
1516- keymode = 1;
1517- }
1518- else if( myHuman->GetWeaponBlazingmode() == false ){
1519- keymode = 1;
1520- }
1521- else{
1522- keymode = 0;
1523- }
1511+ //連射モードを取得
1512+ if( zombie == true ){
1513+ keymode = 1;
1514+ }
1515+ else if( myHuman->GetWeaponBlazingmode() == false ){
1516+ keymode = 1;
1517+ }
1518+ else{
1519+ keymode = 0;
1520+ }
15241521
1525- //発砲操作かチェック
1526- if( CheckInputControl(KEY_Shot, keymode) ){
1522+ //発砲操作かチェック
1523+ if( CheckInputControl(KEY_Shot, keymode) ){
15271524
1528- if( zombie == false ){
1529- //弾の発射に成功すれば
1530- if( ObjMgr.ShotWeapon(PlayerID) == 1 ){
1531- //スコアに加算
1532- MainGameInfo.fire += 1;
1525+ if( zombie == false ){
1526+ //弾の発射に成功すれば
1527+ if( ObjMgr.ShotWeapon(PlayerID) == 1 ){
1528+ //スコアに加算
1529+ MainGameInfo.fire += 1;
15331530
1534- //プレイヤーの向きを取得
1535- ObjMgr.GetPlayerHumanObject()->GetRxRy(&mouse_rx, &mouse_ry);
1536- }
1531+ //プレイヤーの向きを取得
1532+ ObjMgr.GetPlayerHumanObject()->GetRxRy(&mouse_rx, &mouse_ry);
1533+ }
1534+ }
1535+ else{
1536+ for(int i=0; i<MAX_HUMAN; i++){
1537+ human *EnemyHuman = ObjMgr.GeHumanObject(i);
1538+ if( ObjMgr.CheckZombieAttack(myHuman, EnemyHuman) == true ){
1539+ ObjMgr.HitZombieAttack(myHuman, EnemyHuman);
15371540 }
1538- else{
1539- for(int i=0; i<MAX_HUMAN; i++){
1540- human *EnemyHuman = ObjMgr.GeHumanObject(i);
1541- if( ObjMgr.CheckZombieAttack(myHuman, EnemyHuman) == true ){
1542- ObjMgr.HitZombieAttack(myHuman, EnemyHuman);
1543- }
1544- }
1545- }
1546-
15471541 }
15481542 }
15491543
1550- //リロード操作かチェック
1551- if( CheckInputControl(KEY_RELOAD, 1) ){
1552- ObjMgr.ReloadWeapon(PlayerID);
1544+ }
1545+
1546+ //リロード操作かチェック
1547+ if( CheckInputControl(KEY_RELOAD, 1) ){
1548+ ObjMgr.ReloadWeapon(PlayerID);
1549+ }
1550+
1551+ //武器の切り替え操作かチェック
1552+ if( CheckInputControl(KEY_SWITCHWEAPON, 1) ){
1553+ ObjMgr.ChangeWeapon(PlayerID, -1);
1554+ }
1555+ if( CheckInputControl(KEY_WEAPON1, 1) ){
1556+ ObjMgr.ChangeWeapon(PlayerID, 0);
1557+ }
1558+ if( CheckInputControl(KEY_WEAPON2, 1) ){
1559+ ObjMgr.ChangeWeapon(PlayerID, 1);
1560+ }
1561+
1562+ //武器の廃棄操作かチェック
1563+ if( CheckInputControl(KEY_DROPWEAPON, 1) ){
1564+ ObjMgr.DumpWeapon(PlayerID);
1565+ }
1566+
1567+ //スコープ操作かチェック
1568+ if( CheckInputControl(KEY_ZOOMSCOPE, 1) ){
1569+ ObjMgr.ChangeScopeMode(PlayerID);
1570+ }
1571+
1572+ //連射モード変更操作かチェック
1573+ if( CheckInputControl(KEY_ShotMODE, 1) ){
1574+ ObjMgr.ChangeShotMode(PlayerID);
1575+ }
1576+
1577+ //カメラ表示モード変更操作かチェック
1578+ if( inputCtrl->CheckKeyDown( GetFunctionKeycode(1) ) ){
1579+ if( Camera_F1mode == false ){
1580+ Camera_F1mode = true;
1581+ view_rx = 0.0f;
1582+ view_ry = VIEW_F1MODE_ANGLE;
15531583 }
1584+ else{
1585+ Camera_F1mode = false;
1586+ view_rx = 0.0f;
1587+ view_ry = 0.0f;
1588+ }
1589+ }
15541590
1555- //武器の切り替え操作かチェック
1556- if( CheckInputControl(KEY_SWITCHWEAPON, 1) ){
1557- ObjMgr.ChangeWeapon(PlayerID, -1);
1591+ //カメラ操作
1592+ if( Camera_F1mode == true ){
1593+ if( inputCtrl->CheckKeyNow( OriginalkeycodeToDinputdef(0x0C) ) ){ //NUM8
1594+ view_ry -= INPUT_F1NUMKEYS_ANGLE;
15581595 }
1559- if( CheckInputControl(KEY_WEAPON1, 1) ){
1560- ObjMgr.ChangeWeapon(PlayerID, 0);
1596+ if( inputCtrl->CheckKeyNow( OriginalkeycodeToDinputdef(0x09) ) ){ //NUM5
1597+ view_ry += INPUT_F1NUMKEYS_ANGLE;
15611598 }
1562- if( CheckInputControl(KEY_WEAPON2, 1) ){
1563- ObjMgr.ChangeWeapon(PlayerID, 1);
1599+ if( inputCtrl->CheckKeyNow( OriginalkeycodeToDinputdef(0x08) ) ){ //NUM4
1600+ view_rx -= INPUT_F1NUMKEYS_ANGLE;
15641601 }
1565-
1566- //武器の廃棄操作かチェック
1567- if( CheckInputControl(KEY_DROPWEAPON, 1) ){
1568- ObjMgr.DumpWeapon(PlayerID);
1602+ if( inputCtrl->CheckKeyNow( OriginalkeycodeToDinputdef(0x0A) ) ){ //NUM6
1603+ view_rx += INPUT_F1NUMKEYS_ANGLE;
15691604 }
1605+ }
15701606
1571- //スコープ操作かチェック
1572- if( CheckInputControl(KEY_ZOOMSCOPE, 1) ){
1573- ObjMgr.ChangeScopeMode(PlayerID);
1574- }
1607+ }
15751608
1576- //連射モード変更操作かチェック
1577- if( CheckInputControl(KEY_ShotMODE, 1) ){
1578- ObjMgr.ChangeShotMode(PlayerID);
1579- }
1609+ // ここまで通常操作系
1610+ //
1611+ // ここから裏技系
15801612
1581- //カメラ操作
1582- if( Camera_F1mode == true ){
1583- if( inputCtrl->CheckKeyNow( OriginalkeycodeToDinputdef(0x0C) ) ){ //NUM8
1584- view_ry -= DegreeToRadian(2);
1585- }
1586- if( inputCtrl->CheckKeyNow( OriginalkeycodeToDinputdef(0x09) ) ){ //NUM5
1587- view_ry += DegreeToRadian(2);
1588- }
1589- if( inputCtrl->CheckKeyNow( OriginalkeycodeToDinputdef(0x08) ) ){ //NUM4
1590- view_rx -= DegreeToRadian(2);
1591- }
1592- if( inputCtrl->CheckKeyNow( OriginalkeycodeToDinputdef(0x0A) ) ){ //NUM6
1593- view_rx += DegreeToRadian(2);
1594- }
1595- }
1613+ if( myHuman->GetHP() > 0 ){
15961614
1597- //裏技・上昇の操作かチェック
1598- if( (inputCtrl->CheckKeyNow( GetFunctionKeycode(5) ))&&(inputCtrl->CheckKeyNow(OriginalkeycodeToDinputdef(0x0F))) ){ // F5 + [ENTER]
1599- Cmd_F5 = true;
1600- }
1601- else{
1602- Cmd_F5 = false;
1603- }
1615+ //裏技・上昇の操作かチェック
1616+ if( (inputCtrl->CheckKeyNow( GetFunctionKeycode(5) ))&&(inputCtrl->CheckKeyNow(OriginalkeycodeToDinputdef(0x0F))) ){ // F5 + [ENTER]
1617+ Cmd_F5 = true;
1618+ }
1619+ else{
1620+ Cmd_F5 = false;
1621+ }
16041622
1605- //裏技・弾追加の操作かチェック
1606- if( inputCtrl->CheckKeyNow( GetFunctionKeycode(6) ) ){
1607- if( inputCtrl->CheckKeyDown(OriginalkeycodeToDinputdef(0x0F)) ){ // [ENTER]
1608- ObjMgr.CheatAddBullet(PlayerID);
1609- }
1623+ //裏技・弾追加の操作かチェック
1624+ if( inputCtrl->CheckKeyNow( GetFunctionKeycode(6) ) ){
1625+ if( inputCtrl->CheckKeyDown(OriginalkeycodeToDinputdef(0x0F)) ){ // [ENTER]
1626+ ObjMgr.CheatAddBullet(PlayerID);
16101627 }
1628+ }
16111629
1612- //裏技・武器変更の操作かチェック
1613- if( inputCtrl->CheckKeyNow( GetFunctionKeycode(7) ) ){
1614- if( inputCtrl->CheckKeyDown(OriginalkeycodeToDinputdef(0x02)) ){ // [←]
1615- int id_param = myHuman->GetMainWeaponTypeNO();
1630+ //裏技・武器変更の操作かチェック
1631+ if( inputCtrl->CheckKeyNow( GetFunctionKeycode(7) ) ){
1632+ if( inputCtrl->CheckKeyDown(OriginalkeycodeToDinputdef(0x02)) ){ // [←]
1633+ int id_param = myHuman->GetMainWeaponTypeNO();
16161634
1617- //次の武器番号を計算
1618- if( id_param >= TOTAL_PARAMETERINFO_WEAPON-1 ){ id_param = 0; }
1619- else{ id_param += 1; }
1635+ //次の武器番号を計算
1636+ if( id_param >= TOTAL_PARAMETERINFO_WEAPON-1 ){ id_param = 0; }
1637+ else{ id_param += 1; }
16201638
1621- ObjMgr.CheatNewWeapon(PlayerID, id_param);
1622- }
1623- if( inputCtrl->CheckKeyDown(OriginalkeycodeToDinputdef(0x03)) ){ // [→]
1624- int id_param = myHuman->GetMainWeaponTypeNO();
1639+ ObjMgr.CheatNewWeapon(PlayerID, id_param);
1640+ }
1641+ if( inputCtrl->CheckKeyDown(OriginalkeycodeToDinputdef(0x03)) ){ // [→]
1642+ int id_param = myHuman->GetMainWeaponTypeNO();
16251643
1626- //次の武器番号を計算
1627- if( id_param <= 0 ){ id_param = TOTAL_PARAMETERINFO_WEAPON-1; }
1628- else{ id_param -= 1; }
1644+ //次の武器番号を計算
1645+ if( id_param <= 0 ){ id_param = TOTAL_PARAMETERINFO_WEAPON-1; }
1646+ else{ id_param -= 1; }
16291647
1630- ObjMgr.CheatNewWeapon(PlayerID, id_param);
1631- }
1648+ ObjMgr.CheatNewWeapon(PlayerID, id_param);
16321649 }
1650+ }
16331651
1634- //裏技・人変更の操作かチェック
1635- if( inputCtrl->CheckKeyNow( GetFunctionKeycode(8) ) ){
1636- int Player_HumanID;
1652+ }
16371653
1638- if( inputCtrl->CheckKeyDown(OriginalkeycodeToDinputdef(0x02)) ){ // [←]
1639- //現在のプレイヤー番号を取得
1640- Player_HumanID = ObjMgr.GetPlayerID();
1654+ //裏技・人変更の操作かチェック
1655+ if( inputCtrl->CheckKeyNow( GetFunctionKeycode(8) ) ){
1656+ int Player_HumanID;
16411657
1642- //次の人を計算
1643- Player_HumanID += 1;
1644- if( Player_HumanID >= MAX_HUMAN ){ Player_HumanID = 0; }
1658+ if( inputCtrl->CheckKeyDown(OriginalkeycodeToDinputdef(0x02)) ){ // [←]
1659+ //現在のプレイヤー番号を取得
1660+ Player_HumanID = ObjMgr.GetPlayerID();
16451661
1646- //対象プレイヤー番号を適用
1647- ObjMgr.SetPlayerID(Player_HumanID);
1662+ //次の人を計算
1663+ Player_HumanID += 1;
1664+ if( Player_HumanID >= MAX_HUMAN ){ Player_HumanID = 0; }
16481665
1649- //プレイヤーの向きを取得
1650- ObjMgr.GetPlayerHumanObject()->GetRxRy(&mouse_rx, &mouse_ry);
1666+ //対象プレイヤー番号を適用
1667+ ObjMgr.SetPlayerID(Player_HumanID);
16511668
1652- //F1モード時にカメラの向きを再設定
1653- if( Camera_F1mode == true ){
1654- camera_rx = DegreeToRadian(90);
1655- }
1656- }
1657- if( inputCtrl->CheckKeyDown(OriginalkeycodeToDinputdef(0x03)) ){ // [→]
1658- //現在のプレイヤー番号を取得
1659- Player_HumanID = ObjMgr.GetPlayerID();
1669+ //プレイヤーの向きを取得
1670+ ObjMgr.GetPlayerHumanObject()->GetRxRy(&mouse_rx, &mouse_ry);
16601671
1661- //次の人を計算
1662- Player_HumanID -= 1;
1663- if( Player_HumanID < 0 ){ Player_HumanID = MAX_HUMAN-1; }
1672+ //F1モード時にカメラの向きを再設定
1673+ if( Camera_F1mode == true ){
1674+ camera_rx = DegreeToRadian(90);
1675+ }
1676+ }
1677+ if( inputCtrl->CheckKeyDown(OriginalkeycodeToDinputdef(0x03)) ){ // [→]
1678+ //現在のプレイヤー番号を取得
1679+ Player_HumanID = ObjMgr.GetPlayerID();
16641680
1665- //対象プレイヤー番号を適用
1666- ObjMgr.SetPlayerID(Player_HumanID);
1681+ //次の人を計算
1682+ Player_HumanID -= 1;
1683+ if( Player_HumanID < 0 ){ Player_HumanID = MAX_HUMAN-1; }
16671684
1668- //プレイヤーの向きを取得
1669- ObjMgr.GetPlayerHumanObject()->GetRxRy(&mouse_rx, &mouse_ry);
1685+ //対象プレイヤー番号を適用
1686+ ObjMgr.SetPlayerID(Player_HumanID);
16701687
1671- //F1モード時にカメラの向きを再設定
1672- if( Camera_F1mode == true ){
1673- camera_rx = DegreeToRadian(90);
1674- }
1675- }
1688+ //プレイヤーの向きを取得
1689+ ObjMgr.GetPlayerHumanObject()->GetRxRy(&mouse_rx, &mouse_ry);
1690+
1691+ //F1モード時にカメラの向きを再設定
1692+ if( Camera_F1mode == true ){
1693+ camera_rx = DegreeToRadian(90);
16761694 }
1695+ }
1696+ }
16771697
1678- //裏技・人追加の操作かチェック
1679- if( inputCtrl->CheckKeyNow( GetFunctionKeycode(9) ) ){
1680- if( (inputCtrl->CheckKeyDown(OriginalkeycodeToDinputdef(0x00)))||(inputCtrl->CheckKeyDown(OriginalkeycodeToDinputdef(0x01))) ){ // [↑]・[↓]
1681- float x, y, z, r;
1682- int param, dataid, team;
1683- int selectweapon;
1684- weapon *weapon[TOTAL_HAVEWEAPON];
1685- int weapon_paramid[TOTAL_HAVEWEAPON];
1686- for(int i=0; i<TOTAL_HAVEWEAPON; i++){
1687- weapon[i] = NULL;
1688- weapon_paramid[i] = 0;
1689- }
1690- int id;
1698+ if( myHuman->GetHP() > 0 ){
16911699
1692- //プレイヤーの座標や武器を取得
1693- myHuman->GetPosData(&x, &y, &z, &r);
1694- myHuman->GetParamData(&param, &dataid, NULL, &team);
1695- myHuman->GetWeapon(&selectweapon, weapon);
1696- for(int i=0; i<TOTAL_HAVEWEAPON; i++){
1697- if( weapon[i] != NULL ){
1698- weapon[i]->GetParamData(&weapon_paramid[i], NULL, NULL);
1699- }
1700+ //裏技・人追加の操作かチェック
1701+ if( inputCtrl->CheckKeyNow( GetFunctionKeycode(9) ) ){
1702+ if( (inputCtrl->CheckKeyDown(OriginalkeycodeToDinputdef(0x00)))||(inputCtrl->CheckKeyDown(OriginalkeycodeToDinputdef(0x01))) ){ // [↑]・[↓]
1703+ float x, y, z, r;
1704+ int param, dataid, team;
1705+ int selectweapon;
1706+ weapon *weapon[TOTAL_HAVEWEAPON];
1707+ int weapon_paramid[TOTAL_HAVEWEAPON];
1708+ for(int i=0; i<TOTAL_HAVEWEAPON; i++){
1709+ weapon[i] = NULL;
1710+ weapon_paramid[i] = 0;
1711+ }
1712+ int id;
1713+
1714+ //プレイヤーの座標や武器を取得
1715+ myHuman->GetPosData(&x, &y, &z, &r);
1716+ myHuman->GetParamData(&param, &dataid, NULL, &team);
1717+ myHuman->GetWeapon(&selectweapon, weapon);
1718+ for(int i=0; i<TOTAL_HAVEWEAPON; i++){
1719+ if( weapon[i] != NULL ){
1720+ weapon[i]->GetParamData(&weapon_paramid[i], NULL, NULL);
17001721 }
1722+ }
17011723
1702- //プレイヤーの目の前の座標を取得
1703- x += cos(r*-1 + (float)M_PI/2)*10.0f;
1704- y += 5.0f;
1705- z += sin(r*-1 + (float)M_PI/2)*10.0f;
1724+ //プレイヤーの目の前の座標を取得
1725+ x += cos(r*-1 + (float)M_PI/2)*10.0f;
1726+ y += 5.0f;
1727+ z += sin(r*-1 + (float)M_PI/2)*10.0f;
17061728
1707- //人を追加
1708- id = ObjMgr.AddHumanIndex(x, y, z, r, param, team, weapon_paramid);
1709- if( id >= 0 ){
1710- ObjMgr.ChangeWeapon(id, selectweapon);
1729+ //人を追加
1730+ id = ObjMgr.AddHumanIndex(x, y, z, r, param, team, weapon_paramid);
1731+ if( id >= 0 ){
1732+ ObjMgr.ChangeWeapon(id, selectweapon);
17111733
1712- //AIを設定
1713- HumanAI[id].Init();
1714- if( inputCtrl->CheckKeyDown(OriginalkeycodeToDinputdef(0x00)) ){ // [↑]
1715- HumanAI[id].SetHoldTracking(PlayerID);
1716- }
1717- if( inputCtrl->CheckKeyDown(OriginalkeycodeToDinputdef(0x01)) ){ // [↓]
1718- HumanAI[id].SetHoldWait(x, z, r);
1719- }
1734+ //AIを設定
1735+ HumanAI[id].Init();
1736+ if( inputCtrl->CheckKeyDown(OriginalkeycodeToDinputdef(0x00)) ){ // [↑]
1737+ HumanAI[id].SetHoldTracking(PlayerID);
17201738 }
1739+ if( inputCtrl->CheckKeyDown(OriginalkeycodeToDinputdef(0x01)) ){ // [↓]
1740+ HumanAI[id].SetHoldWait(x, z, r);
1741+ }
17211742 }
17221743 }
1744+ }
17231745
1724- //裏技・腕描画の操作かチェック
1725- if( inputCtrl->CheckKeyDown( GetHomeKeycode() ) ){
1726- if( Camera_HOMEmode == false ){
1727- Camera_HOMEmode = true;
1728- }
1729- else{
1730- Camera_HOMEmode = false;
1731- }
1746+ //裏技・腕描画の操作かチェック
1747+ if( inputCtrl->CheckKeyDown( GetHomeKeycode() ) ){
1748+ if( Camera_HOMEmode == false ){
1749+ Camera_HOMEmode = true;
17321750 }
1751+ else{
1752+ Camera_HOMEmode = false;
1753+ }
17331754 }
1755+ }
1756+}
17341757
1735-#ifdef ENABLE_DEBUGCONSOLE
1758+//! @brief フリーカメラ操作系の入力処理
1759+//! @param mouse_x マウスのX座標
1760+//! @param mouse_y マウスのY座標
1761+//! @param MouseSensitivity 視点の移動量計算
1762+void maingame::InputViewCamera(int mouse_x, int mouse_y, float MouseSensitivity)
1763+{
1764+ //マウス移動をカメラの向きとして適用
1765+ camera_rx -= mouse_x * MouseSensitivity;
1766+ camera_ry -= mouse_y * MouseSensitivity;
1767+
1768+ //キー操作による向きを計算
1769+ if( CheckInputControl(KEY_TURNUP, 0) ){ camera_ry += INPUT_ARROWKEYS_ANGLE; } // 標準:[↑]
1770+ if( CheckInputControl(KEY_TURNDOWN, 0) ){ camera_ry -= INPUT_ARROWKEYS_ANGLE; } // 標準:[↓]
1771+ if( CheckInputControl(KEY_TURNLEFT, 0) ){ camera_rx += INPUT_ARROWKEYS_ANGLE; } // 標準:[←]
1772+ if( CheckInputControl(KEY_TURNRIGHT, 0) ){ camera_rx -= INPUT_ARROWKEYS_ANGLE; } // 標準:[→]
1773+
1774+ if( camera_ry > DegreeToRadian(70) ) camera_ry = DegreeToRadian(70);
1775+ if( camera_ry < DegreeToRadian(-70) ) camera_ry = DegreeToRadian(-70);
1776+
1777+ //移動量決定
1778+ float dist = VIEW_FREECAMERA_SCALE;
1779+ if( CheckInputControl(KEY_Shot, 0) ){
1780+ dist *= 2;
17361781 }
1737- if( Show_Console == true ){
1738- InputConsole();
1782+
1783+ //キー操作によりカメラ座標を計算
1784+ if( CheckInputControl(KEY_MOVEFORWARD, 0) ){
1785+ camera_x += cos(camera_rx)*cos(camera_ry)*dist;
1786+ camera_y += sin(camera_ry)*dist;
1787+ camera_z += sin(camera_rx)*cos(camera_ry)*dist;
17391788 }
1740-#endif
1741-
1742- time_input = GetTimeMS() - time;
1789+ if( CheckInputControl(KEY_MOVEBACKWARD, 0) ){
1790+ camera_x -= cos(camera_rx)*cos(camera_ry)*dist;
1791+ camera_y -= sin(camera_ry)*dist;
1792+ camera_z -= sin(camera_rx)*cos(camera_ry)*dist;
1793+ }
1794+ if( CheckInputControl(KEY_MOVELEFT, 0) ){
1795+ camera_x += cos(camera_rx + (float)M_PI/2)*dist;
1796+ camera_z += sin(camera_rx + (float)M_PI/2)*dist;
1797+ }
1798+ if( CheckInputControl(KEY_MOVERIGHT, 0) ){
1799+ camera_x += cos(camera_rx - (float)M_PI/2)*dist;
1800+ camera_z += sin(camera_rx - (float)M_PI/2)*dist;
1801+ }
17431802 }
17441803
17451804 void maingame::Process()
@@ -1867,27 +1926,42 @@
18671926 camera_z = z + sin(camera_rx)*r;
18681927 }
18691928 else if( Camera_F1mode == true ){
1870- float crx = camera_rx*0.6f + (view_rx + mouse_rx*-1 + (float)M_PI/2)*0.4f; // 3/5 + 2/5
1871- float cry = camera_ry*0.6f + (view_ry + mouse_ry)*0.4f; // 3/5 + 2/5
1929+ float crx, cry;
1930+ float ccx, ccy, ccz;
1931+
1932+ //カメラの注視点を計算
1933+ crx = camera_rx*0.8f + (view_rx + mouse_rx*-1 + (float)M_PI/2)*0.2f; // 8 : 2
1934+ cry = camera_ry*0.8f + (view_ry + mouse_ry)*0.2f - (float)M_PI/2; // 8 : 2
1935+ ccx = x - cos(crx)*cos(cry)*3.0f;
1936+ ccy = y + HUMAN_HEIGHT-0.5f + sin(cry*-1)*2.5f;
1937+ ccz = z - sin(crx)*cos(cry)*3.0f;
1938+
1939+ //注視点からカメラまでの当たり判定
1940+ cry += (float)M_PI/2;
18721941 float dist;
1873- if( CollD.CheckALLBlockIntersectRay(x, y + HUMAN_HEIGHT, z, cos(crx)*cos(cry)*-1, sin(cry*-1), sin(crx)*cos(cry)*-1, NULL, NULL, &dist, 13.0f) == true ){
1942+ if( CollD.CheckALLBlockIntersectRay(ccx, ccy, ccz, cos(crx)*cos(cry)*-1, sin(cry*-1), sin(crx)*cos(cry)*-1, NULL, NULL, &dist, VIEW_F1MODE_DIST) == true ){
18741943 dist -= 1.0f;
18751944 }
18761945 else{
1877- dist = 13.0f;
1946+ dist = VIEW_F1MODE_DIST;
18781947 }
1879- camera_x = x - cos(crx)*cos(cry)*dist;
1880- camera_y = y + HUMAN_HEIGHT + sin(cry*-1)*dist;
1881- camera_z = z - sin(crx)*cos(cry)*dist;
1948+
1949+ //カメラ座標を再計算
1950+ camera_x = ccx - cos(crx)*cos(cry)*(dist);
1951+ camera_y = ccy + sin(cry*-1)*dist;
1952+ camera_z = ccz - sin(crx)*cos(cry)*(dist);
18821953 camera_rx = crx;
18831954 camera_ry = cry;
18841955 }
18851956 else{
1886- camera_x = x;
1887- camera_y = y + VIEW_HEIGHT;
1888- camera_z = z;
1889- camera_rx = view_rx + mouse_rx*-1 + (float)M_PI/2;
1890- camera_ry = view_ry + mouse_ry;
1957+ float crx = view_rx + mouse_rx*-1 + (float)M_PI/2;
1958+ float cry = view_ry + mouse_ry;
1959+
1960+ camera_x = x + cos(crx)*cos(cry)*VIEW_DIST;
1961+ camera_y = y + VIEW_HEIGHT + sin(cry)*VIEW_DIST;
1962+ camera_z = z + sin(crx)*cos(cry)*VIEW_DIST;
1963+ camera_rx = crx;
1964+ camera_ry = cry;
18911965 }
18921966
18931967 //ダメージを受けていれば、レッドフラッシュを描画する
--- trunk/gamemain.h (revision 177)
+++ trunk/gamemain.h (revision 178)
@@ -37,6 +37,9 @@
3737 #define TOTAL_MENUITEMS 8 //!< メニュー1画面に表示するミッション数
3838 #define MAINMENU_H (TOTAL_MENUITEMS+2)*30 + 25 //!< メニューの表示サイズ・高さ
3939
40+#define INPUT_ARROWKEYS_ANGLE DegreeToRadian(4) //!< 方向キーでの回転角度
41+#define INPUT_F1NUMKEYS_ANGLE DegreeToRadian(2) //!< 三人称視点でのテンキーの回転角度
42+
4043 #define HUDA_WEAPON_POSX (SCREEN_WIDTH - 255) //!< 武器情報を描画する領域・X座標
4144 #define HUDA_WEAPON_POSY (SCREEN_HEIGHT - 98) //!< 武器情報を描画する領域・Y座標
4245 #define HUDA_WEAPON_SIZEW 8 //!< 武器情報を描画する領域・横サイズ(32ピクセルの配置個数)
@@ -43,6 +46,10 @@
4346 #define HUDA_WEAPON_SIZEH 3 //!< 武器情報を描画する領域・縦サイズ(32ピクセルの配置個数)
4447
4548 #define VIEW_HEIGHT 19.0f //!< 視点の高さ
49+#define VIEW_DIST 0.1f //!< 中心から視点までの距離
50+#define VIEW_F1MODE_ANGLE DegreeToRadian(-22.5f) //!< 三人称視点での視点角度(初期)
51+#define VIEW_F1MODE_DIST 14.0f //!< 三人称視点での視点距離(最大)
52+#define VIEW_FREECAMERA_SCALE 1.5f //!< フリーカメラでの移動速度(高速モードは×2)
4653 #define VIEWANGLE_NORMAL DegreeToRadian(65) //!< 視野角 標準
4754 #define VIEWANGLE_SCOPE_1 DegreeToRadian(30) //!< 視野角 スコープ1
4855 #define VIEWANGLE_SCOPE_2 DegreeToRadian(15) //!< 視野角 スコープ2
@@ -165,10 +172,12 @@
165172 //class EventControl Event[TOTAL_EVENTLINE]; //!< イベント制御クラス
166173 int SkyNumber; //!< 背景空番号
167174 bool DarkScreenFlag; //!< 画面を暗く
168- float mouse_rx; //!< マウスによる水平軸角度
169- float mouse_ry; //!< マウスによる垂直軸角度
170- float view_rx; //!< マウス角度とカメラ角度の差(水平軸)
171- float view_ry; //!< マウス角度とカメラ角度の差(垂直軸)
175+ float mouse_rx; //!< マウスによる水平軸角度
176+ float mouse_ry; //!< マウスによる垂直軸角度
177+ float view_rx; //!< マウス角度とカメラ角度の差(水平軸)
178+ float view_ry; //!< マウス角度とカメラ角度の差(垂直軸)
179+ float add_camera_rx; //!< カメラ回転角度 RXの増減量
180+ float add_camera_ry; //!< カメラ回転角度 RYの増減量
172181 bool ShowInfo_Debugmode; //!< 座標などを表示するデバックモード
173182 bool Camera_Debugmode; //!< カメラデバックモード
174183 bool tag; //!< オブジェクトのタグを表示
@@ -201,6 +210,8 @@
201210 int time_render; //!< 描画の処理時間
202211 GameInfo MainGameInfo; //!< リザルト用管理クラス
203212 bool CheckInputControl(int CheckKey, int mode);
213+ void InputPlayer(human *myHuman, int mouse_x, int mouse_y, float MouseSensitivity);
214+ void InputViewCamera(int mouse_x, int mouse_y, float MouseSensitivity);
204215 void Render3D();
205216 void Render2D();
206217 bool GetRadarPos(float in_x, float in_y, float in_z, int RadarPosX, int RadarPosY, int RadarSize, float RadarWorldR, int *out_x, int *out_y, float *local_y, bool check);