simulation/Entity.cpp

30 lines
502 B
C++

#include "Entity.h"
#include <iostream>
Entity::Entity(Vec2 p, Vec2 s, Vec2 a):
pos(p), spe(s), acc(a)
{
}
void Entity::Update(){
pos = pos + spe + acc/2;
spe = spe + acc;
if(pos.y >= 1000){
spe.y = - spe.y + acc.y;
}
if(pos.x >= 1920){
pos.x = 0;
}
}
void Entity::Debug() const{
std::cout << "pos= (" << pos.x << ", " << pos.y << ")"
<< "spe= (" << spe.x << ", " << spe.y << ")"
<< "acc= (" << acc.x << ", " << acc.y << ")" << std::endl;
}
Vec2 Entity::GetPos(){
return pos;
}