Skip to content

Commit

Permalink
r
Browse files Browse the repository at this point in the history
  • Loading branch information
JackAshwell11 committed Feb 16, 2024
1 parent 0c16d8b commit 851b90e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions hades_extensions/game_objects/components/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class MovementForce(Stat): ...

class KinematicComponent(ComponentBase):
def __init__(self: KinematicComponent, vertices: list[cpVect]) -> None: ...
def get_position(self: KinematicComponent) -> cpVect: ...

class StatusEffect:
value: float
Expand Down
6 changes: 3 additions & 3 deletions src/hades/views/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,11 @@ def on_update(self: Game, delta_time: float) -> None:
GameObjectType.ENEMY,
[],
):
entity.position = self.registry.get_component(
pos = self.registry.get_component(
entity.game_object_id,
KinematicComponent,
).body.p
# TODO: Need to get position
).get_position()
entity.position = (pos.x, pos.y)

# Update the indicator bars
for indicator_bar in self.indicator_bars:
Expand Down
6 changes: 5 additions & 1 deletion src/hades_extensions/src/binding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,11 @@ PYBIND11_MODULE(hades_extensions, module) { // NOLINT
.def(pybind11::init<std::vector<cpVect>>(), pybind11::arg("vertices"),
"Initialise the object.\n\n"
"Args:\n"
" vertices: The vertices of the shape.");
" vertices: The vertices of the shape.")
.def("get_position", [](const KinematicComponent &kinematic_component) { return cpBodyGetPosition(*kinematic_component.body); },
"Get the position of the game object.\n\n"
"Returns:\n"
" The position of the game object.");
pybind11::class_<PhysicsSystem, SystemBase, std::shared_ptr<PhysicsSystem>>(
systems, "PhysicseSystem", "Provides facilities to manipulate game object's physics.")
.def(pybind11::init<Registry *>(), pybind11::arg("registry"),
Expand Down

0 comments on commit 851b90e

Please sign in to comment.