-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
311 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Git LFS file not shown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
name = Rocket | ||
Rigidbody { | ||
} | ||
Transform { | ||
} | ||
StaticMesh { | ||
mesh = Resources\Meshes\rocket.obj | ||
material = Resources\Materials\cardboard_enemy.material | ||
} | ||
Rocket { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#include "Rocket.h" | ||
|
||
#include "Scene/Transform.h" | ||
#include "Scene/Helicopter.h" | ||
#include "Physics/Rigidbody.h" | ||
|
||
#include "SceneManager.h" | ||
|
||
#include "imgui.h" | ||
|
||
Rocket::Rocket(GameObject* gameObject) | ||
: Component(gameObject), | ||
transform_(gameObject->createComponent<Transform>()), | ||
speed_(100.0f), | ||
damage_(15.0f) | ||
{ | ||
// Initialise rotation | ||
transform_->setRotationLocal(Quaternion::identity()); | ||
} | ||
|
||
void Rocket::drawProperties() | ||
{ | ||
ImGui::DragFloat("Rocket speed", &speed_, 0.1f); | ||
} | ||
|
||
void Rocket::handleCollision(Collider* collider) | ||
{ | ||
Helicopter* chopper = collider->gameObject()->findComponent<Helicopter>(); | ||
if (chopper != nullptr) | ||
{ | ||
chopper->takeDamage(damage_); | ||
} | ||
|
||
// Delete gameObject on collision | ||
delete gameObject(); | ||
} | ||
|
||
void Rocket::setRocketSpeed(float speed) | ||
{ | ||
speed_ = speed; | ||
} | ||
void Rocket::initRocket(const Point3& pos, const Quaternion& rot) | ||
{ | ||
transform_->setPositionLocal(pos); | ||
transform_->setRotationLocal(rot); | ||
|
||
// Create rigidbody for collisions | ||
gameObject()->createComponent<Rigidbody>(); | ||
Rigidbody* collider = gameObject()->findComponent<Rigidbody>(); | ||
|
||
// Calculate velocity and send to rigidbody component | ||
Vector3 velocity = transform_->forwards() * speed_; | ||
collider->setVelocity(velocity); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#pragma once | ||
|
||
#include "Scene/Component.h" | ||
#include "Math/Vector3.h" | ||
|
||
class Transform; | ||
class Quaternion; | ||
|
||
class Rocket : public Component | ||
{ | ||
public: | ||
Rocket(GameObject* gameObject); | ||
|
||
void drawProperties() override; | ||
void handleCollision(Collider* collider) override; | ||
|
||
void setRocketSpeed(float speed); | ||
void initRocket(const Point3& pos, const Quaternion& rot); | ||
|
||
private: | ||
Transform* transform_; | ||
|
||
float speed_; | ||
float damage_; | ||
|
||
bool initialised_ = false; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.