summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/chunk-scenery.cpp2
-rw-r--r--src/critter.cpp (renamed from src/character.cpp)36
-rw-r--r--src/critter.hpp (renamed from src/character.hpp)20
-rw-r--r--src/object-type.hpp2
4 files changed, 30 insertions, 30 deletions
diff --git a/src/chunk-scenery.cpp b/src/chunk-scenery.cpp
index d211b6a4..6fc48821 100644
--- a/src/chunk-scenery.cpp
+++ b/src/chunk-scenery.cpp
@@ -122,7 +122,7 @@ auto chunk::make_topo_sort_data(object& e, uint32_t mesh_idx) -> topo_sort_data
break;
}
}
- else if (e.type() == object_type::character)
+ else if (e.type() == object_type::critter)
data.mode = topo_sort_data::mode_character;
return data;
}
diff --git a/src/character.cpp b/src/critter.cpp
index 3e252e7a..9111aaf6 100644
--- a/src/character.cpp
+++ b/src/critter.cpp
@@ -1,4 +1,4 @@
-#include "character.hpp"
+#include "critter.hpp"
#include "src/anim-atlas.hpp"
#include "loader/loader.hpp"
#include "src/world.hpp"
@@ -85,17 +85,17 @@ constexpr std::array<rotation, 3> rotation_to_similar(rotation r)
} // namespace
-character_proto::character_proto(const character_proto&) = default;
-character_proto::~character_proto() noexcept = default;
-character_proto& character_proto::operator=(const character_proto&) = default;
+critter_proto::critter_proto(const critter_proto&) = default;
+critter_proto::~critter_proto() noexcept = default;
+critter_proto& critter_proto::operator=(const critter_proto&) = default;
-character_proto::character_proto()
+critter_proto::critter_proto()
{
- type = object_type::character;
+ type = object_type::critter;
atlas = loader.anim_atlas("npc-walk", loader.ANIM_PATH);
}
-bool character_proto::operator==(const object_proto& e0) const
+bool critter_proto::operator==(const object_proto& e0) const
{
if (type != e0.type)
return false;
@@ -103,11 +103,11 @@ bool character_proto::operator==(const object_proto& e0) const
if (!object_proto::operator==(e0))
return false;
- const auto& s0 = static_cast<const character_proto&>(e0);
+ const auto& s0 = static_cast<const critter_proto&>(e0);
return name == s0.name && playable == s0.playable;
}
-int character::allocate_frame_time(float dt)
+int critter::allocate_frame_time(float dt)
{
int d = int(delta) + int(65535u * dt);
constexpr int framerate_ = 65535/framerate;
@@ -117,14 +117,14 @@ int character::allocate_frame_time(float dt)
return ret;
}
-Vector2 character::move_vec(Vector2i vec)
+Vector2 critter::move_vec(Vector2i vec)
{
const int left_right = vec[0], top_bottom = vec[1];
constexpr auto c = move_speed * frame_time;
return c * Vector2((float)sgn(left_right), (float)sgn(top_bottom)).normalized();
}
-void character::set_keys(bool L, bool R, bool U, bool D)
+void critter::set_keys(bool L, bool R, bool U, bool D)
{
b_L = L;
b_R = R;
@@ -132,18 +132,18 @@ void character::set_keys(bool L, bool R, bool U, bool D)
b_D = D;
}
-float character::depth_offset() const
+float critter::depth_offset() const
{
return tile_shader::character_depth_offset;
}
-Vector2 character::ordinal_offset(Vector2b offset) const
+Vector2 critter::ordinal_offset(Vector2b offset) const
{
(void)offset;
return Vector2(offset);
}
-void character::update(size_t i, float dt)
+void critter::update(size_t i, float dt)
{
const auto new_r = arrows_to_dir(b_L, b_R, b_U, b_D);
if (new_r == rotation{rotation_COUNT})
@@ -195,18 +195,18 @@ done:
}
}
-object_type character::type() const noexcept { return object_type::character; }
+object_type critter::type() const noexcept { return object_type::critter; }
-character::operator character_proto() const
+critter::operator critter_proto() const
{
- character_proto ret;
+ critter_proto ret;
static_cast<object_proto&>(ret) = object::operator object_proto();
ret.name = name;
ret.playable = playable;
return ret;
}
-character::character(object_id id, struct chunk& c, const character_proto& proto) :
+critter::critter(object_id id, struct chunk& c, const critter_proto& proto) :
object{id, c, proto},
name{proto.name},
playable{proto.playable}
diff --git a/src/character.hpp b/src/critter.hpp
index 2c7543a5..34ff9b33 100644
--- a/src/character.hpp
+++ b/src/critter.hpp
@@ -9,22 +9,22 @@ namespace floormat {
struct anim_atlas;
struct world;
-struct character_proto : object_proto
+struct critter_proto : object_proto
{
String name;
bool playable : 1 = false;
- character_proto();
- character_proto(const character_proto&);
- ~character_proto() noexcept override;
- character_proto& operator=(const character_proto&);
+ 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 character final : object
+struct critter final : object
{
object_type type() const noexcept override;
- explicit operator character_proto() const;
+ explicit operator critter_proto() const;
void update(size_t i, float dt) override;
void set_keys(bool L, bool R, bool U, bool D);
@@ -41,10 +41,10 @@ private:
static Vector2 move_vec(Vector2i vec);
friend struct world;
- character(object_id id, struct chunk& c, const character_proto& proto);
+ critter(object_id id, struct chunk& c, const critter_proto& proto);
};
-template<> struct object_type_<struct character> : std::integral_constant<object_type, object_type::character> {};
-template<> struct object_type_<struct character_proto> : std::integral_constant<object_type, object_type::character> {};
+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
diff --git a/src/object-type.hpp b/src/object-type.hpp
index 1a1d1aff..3a6a92e9 100644
--- a/src/object-type.hpp
+++ b/src/object-type.hpp
@@ -3,7 +3,7 @@
namespace floormat {
enum class object_type : unsigned char {
- none, character, scenery, light,
+ none, critter, scenery, light,
};
constexpr inline size_t object_type_BITS = 3;