diff options
author | Stijn Buys <ingar@osirion.org> | 2008-02-13 18:29:55 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2008-02-13 18:29:55 +0000 |
commit | ee891311ccc79bbc7837caac8546aac5b9bdf80f (patch) | |
tree | 4279b0bec63d2152669b19d1f11199c56ae57b7b /src/client | |
parent | a65427370dfe27dfa74efb0bddd44d7ffb9552ac (diff) |
camera Overview as spectator only, join works
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/camera.cc | 103 | ||||
-rw-r--r-- | src/client/client.cc | 2 | ||||
-rw-r--r-- | src/client/video.cc | 4 |
3 files changed, 61 insertions, 48 deletions
diff --git a/src/client/camera.cc b/src/client/camera.cc index 85929cc..f274e12 100644 --- a/src/client/camera.cc +++ b/src/client/camera.cc @@ -77,18 +77,71 @@ void shutdown() { } +void set_mode(Mode newmode) { + switch(newmode) { + case Track: + // switch camera to Track mode + mode = Track; + yaw_target = core::localplayer.controled->direction; + yaw_current = yaw_target; + pitch_target = pitch_track; + pitch_current = pitch_target; + distance = 0.4f; + break; + case Free: + // switch camera to Free mode + mode = Free; + yaw_target = core::localplayer.controled->direction; + yaw_current = yaw_target; + pitch_target = pitch_track; + pitch_current = pitch_target; + distance = 0.4f; + break; + case Overview: + // switch camera to Overview mode + mode = Overview; + x_offset = 0; + z_offset = 0; + distance = 20.0f; + default: + break; + } + +} + +void next_mode() +{ + + if (!core::localplayer.controled) { + set_mode(Overview); + return; + } + + switch(mode) { + case Free: + // switch camera to Track mode + set_mode(Track); + break; + case Track: + // switch camera to Free mode + set_mode(Free); + break; + default: + break; + } +} + void draw(float elapsed) { if (!core::localplayer.controled) { // switch the camera to Overview of the player is not controling anything if (mode != Overview) { - mode = Overview; - target = math::Vector3f(0,0,0); - x_offset = 0; - z_offset = 0; - distance = 20.0f; + set_mode(Overview); } } else { + if (mode == Overview) + set_mode(Track); + camera::target = core::localplayer.controled->location; } @@ -168,46 +221,6 @@ void key_down() } } -void next_mode() { - - if (!core::localplayer.controled) { - mode = Overview; - target = math::Vector3f(0,0,0); - x_offset = 0; - z_offset = 0; - distance = 20.0f; - } - - switch(mode) { - case Overview: - // switch camera to Track mode - mode = Track; - yaw_target = core::localplayer.controled->direction; - yaw_current = yaw_target; - pitch_target = pitch_track; - pitch_current = pitch_target; - distance = 0.4f; - break; - case Track: - // switch camera to Free mode - mode = Free; - yaw_target = core::localplayer.controled->direction; - yaw_current = yaw_target; - pitch_target = pitch_track; - pitch_current = pitch_target; - distance = 0.4f; - break; - case Free: - // switch camera to Overview mode - mode = Overview; - x_offset = 0; - z_offset = 0; - distance = 20.0f; - default: - break; - } -} - } // namespace camera } // namespace client diff --git a/src/client/client.cc b/src/client/client.cc index 6ae6ba8..214ba2f 100644 --- a/src/client/client.cc +++ b/src/client/client.cc @@ -83,7 +83,7 @@ void Client::init() con_print << "Initializing client..." << std::endl; // initialize core - core::localplayer.name = "Client"; + core::sv_dedicated = core::cvar::get("sv_dedicated", "0", core::cvar::ReadOnly); core::Application::init(); // initialize SDL, but do not initialize any subsystems diff --git a/src/client/video.cc b/src/client/video.cc index 19555ec..1a1f5e2 100644 --- a/src/client/video.cc +++ b/src/client/video.cc @@ -60,13 +60,13 @@ bool init() int flags = 0; if( SDL_InitSubSystem(SDL_INIT_VIDEO) < 0 ) { - std::cerr << "SDL_Init() failed: " << SDL_GetError() << std::endl; + con_error << "SDL_InitSubSystem() failed: " << SDL_GetError() << std::endl; return false; } const SDL_VideoInfo* sdl_videoinfo = SDL_GetVideoInfo(); if( !sdl_videoinfo) { - std::cerr << "SDL_GetVideoInfo() failed: " << SDL_GetError() << std::endl; + con_error << "SDL_GetVideoInfo() failed: " << SDL_GetError() << std::endl; return false; } |