summaryrefslogtreecommitdiffhomepage
path: root/src/character.hpp
blob: 9e2617ae8f57cdda3cafacb37b6ab3c4ea2227ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#pragma once
#include "src/global-coords.hpp"
#include "src/rotation.hpp"
#include "src/entity.hpp"
#include <memory>

namespace floormat {

struct anim_atlas;
struct world;

struct character final : entity
{
    ~character() override;
    void set_keys(bool L, bool R, bool U, bool D);
    bool update(std::size_t i, float dt) override;
    bool is_playable() const { return playable; }

private:
    int allocate_frame_time(float dt);
    static Vector2 move_vec(int left_right, int top_bottom);

    friend struct world;
    character(std::uint64_t id, struct chunk& c, entity_type type, bool playable);

    Vector2s offset_frac;
    bool b_L : 1 = false, b_R : 1 = false, b_U : 1 = false, b_D : 1 = false;
    bool playable : 1 = false;
};

template<> struct entity_type_<struct character> : std::integral_constant<entity_type, entity_type::character> {};

} // namespace floormat