feat: added truck

main
Sara 2025-01-09 21:57:34 +01:00
parent 5109df0e6e
commit 200b621fde
2 changed files with 36 additions and 0 deletions

17
src/truck.cpp Normal file
View File

@ -0,0 +1,17 @@
#include "truck.hpp"
#include "core/callable.hpp"
#include "core/collision_shape.hpp"
#include "core/sprite.hpp"
Truck::Truck(float x_pos)
: ce::CollidableNode("truck", 0x1u, 0x1u)
, sprite{this->create_child<ce::Sprite>("sprite", "truck")}
, shape{this->create_child<ce::CollisionShape>("truck_col_shape", this, ce::Shape::make_box(2.f, 2.f))} {
this->sprite->set_global_transform(this->get_global_transform()
.scaled({2.5f, 2.5f})
.translated({x_pos, -3.f})
);
}
void Truck::_tick(double const &delta) {
}

19
src/truck.hpp Normal file
View File

@ -0,0 +1,19 @@
#ifndef TRUCK_HPP
#define TRUCK_HPP
#include "core/collidable_node.hpp"
namespace ce {
class Sprite;
class CollisionShape;
};
class Truck : public ce::CollidableNode {
ce::Sprite *sprite{nullptr};
ce::CollisionShape *shape{nullptr};
public:
Truck(float x_pos);
virtual void _tick(double const &delta) override;
};
#endif // !TRUCK_HPP