Skip to content

Commit

Permalink
#39: Implemented Flagella class with movement force vector, began bin…
Browse files Browse the repository at this point in the history
…ding to CellState
  • Loading branch information
hpfluke0478 committed Jan 23, 2024
1 parent c5452c9 commit f7724bc
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
34 changes: 33 additions & 1 deletion src/cell_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ CellState::CellState() {
_age = 0;
_lifespan = 1;
_scale = 1;
_flagella = Flagella;
}
CellState::~CellState() {}

Expand Down Expand Up @@ -44,4 +45,35 @@ void CellState::applyScale(const float scale) {
if (scale <= 0)
_scale *= scale;
}
float CellState::getScale() const { return _scale; }
float CellState::getScale() const { return _scale; }

void CellState::setMovementForce(const Vector2 &force) {
if (_flagella) {
_flagella = setMovementForce(force)
}
}

void CellState::getMovementForce() const {
return _flagella ? _flagella->getMovementForce() : Vector2():
}

void Flagella:_bind_methods() {
ClassDB::bind_method(D_METHOD("set_movement_force", "force"),
&Flagella::setMovementForce);
ClassDB::bind_method(D_METHOD("get_movement_force", &Flagella:getMovementForce));
ClassDB::add_property("Flagella", PropertyInfo(Variant::VECTOR2, "movement_force"),
"set_movement_force", "get_lifespan");
}

Flagella::Flagella() {
_movement_force = Vector2();
}
Flagella::~Flagella() {}

void Flagella::setMovementForce(const Vector2 &force) {
_movement_force = force;
}

Vector2 Flagella::getMovementForce() const {
return _movement_force;
}
22 changes: 22 additions & 0 deletions src/cell_state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,33 @@ class CellState : public Node {
void applyScale(const float);
float getScale() const;

void setMovementForce(const Vector2 &force);
Vector2 getMovementForce() const;

private:
bool _alive;
float _age;
float _lifespan;
float _scale;
Ref<Flagella> _flagella;
};

class Flagella : public Node {
GDCLASS(Flagella, Node);

protected:
static void _bind_methods():

public:
Flagella():
~Flagella():

void setMovementForce(const Vector2 &force);
Vector2 getMovementForce() const;

private:
Vector2 _movement_force;

};

}; // namespace godot

0 comments on commit f7724bc

Please sign in to comment.