You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.1 KiB
C++

#pragma once
#include "base.h"
namespace hexapod {
enum MovementMode {
MOVEMENT_STANDBY = 0,
MOVEMENT_FORWARD,
MOVEMENT_BACKWARD,
MOVEMENT_TURNLEFT,
MOVEMENT_TURNRIGHT,
MOVEMENT_SHIFTLEFT,
MOVEMENT_SHIFTRIGHT,
MOVEMENT_ROTATEX,
MOVEMENT_ROTATEY,
MOVEMENT_ROTATEZ,
MOVEMENT_TOTAL,
};
inline MovementMode operator++ (MovementMode& m, int) {
if (m < MOVEMENT_TOTAL)
m = static_cast<MovementMode>(static_cast<int>(m) + 1);
return m;
}
struct MovementTable {
const Locations* table;
int length;
int stepDuration;
const int* entries;
int entriesCount;
};
class Movement {
public:
Movement(MovementMode mode);
void setMode(MovementMode newMode);
const Locations& next(int elapsed);
private:
MovementMode mode_;
Locations position_;
int index_; // index in mode position table
bool transiting_; // if still in transiting to new mode
int remainTime_;
};
}