diff options
Diffstat (limited to 'src/game.cpp')
-rw-r--r-- | src/game.cpp | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/src/game.cpp b/src/game.cpp index f435a4d71..02308b65d 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -977,6 +977,8 @@ bool nodePlacementPrediction(Client &client, return false; } +bool is_third_person = false; + static void show_chat_menu(FormspecFormSource* current_formspec, TextDest* current_textdest, IWritableTextureSource* tsrc, IrrlichtDevice * device, Client* client, std::string text) @@ -1470,6 +1472,8 @@ void the_game(bool &kill, bool random_input, InputHandler *input, f32 camera_yaw = 0; // "right/left" f32 camera_pitch = 0; // "up/down" + int current_camera_mode = CAMERA_MODE_FIRST; // start in first-person view + /* Clouds */ @@ -2251,7 +2255,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input, else{ s32 dx = input->getMousePos().X - displaycenter.X; s32 dy = input->getMousePos().Y - displaycenter.Y; - if(invert_mouse) + if(invert_mouse || player->camera_mode == CAMERA_MODE_THIRD_FRONT) dy = -dy; //infostream<<"window active, pos difference "<<dx<<","<<dy<<std::endl; @@ -2659,9 +2663,21 @@ void the_game(bool &kill, bool random_input, InputHandler *input, LocalPlayer* player = client.getEnv().getLocalPlayer(); float full_punch_interval = playeritem_toolcap.full_punch_interval; float tool_reload_ratio = time_from_last_punch / full_punch_interval; + + if(input->wasKeyDown(getKeySetting("keymap_camera_mode"))) { + + if (current_camera_mode == CAMERA_MODE_FIRST) + current_camera_mode = CAMERA_MODE_THIRD; + else if (current_camera_mode == CAMERA_MODE_THIRD) + current_camera_mode = CAMERA_MODE_THIRD_FRONT; + else + current_camera_mode = CAMERA_MODE_FIRST; + + } + player->camera_mode = current_camera_mode; tool_reload_ratio = MYMIN(tool_reload_ratio, 1.0); - camera.update(player, dtime, busytime, screensize, - tool_reload_ratio); + camera.update(player, dtime, busytime, screensize, tool_reload_ratio, + current_camera_mode, client.getEnv()); camera.step(dtime); v3f player_position = player->getPosition(); @@ -2717,6 +2733,10 @@ void the_game(bool &kill, bool random_input, InputHandler *input, core::line3d<f32> shootline(camera_position, camera_position + camera_direction * BS * (d+1)); + // prevent player pointing anything in front-view + if (current_camera_mode == CAMERA_MODE_THIRD_FRONT) + shootline = core::line3d<f32>(0,0,0,0,0,0); + ClientActiveObject *selected_object = NULL; PointedThing pointed = getPointedThing( @@ -3507,7 +3527,9 @@ void the_game(bool &kill, bool random_input, InputHandler *input, /* Wielded tool */ - if(show_hud && (player->hud_flags & HUD_FLAG_WIELDITEM_VISIBLE)) + if(show_hud && + (player->hud_flags & HUD_FLAG_WIELDITEM_VISIBLE) && + current_camera_mode < CAMERA_MODE_THIRD) { // Warning: This clears the Z buffer. camera.drawWieldedTool(); |