diff options
| author | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-08-27 15:48:50 +0000 |
|---|---|---|
| committer | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-08-27 15:48:50 +0000 |
| commit | dfe499248f1b1236487156b28e4a535d7963fe35 (patch) | |
| tree | a750b0f28cfd3f3e252602681412ac1adc6d29c7 /src/game/client/components/camera.cpp | |
| parent | d711dd190cac809a9bd278fba03ed974812bb863 (diff) | |
| download | zcatch-dfe499248f1b1236487156b28e4a535d7963fe35.tar.gz zcatch-dfe499248f1b1236487156b28e4a535d7963fe35.zip | |
major commit. game client restructure. not complete, loads of stuff not working, but the structure is there
Diffstat (limited to 'src/game/client/components/camera.cpp')
| -rw-r--r-- | src/game/client/components/camera.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/game/client/components/camera.cpp b/src/game/client/components/camera.cpp new file mode 100644 index 00000000..32442031 --- /dev/null +++ b/src/game/client/components/camera.cpp @@ -0,0 +1,45 @@ +extern "C" { + #include <engine/e_config.h> + #include <engine/e_client_interface.h> +} + +#include <base/math.hpp> +#include <game/collision.hpp> +#include <game/client/gameclient.hpp> +#include <game/client/component.hpp> + +#include "camera.hpp" +#include "controls.hpp" + +CAMERA::CAMERA() +{ +} + +void CAMERA::on_render() +{ + //vec2 center; + zoom = 1.0f; + + bool spectate = false; + + if(spectate) + center = gameclient.controls->mouse_pos; + else + { + + float l = length(gameclient.controls->mouse_pos); + float deadzone = config.cl_mouse_deadzone; + float follow_factor = config.cl_mouse_followfactor/100.0f; + vec2 camera_offset(0, 0); + + float offset_amount = max(l-deadzone, 0.0f) * follow_factor; + if(l > 0.0001f) // make sure that this isn't 0 + camera_offset = normalize(gameclient.controls->mouse_pos)*offset_amount; + + center = gameclient.local_character_pos + camera_offset; + } + + // set listner pos + snd_set_listener_pos(center.x, center.y); +} + |