Implemented picking up objects and dropping them. Also, made transform part of GameObject instead of a separate component.
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include <math/GameMath.h>
|
||||
#include <cmath>
|
||||
|
||||
namespace farmlands {
|
||||
|
||||
@@ -36,4 +37,16 @@ void translate(float x, float y, model::Direction direction, float distance, flo
|
||||
*outY = y + dy * distance;
|
||||
}
|
||||
|
||||
void moveTowards(float *x, float *y, float towardsX, float towardsY, float speed)
|
||||
{
|
||||
float angle = atan2f(towardsX - *x, towardsY - *y);
|
||||
*x += cosf(angle) * speed;
|
||||
*y += sinf(angle) * speed;
|
||||
}
|
||||
|
||||
float distanceSq(float x0, float y0, float x1, float y1)
|
||||
{
|
||||
return (x0 - x1) * (x0 - x1) + (y0 - y1) * (y0 - y1);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -24,7 +24,9 @@ namespace farmlands {
|
||||
return value;
|
||||
}
|
||||
|
||||
void translate(float x, float y, model::Direction direction, float distance, float* outX, float *outY);
|
||||
void translate(float x, float y, model::Direction direction, float distance, float* outX, float* outY);
|
||||
void moveTowards(float *x, float *y, float towardsX, float towardsY, float speed);
|
||||
float distanceSq(float x0, float y0, float x1, float y1);
|
||||
|
||||
}
|
||||
#endif /* MATH_GAMEMATH_H_ */
|
||||
|
Reference in New Issue
Block a user