aboutsummaryrefslogtreecommitdiff
path: root/game/player/PlayerBulletScript.cpp
diff options
context:
space:
mode:
authorWBoerenkamps <wrj.boerenkamps@student.avans.nl>2025-01-08 13:52:43 +0100
committerWBoerenkamps <wrj.boerenkamps@student.avans.nl>2025-01-08 13:52:43 +0100
commitfcec9d7598f0808d4081120a9cb2036bdea59737 (patch)
tree4963d2f791a4c3ba27d357ad38345094a8e65fc4 /game/player/PlayerBulletScript.cpp
parent1413beea3b506b15b9f0080cec29c745d1ef88da (diff)
make format
Diffstat (limited to 'game/player/PlayerBulletScript.cpp')
-rw-r--r--game/player/PlayerBulletScript.cpp30
1 files changed, 15 insertions, 15 deletions
diff --git a/game/player/PlayerBulletScript.cpp b/game/player/PlayerBulletScript.cpp
index 6beb9f1..a76b7eb 100644
--- a/game/player/PlayerBulletScript.cpp
+++ b/game/player/PlayerBulletScript.cpp
@@ -1,41 +1,41 @@
#include <crepe/api/Camera.h>
-#include <crepe/api/Rigidbody.h>
#include <crepe/api/Metadata.h>
+#include <crepe/api/Rigidbody.h>
#include "PlayerBulletScript.h"
using namespace crepe;
using namespace std;
-void PlayerBulletScript::init(){
- this->subscribe<CollisionEvent>([this](const CollisionEvent& e) -> bool {
+void PlayerBulletScript::init() {
+ this->subscribe<CollisionEvent>([this](const CollisionEvent & e) -> bool {
return this->on_collide(e);
});
}
-void PlayerBulletScript::fixed_update(crepe::duration_t dt){
- Transform& transform = this->get_component<Transform>();
- Camera& camera = this->get_components_by_name<Camera>("camera").front();
- Transform& cam_transform = this->get_components_by_name<Transform>("camera").front();
- Rigidbody& bullet_body = this->get_component<Rigidbody>();
+void PlayerBulletScript::fixed_update(crepe::duration_t dt) {
+ Transform & transform = this->get_component<Transform>();
+ Camera & camera = this->get_components_by_name<Camera>("camera").front();
+ Transform & cam_transform = this->get_components_by_name<Transform>("camera").front();
+ Rigidbody & bullet_body = this->get_component<Rigidbody>();
transform.rotation += bullet_body.data.angular_velocity;
transform.position += bullet_body.data.linear_velocity * dt.count();
vec2 half_screen = camera.viewport_size / 2;
float despawn_location = cam_transform.position.x + half_screen.x + 50;
- if(transform.position.x > despawn_location){
+ if (transform.position.x > despawn_location) {
this->despawn_bullet();
}
}
-void PlayerBulletScript::despawn_bullet(){
- Transform& transform = this->get_component<Transform>();
- Rigidbody& bullet_body = this->get_component<Rigidbody>();
+void PlayerBulletScript::despawn_bullet() {
+ Transform & transform = this->get_component<Transform>();
+ Rigidbody & bullet_body = this->get_component<Rigidbody>();
bullet_body.active = false;
- BehaviorScript& bullet_script = this->get_component<BehaviorScript>();
+ BehaviorScript & bullet_script = this->get_component<BehaviorScript>();
bullet_script.active = false;
- transform.position = {0,-850};
+ transform.position = {0, -850};
}
-bool PlayerBulletScript::on_collide(const CollisionEvent& e){
+bool PlayerBulletScript::on_collide(const CollisionEvent & e) {
this->despawn_bullet();
return false;
}