Skip to content

Instantly share code, notes, and snippets.

@poseidon4o
Last active November 27, 2019 18:37
Show Gist options
  • Select an option

  • Save poseidon4o/6255fc9db34cc887a8ec4ef5f5332164 to your computer and use it in GitHub Desktop.

Select an option

Save poseidon4o/6255fc9db34cc887a8ec4ef5f5332164 to your computer and use it in GitHub Desktop.
#include <vector>
const int PLAYER_SPEED = 10;
const int ENEMY_SPEED = 15;
struct Point {
int x;
int y;
};
struct Box {
Point topLeft;
Point bottomRight;
};
struct EnemyPath {
Point start;
Point end;
};
struct LevelDescription {
std::vector<Box> playableArea; ///< The union of these boxes makes the level's area
Box start; ///< The starting area, the player starts at the center of this box
Box end; ///< The player needs to touch this box to finish succesfully
std::vector<EnemyPath> enemyPaths; ///< All enemies in the level, if a player touches them he looses
};
enum Direction {
directionNone = 0,
directionUp = 1 << 0,
directionDown = 1 << 1,
directionLeft = 1 << 2,
directionRight = 1 << 3,
};
/// Based on a level description generate what commands would a player give to complete the level
/// Direction may be combined, like directionDown | directionRight to move diagonally to down-right
std::vector<Direction> generateBestPath(const LevelDescription &level);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment