feat: initialized template and wrote first gameplay code
This commit is contained in:
parent
82f2cae0f6
commit
46a958f801
47 changed files with 1093 additions and 33 deletions
38
modules/wave_survival/player_camera.cpp
Normal file
38
modules/wave_survival/player_camera.cpp
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
#include "player_camera.h"
|
||||
#include "macros.h"
|
||||
#include "player_input.h"
|
||||
|
||||
void PlayerCamera::_bind_methods() {
|
||||
}
|
||||
|
||||
void PlayerCamera::on_look_input(Vector2 input) {
|
||||
GETSET(rotation, {
|
||||
rotation.x = CLAMP(rotation.x + input.y, -Math::PI / 2.0, Math::PI / 2.0);
|
||||
});
|
||||
}
|
||||
|
||||
void PlayerCamera::update_fov() {
|
||||
if (!Engine::get_singleton()->is_editor_hint() && is_ready()) {
|
||||
set_fov(this->base_fov * this->fov_factor);
|
||||
}
|
||||
}
|
||||
|
||||
void PlayerCamera::_notification(int what) {
|
||||
if (Engine::get_singleton()->is_editor_hint()) {
|
||||
return;
|
||||
}
|
||||
if (what == NOTIFICATION_READY) {
|
||||
PlayerInput *input{ cast_to<PlayerInput>(get_node(NodePath("%PlayerInput"))) };
|
||||
input->connect(PlayerInput::sig_look_input, callable_mp(this, &self_type::on_look_input));
|
||||
this->base_fov = get_fov();
|
||||
}
|
||||
}
|
||||
|
||||
void PlayerCamera::set_fov_factor(float value) {
|
||||
this->fov_factor = value;
|
||||
update_fov();
|
||||
}
|
||||
|
||||
float PlayerCamera::get_fov_factor() const {
|
||||
return this->fov_factor;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue