first commit
This commit is contained in:
68
src/ecs/TransformComponent.h
Normal file
68
src/ecs/TransformComponent.h
Normal file
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* TransformComponent.h
|
||||
*
|
||||
* Created on: Feb 22, 2020
|
||||
* Author: ayoungblood
|
||||
*/
|
||||
|
||||
#ifndef SRC_ECS_TransformComponent_H_
|
||||
#define SRC_ECS_TransformComponent_H_
|
||||
|
||||
#include "Components.h"
|
||||
#include "../game/Vector2D.h"
|
||||
|
||||
class TransformComponent : public Component
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
Vector2D position;
|
||||
Vector2D velocity;
|
||||
|
||||
int height = 40;
|
||||
int width = 30;
|
||||
int scale = 1;
|
||||
int speed = 2;
|
||||
|
||||
TransformComponent()
|
||||
{
|
||||
position.Zero();
|
||||
}
|
||||
|
||||
TransformComponent(int sc)
|
||||
{
|
||||
position.x = 64*sc;
|
||||
position.y = 80*sc;
|
||||
scale = sc;
|
||||
speed = speed*sc;
|
||||
}
|
||||
|
||||
TransformComponent(float x, float y)
|
||||
{
|
||||
position.Zero();
|
||||
}
|
||||
|
||||
TransformComponent(int x, int y, int w, int h, int sc)
|
||||
{
|
||||
position.x = x;
|
||||
position.y = y;
|
||||
width = w;
|
||||
height = h;
|
||||
scale = sc;
|
||||
speed = speed*sc;
|
||||
}
|
||||
|
||||
void init() override
|
||||
{
|
||||
velocity.Zero();
|
||||
}
|
||||
void update() override
|
||||
{
|
||||
position.x += velocity.x * speed;
|
||||
position.y += velocity.y * speed;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif /* SRC_ECS_TransformComponent_H_ */
|
Reference in New Issue
Block a user