diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-09-01 22:36:26 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-09-01 22:36:26 +0200 |
commit | d90c38ce59d406cdfd4303c836ee524a71ad0979 (patch) | |
tree | 27c7bae59fbea84529977f588f050d5ce09e14ea /src/critter.hpp | |
parent | 31fd5bbc08234686cf798a93a18e0bb73615d1bf (diff) |
rename character -> critter
Diffstat (limited to 'src/critter.hpp')
-rw-r--r-- | src/critter.hpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/critter.hpp b/src/critter.hpp new file mode 100644 index 00000000..34ff9b33 --- /dev/null +++ b/src/critter.hpp @@ -0,0 +1,50 @@ +#pragma once +#include "src/global-coords.hpp" +#include "src/rotation.hpp" +#include "src/object.hpp" +#include <Corrade/Containers/String.h> + +namespace floormat { + +struct anim_atlas; +struct world; + +struct critter_proto : object_proto +{ + String name; + bool playable : 1 = false; + + critter_proto(); + critter_proto(const critter_proto&); + ~critter_proto() noexcept override; + critter_proto& operator=(const critter_proto&); + bool operator==(const object_proto& proto) const override; +}; + +struct critter final : object +{ + object_type type() const noexcept override; + explicit operator critter_proto() const; + + void update(size_t i, float dt) override; + void set_keys(bool L, bool R, bool U, bool D); + Vector2 ordinal_offset(Vector2b offset) const override; + float depth_offset() const override; + + String name; + Vector2s offset_frac; + bool b_L : 1 = false, b_R : 1 = false, b_U : 1 = false, b_D : 1 = false; + bool playable : 1 = false; + +private: + int allocate_frame_time(float dt); + static Vector2 move_vec(Vector2i vec); + + friend struct world; + critter(object_id id, struct chunk& c, const critter_proto& proto); +}; + +template<> struct object_type_<struct critter> : std::integral_constant<object_type, object_type::critter> {}; +template<> struct object_type_<struct critter_proto> : std::integral_constant<object_type, object_type::critter> {}; + +} // namespace floormat |