ソースを参照

Added mouse camera movement

Thomas Buck 10年前
コミット
964f379642
3個のファイルの変更25行の追加10行の削除
  1. 2
    2
      data/OpenRaider.ini
  2. 21
    8
      src/Game.cpp
  3. 2
    0
      src/OpenRaider.cpp

+ 2
- 2
data/OpenRaider.ini ファイルの表示

@@ -19,8 +19,8 @@ set audio      true # Enable Audio Output
19 19
 set volume     0.5
20 20
 
21 21
 # Input
22
-set mouse_x    1.0
23
-set mouse_y    1.0
22
+set mouse_x    0.75
23
+set mouse_y    0.75
24 24
 
25 25
 bind menu     "escape"
26 26
 bind console  "backquote"

+ 21
- 8
src/Game.cpp ファイルの表示

@@ -91,6 +91,9 @@ void Game::destroy() {
91 91
 
92 92
     mLoaded = false;
93 93
     mRender->setMode(Render::modeDisabled);
94
+
95
+    mRender->ClearWorld();
96
+    mWorld.destroy();
94 97
 }
95 98
 
96 99
 int Game::loadLevel(const char *level) {
@@ -99,9 +102,6 @@ int Game::loadLevel(const char *level) {
99 102
 
100 103
     mName = bufferString("%s", level);
101 104
 
102
-    mRender->ClearWorld();
103
-    mWorld.destroy();
104
-
105 105
     // Load the level pak into TombRaider
106 106
     gOpenRaider->mConsole->print("Loading %s", mName);
107 107
     int error = mTombRaider.Load(mName, percentCallbackTrampoline, this);
@@ -159,15 +159,28 @@ void Game::handleAction(ActionEvents action, bool isFinished) {
159 159
 
160 160
 void Game::handleMouseMotion(int xrel, int yrel) {
161 161
     if (mLoaded) {
162
-
162
+        if (xrel > 0)
163
+            while (xrel-- > 0)
164
+                mCamera->command(CAMERA_ROTATE_RIGHT);
165
+        else if (xrel < 0)
166
+            while (xrel++ < 0)
167
+                mCamera->command(CAMERA_ROTATE_LEFT);
168
+
169
+        if (yrel > 0)
170
+            while (yrel-- > 0)
171
+                mCamera->command(CAMERA_ROTATE_UP);
172
+        else if (yrel < 0)
173
+            while (yrel++ < 0)
174
+                mCamera->command(CAMERA_ROTATE_DOWN);
175
+
176
+        if (mLara) {
177
+            mLara->angles[1] = mCamera->getRadianYaw();
178
+            mLara->angles[2] = mCamera->getRadianPitch();
179
+        }
163 180
     }
164 181
 }
165 182
 
166 183
 void Game::display() {
167
-    if (mLoaded) {
168
-
169
-    }
170
-
171 184
     mRender->Display();
172 185
 }
173 186
 

+ 2
- 0
src/OpenRaider.cpp ファイルの表示

@@ -667,6 +667,8 @@ void OpenRaider::handleKeyboard(KeyboardButton key, bool pressed) {
667 667
     } else {
668 668
         mMenu->handleKeyboard(key, pressed);
669 669
     }
670
+
671
+    mWindow->setMousegrab(!(mMenu->isVisible() || mConsole->isVisible()));
670 672
 }
671 673
 
672 674
 void OpenRaider::handleText(char *text, bool notFinished) {

読み込み中…
キャンセル
保存