S2DE::Vec2<float> moveCursorPos;
S2DE::Vec2<float> arenaCenter = { 23, 11 };
-static const int numActions = 4;
-static const char* actions[numActions] = {"Move", "Attack", "End", "FLEE"};
+static const int numActions = 5;
+static const char* actions[numActions] = {"Move", "Attack", "Abilities", "End", "FLEE"};
int currentAction = 0;
SDL_Colour hpColour = { 136, 8, 8, 255 };
/*combatants.push_back(enemy);
combatants.push_back(frog);*/
+}
+void beginCombat()
+{
Character dummy;
dummy.allied = false;
dummy.name = "Practice Dummy";
combatants.push_back(*eric); // push back copies of the players?
combatants.push_back(*monica);
-
+
// calculates turn order. Can expand the lambda to support other things
std::sort(combatants.begin(), combatants.end(), [](const Character& a, const Character& b) {return a.agility > b.agility; });
currentCombatState = SELECT_TARGET;
}
break;
- case 2: // end selected
+ case 2: // transition to select abilities state
+ break;
+ case 3: // end selected
currentCombatState = TURN_ORDER;
break;
//bool checkCollision(S2DE::Vec2<float> worldPos);
+/*
+This structure defines any entity that is not a tile that can be drawn on the overworld.
+Will need a function to detect collisions with these, although will assume all the same size.
+Will also need some way to mark them as "dead" or innactive. The hostile flag determines if collision
+with one initiates combat or not.
+*/
+struct OverworldEntity {
+ bool hostile;
+ S2DE::Vec2<float> position;
+ SDL_Texture* texture;
+};
+
+std::vector<OverworldEntity> overworldEntities;
+
+void initOverworldEntities();
+/*
+This function checks collisions against all overworld entities.
+Currently returns true if a collision is found. This needs to be changed though depending on what the player collides with.
+*/
+bool checkCollisionOverworldEntities();
+
+
+void initOverworldEntities() {
+ overworldEntities.push_back({ true, {29, 22}, practice_dummy_texture });
+}
+
+bool checkCollisionOverworldEntities() {
+
+ // assumes the enemy has size 1x1;
+
+ for (auto oe : overworldEntities) {
+
+ float minX = playerPos.x;
+ float minY = playerPos.y;
+ float maxX = playerPos.x + 1.0f;
+ float maxy = playerPos.y + 1.0f;
+ float width = 1.0f;
+ float height = 1.0f;
+ if ((playerPos.x > oe.position.x && playerPos.x < oe.position.x + width)
+ && (playerPos.y > oe.position.y && playerPos.y < oe.position.y + height)){
+ return true;
+ }
+
+ }
+
+ return false;
+}
+
void renderWorld()
{
S2DE::Rect enemySRect = { 0, 32 * enemyDirection, 32, 32 };
S2DE::renderTexture(&renderer, &bird, &enemySRect, &enemyDRect);
+ // render overworld Entities
+ for (auto oe : overworldEntities) {
+ S2DE::Rect oeDRect = S2DE::worldToScreenRect(&camera, &oe.position, 2, WINDOW_WIDTH, WINDOW_HEIGHT, 32, 32);
+ S2DE::Rect oeSRect = { 0, 0, 32, 32 };
+ S2DE::renderTexture(&renderer, &oe.texture, &oeSRect, &oeDRect);
+ }
// render player
for (int i = 0; i < WORLD_HEIGHT; ++i) world[i] = new WorldCell[WORLD_WIDTH];
loadWorld("maps/overworld_1.tmj", world, WORLD_WIDTH, WORLD_HEIGHT);
+
+ initOverworldEntities();
bool running = true;
camera = playerPos;
+ if (checkCollisionOverworldEntities()) {
+ beginCombat();
+ gameState = COMBAT;
+ }
+
if (enemyWalkTimer > enemyWalkTime)
{
// flip the direction and reset the timer