real camera movement!

This commit is contained in:
Titus Tscharntke 2011-04-10 21:38:29 +00:00
parent 3e3b774dd5
commit daf8f42f7e
2 changed files with 28 additions and 4 deletions

View File

@ -95,6 +95,7 @@ Game::Game(Program *program, const GameSettings *gameSettings):
renderNetworkStatus= false;
speed= sNormal;
showFullConsole= false;
cameraKeyboardDirection=camNone;
Object::setStateCallback(&gui);
@ -1300,6 +1301,7 @@ void Game::mouseMove(int x, int y, const MouseState *ms) {
else {
//main window
//if(Window::isKeyDown() == false)
if(cameraKeyboardDirection == camNone)
{
if (y < 10) {
gameCamera.setMoveZ(-scrollSpeed);
@ -1434,18 +1436,22 @@ void Game::keyDown(char key) {
//move camera left
else if(key == configKeys.getCharKey("CameraModeLeft")) {
gameCamera.setMoveX(-1);
cameraKeyboardDirection=camLeft;
}
//move camera right
else if(key == configKeys.getCharKey("CameraModeRight")) {
gameCamera.setMoveX(1);
cameraKeyboardDirection=camRight;
}
//move camera up
else if(key == configKeys.getCharKey("CameraModeUp")) {
gameCamera.setMoveZ(1);
cameraKeyboardDirection=camUp;
}
//move camera down
else if(key == configKeys.getCharKey("CameraModeDown")) {
gameCamera.setMoveZ(-1);
cameraKeyboardDirection=camDown;
}
//change camera mode
else if(key == configKeys.getCharKey("FreeCameraMode")) {
@ -1568,13 +1574,22 @@ void Game::keyUp(char key){
key == configKeys.getCharKey("CameraRotateUp")) {
gameCamera.setMoveY(0);
}
else if(key == configKeys.getCharKey("CameraModeUp") ||
key == configKeys.getCharKey("CameraModeDown")) {
else if(key == configKeys.getCharKey("CameraModeUp") && cameraKeyboardDirection == camUp){
gameCamera.setMoveZ(0);
cameraKeyboardDirection= camNone;
}
else if(key == configKeys.getCharKey("CameraModeLeft") ||
key == configKeys.getCharKey("CameraModeRight")) {
else if(key == configKeys.getCharKey("CameraModeDown") && cameraKeyboardDirection == camDown){
gameCamera.setMoveZ(0);
cameraKeyboardDirection= camNone;
}
else if(key == configKeys.getCharKey("CameraModeLeft") && cameraKeyboardDirection == camLeft){
gameCamera.setMoveX(0);
cameraKeyboardDirection= camNone;
}
else if(key == configKeys.getCharKey("CameraModeRight") && cameraKeyboardDirection == camRight){
gameCamera.setMoveX(0);
cameraKeyboardDirection= camNone;
}
}
}

View File

@ -63,6 +63,14 @@ private:
typedef vector<Ai*> Ais;
typedef vector<AiInterface*> AiInterfaces;
enum CameraKeyboardDirection{
camNone,
camLeft,
camRight,
camUp,
camDown
};
private:
//main data
World world;
@ -88,6 +96,7 @@ private:
bool showFullConsole;
bool mouseMoved;
float scrollSpeed;
CameraKeyboardDirection cameraKeyboardDirection;
Speed speed;
GraphicMessageBox mainMessageBox;
GraphicMessageBox errorMessageBox;