// how to handle "moves"
S2DE::Vec2<float> combatMoveDestination = { 0.0f, 0.0f };
- int basicAttackRange = 1.0f;
+ int basicAttackRange = 1.5f;
bool canMove = true;
bool canAttack = true;
S2DE::renderTexture(&renderer, &indicatorSprite, NULL, &arrowDRect);
}
+bool checkCharacterCollision(S2DE::Vec2<float> position) {
+ for (auto c : combatants) {
+ if (c.name != activeCombatant->name) { // this sucks
+ float charMinX = c.position.x;
+ float charMaxX = c.position.x + 1.0;
+ float charMinY = c.position.y;
+ float charMaxY = c.position.y + 1.0;
+
+ if (position.x > charMinX && position.x < charMaxX
+ && position.y > charMinY && position.y < charMaxY) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
void initCombatScene()
{
// I think all resources should be initialized and cleaned up in the globals tbh
}
if (distance({ moveCursorPos.x, newY }, player.position) <= player.moveDist
- && checkCollisionPoint({ moveCursorPos.x + 0.5f, newY + 0.5f }, arena) == false) {
+ && checkCollisionPoint({ moveCursorPos.x + 0.5f, newY + 0.5f }, arena) == false
+ && checkCharacterCollision({moveCursorPos.x + 0.5f, newY + 0.5f}) == false) {
moveCursorPos.y = newY;
}
if (distance({ newX, moveCursorPos.y }, player.position) <= player.moveDist
- && checkCollisionPoint({ newX + 0.5f, moveCursorPos.y + 0.5f }, arena) == false) {
+ && checkCollisionPoint({ newX + 0.5f, moveCursorPos.y + 0.5f }, arena) == false
+ && checkCharacterCollision({ newX + 0.5f, moveCursorPos.y + 0.5f }) == false) {
moveCursorPos.x = newX;
}