diff options
Diffstat (limited to 'game/player/PlayerScript.h')
-rw-r--r-- | game/player/PlayerScript.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/game/player/PlayerScript.h b/game/player/PlayerScript.h new file mode 100644 index 0000000..6a7dedb --- /dev/null +++ b/game/player/PlayerScript.h @@ -0,0 +1,32 @@ +#pragma once + +#include "util/OptionalRef.h" +#include <chrono> +#include <crepe/api/Config.h> +#include <crepe/api/Event.h> +#include <crepe/api/Script.h> + +class PlayerScript : public crepe::Script { +public: + void init(); + void fixed_update(crepe::duration_t dt); + +private: + bool on_collision(const crepe::CollisionEvent & ev); + bool on_key_down(const crepe::KeyPressEvent & ev); + bool on_key_up(const crepe::KeyReleaseEvent & ev); + // bool on_key_up(const crepe::KeyReleaseEvent& ev); + void shoot(const crepe::vec2 & location, float angle); + void help_kick(const crepe::vec2 & direction); + +private: + int prev_anim = 0; + std::chrono::time_point<std::chrono::steady_clock> last_fired; + std::chrono::time_point<std::chrono::steady_clock> last_switched; + std::chrono::duration<float> shot_delay = std::chrono::duration<float>(0.5); + std::chrono::duration<float> switch_delay = std::chrono::duration<float>(0.01); + int current_jetpack_sound = 0; + + float & engine_gravity = crepe::Config::get_instance().physics.gravity; + crepe::OptionalRef<crepe::Rigidbody> body; +}; |