Implemented some tools. Also, implemented inventory.
This commit is contained in:
@@ -7,4 +7,33 @@
|
||||
|
||||
#include <math/GameMath.h>
|
||||
|
||||
namespace farmlands {
|
||||
|
||||
static const float Sqrt2 = 1.41421356237309504880f;
|
||||
|
||||
static const float DirectionVectorX[] =
|
||||
{
|
||||
0, 1, 0, Sqrt2, // none, E, N, NE
|
||||
-1, 0, -Sqrt2, 0, // W, inv, NW, inv
|
||||
0, Sqrt2, 0, 0, // S, SE, inv, inv
|
||||
-Sqrt2, 0, 0, 0 // SW, inv, inv, inv
|
||||
};
|
||||
|
||||
static const float DirectionVectorY[] =
|
||||
{
|
||||
0, 0, -1, -Sqrt2, // none, E, N, NE
|
||||
0, 0, -Sqrt2, 0, // W, inv, NW, inv
|
||||
1, Sqrt2, 0, 0, // S, SE, inv, inv
|
||||
Sqrt2, 0, 0, 0 // SW, inv, inv, inv
|
||||
};
|
||||
|
||||
void translate(float x, float y, model::Direction direction, float distance, float* outX, float *outY)
|
||||
{
|
||||
float dx = DirectionVectorX[direction];
|
||||
float dy = DirectionVectorY[direction];
|
||||
|
||||
*outX = x + dx * distance;
|
||||
*outY = y + dy * distance;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -8,18 +8,23 @@
|
||||
#ifndef MATH_GAMEMATH_H_
|
||||
#define MATH_GAMEMATH_H_
|
||||
|
||||
template<typename TVal, typename TMin, typename TMax>
|
||||
TVal clamp (TVal value, TMin min, TMax max)
|
||||
{
|
||||
if (value < min)
|
||||
return min;
|
||||
#include <model/Direction.h>
|
||||
|
||||
if (value > max)
|
||||
return max;
|
||||
namespace farmlands {
|
||||
|
||||
template<typename TVal, typename TMin, typename TMax>
|
||||
TVal clamp (TVal value, TMin min, TMax max)
|
||||
{
|
||||
if (value < min)
|
||||
return min;
|
||||
|
||||
if (value > max)
|
||||
return max;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
void translate(float x, float y, model::Direction direction, float distance, float* outX, float *outY);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif /* MATH_GAMEMATH_H_ */
|
||||
|
Reference in New Issue
Block a user