first commit

This commit is contained in:
2021-01-29 21:14:20 -05:00
commit b2acceb4b9
78 changed files with 6774 additions and 0 deletions

View File

@ -0,0 +1,58 @@
/*
* Projectile.h
*
* Created on: Apr 4, 2020
* Author: ayoungblood
*/
#ifndef SRC_ECS_PROJECTILECOMPONENT_H_
#define SRC_ECS_PROJECTILECOMPONENT_H_
#include "ECS.h"
#include "Components.h"
#include "../game/Vector2D.h"
class ProjectileComponent : public Component
{
public:
ProjectileComponent(int rng, int sp, Vector2D vel) : range(rng), speed(sp), velocity(vel)
{}
~ProjectileComponent()
{}
void init() override
{
transform = &entity->getComponent<TransformComponent>();
transform->velocity = velocity;
// std::cout << transform->position << std::endl;
}
void update() override
{
distance += speed;
if (distance > range)
{
entity->destroy();
}
else if (transform->position.x > Game::camera.x + Game::camera.w ||
transform->position.x < Game::camera.x ||
transform->position.y > Game::camera.y +Game::camera.h ||
transform->position.y < Game::camera.y)
{
entity->destroy();
}
}
private:
TransformComponent* transform;
int range;
int speed;
int distance;
Vector2D velocity;
};
#endif /* SRC_ECS_PROJECTILECOMPONENT_H_ */