#include <cmath>
#include <algorithm>
-enum SpellType {
- BASIC_ATTACK,
- SLASH
-};
SpellType selectedSpell = BASIC_ATTACK;
std::map<SpellType, AttackAnim> animLookup;
-
-struct Character {
- bool allied;
- std::string name;
- int currentHP;
- int maxHP;
- int currentMP;
- int maxMP;
- int attack;
- int defense;
- int agility; // to determine move order
- float moveDist;
-
- // animation stuff?
- SDL_Texture* texture;
- S2DE::Vec2<float> position;
- // direction vector?
- // how to handle "moves"
- S2DE::Vec2<float> combatMoveDestination = { 0.0f, 0.0f };
-
- int basicAttackRange = 1.75f;
-
- bool canMove = true;
- bool canAttack = true;
-
- bool alive = true;
-
- SpellType basicAttackType = BASIC_ATTACK;
-};
-
std::vector<Character> combatants;
int currentCombatantIndex = -1;
Character* activeCombatant;
enum CombatState {
TURN_ORDER,
ACTION_SELECT,
+ ABILITY_SELECT, // select an ability or spell to cast
PLAYER_MOVE,
SELECT_TARGET,
DO_ATTACK,
if (c.alive) {
S2DE::Vec2<float> pos = c.position;
S2DE::Rect charDRect = S2DE::worldToScreenRect(&combatCam, &pos, 2, WINDOW_WIDTH, WINDOW_HEIGHT, 32, 32);
+
+
S2DE::Rect charSRect = { 0, 0, 32, 32 };
+ if (c.beingHurt) {
+ charSRect.x += 32;
+ }
+
// disabled for now
//if (c.allied) {
// // do the looking logic only for allied characters
animLookup[SLASH] = { slashAnim, 5, 48, 48 };
//Character player = { true, "Player", 100, 100, 50, 50, 10.0f, 3.0f, player_sheet, { 23.0f, 13.0f } };
- Character player;
- player.allied = true;
- player.name = "Player";
- player.maxHP = 100;
- player.currentHP = player.maxHP;
- player.maxMP = 50;
- player.currentMP = player.maxMP;
- player.agility = 10.0f;
- player.moveDist = 3.0f;
- player.texture = player_forward_texture;
- player.position = { arenaCenter.x + 0.5f, arenaCenter.y + 2 };
- player.attack = 5;
- player.defense = 5;
+ //Character player;
+
+ eric->position = { arenaCenter.x + 0.5f, arenaCenter.y + 2 };
+ monica->position = { arenaCenter.x - 0.5f, arenaCenter.y + 2 };
+
+
+ //Character enemy;
+ //enemy.allied = false;
+ //enemy.name = "Bird";
+ //enemy.maxHP = 25;
+ //enemy.currentHP = enemy.maxHP;
+ //enemy.maxMP = 10;
+ //enemy.currentMP = enemy.maxMP;
+ //enemy.agility = 5.0f;
+ //enemy.moveDist = 1.5f;
+ //enemy.texture = bird;
+ //enemy.position = { arenaCenter.x, arenaCenter.y - 2 };
+ //enemy.attack = 2;
+ //enemy.defense = 2;
+
+ //Character frog;
+ //frog.allied = false;
+ //frog.name = "Frog";
+ //frog.currentHP = frog.maxHP = 10;
+ //frog.currentMP = frog.maxMP = 10;
+ //frog.agility = 2;
+ //frog.moveDist = 2.0f;
+ //frog.texture = frog_texture;
+ //frog.position = { arenaCenter.x - 1, arenaCenter.y - 2 };
+ //frog.attack = 2;
+ //frog.defense = 2;
+
+ /*combatants.push_back(enemy);
+ combatants.push_back(frog);*/
+
+
+ Character dummy;
+ dummy.allied = false;
+ dummy.name = "Practice Dummy";
+ dummy.currentHP = dummy.maxHP = 25;
+ dummy.currentMP = dummy.maxMP = 0;
+ dummy.agility = 0.0f;
+ dummy.moveDist = 0;
+ dummy.texture = practice_dummy_texture;
+ dummy.attack = 0;
+ dummy.defense = 0;
+ dummy.position = { arenaCenter.x, arenaCenter.y };
+
+ combatants.push_back(dummy);
+
+ combatants.push_back(*eric); // push back copies of the players?
+ combatants.push_back(*monica);
- Character monica;
- monica.allied = true;
- monica.name = "Monica";
- monica.maxHP = 100;
- monica.currentHP = monica.maxHP;
- monica.maxMP = 50;
- monica.currentMP = monica.maxMP;
- monica.agility = 8.0f;
- monica.moveDist = 6.0f;
- monica.texture = monica_texture;
- monica.position = { arenaCenter.x - 0.5f, arenaCenter.y + 2 };
- monica.attack = 6;
- monica.basicAttackType = SLASH;
- monica.defense = 5;
-
- Character enemy;
- enemy.allied = false;
- enemy.name = "Bird";
- enemy.maxHP = 25;
- enemy.currentHP = enemy.maxHP;
- enemy.maxMP = 10;
- enemy.currentMP = enemy.maxMP;
- enemy.agility = 5.0f;
- enemy.moveDist = 1.5f;
- enemy.texture = bird;
- enemy.position = { arenaCenter.x, arenaCenter.y - 2 };
- enemy.attack = 2;
- enemy.defense = 2;
-
- Character frog;
- frog.allied = false;
- frog.name = "Frog";
- frog.currentHP = frog.maxHP = 10;
- frog.currentMP = frog.maxMP = 10;
- frog.agility = 2;
- frog.moveDist = 2.0f;
- frog.texture = frog_texture;
- frog.position = { arenaCenter.x - 1, arenaCenter.y - 2 };
- frog.attack = 2;
- frog.defense = 2;
-
- combatants.push_back(player);
- combatants.push_back(monica);
- combatants.push_back(enemy);
- combatants.push_back(frog);
-
// 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; });
animTimer = 0;
animFrame += 1;
+ target->beingHurt = true;
+
if (animFrame > anim.numFrames) {
// anim is complete, apply damage and move on.
// reset timers etc.
currentCombatState = ACTION_SELECT;
activeCombatant->canAttack = false;
+ target->beingHurt = false;
}
}
}
#include "globals.h"
+Character* eric = new Character();
+Character* monica = new Character();
+
SDL_Texture* environment_sheet = nullptr;
SDL_Texture* player_sheet = nullptr;
SDL_Texture* water_test_sheet = nullptr;
SDL_Texture* monica_texture = nullptr;
SDL_Texture* player_forward_texture = nullptr;
SDL_Texture* frog_texture = nullptr;
+SDL_Texture* practice_dummy_texture = nullptr;
Mix_Music* background_music = nullptr;
font_grey = S2DE::loadTexture("assets/simple_6x8_grey.png", &renderer);
ui_frame_sheet = S2DE::loadTexture(ui_frame_sheet_path, &renderer);
bird = S2DE::loadTexture(bird_path, &renderer);
+ practice_dummy_texture = S2DE::loadTexture("assets/practice_dummy.png", &renderer);
monica_texture = S2DE::loadTexture("assets/Monica_sprite.png", &renderer);
player_forward_texture = S2DE::loadTexture("assets/player_forward.png", &renderer);
background_music = Mix_LoadMUS(bg_mus_path);
}
+void initPlayerParty() {
+ eric->allied = true;
+ eric->name = "Player";
+ eric->maxHP = 100;
+ eric->currentHP = eric->maxHP;
+ eric->maxMP = 50;
+ eric->currentMP = eric->maxMP;
+ eric->agility = 10.0f;
+ eric->moveDist = 3.0f;
+ eric->texture = player_forward_texture;
+ eric->position = { 0.0f, 0.0f };
+ eric->attack = 5;
+ eric->defense = 5;
+ eric->knownSpells = { THROW_ROCK };
+
+ monica->allied = true;
+ monica->name = "Monica";
+ monica->maxHP = 100;
+ monica->currentHP = monica->maxHP;
+ monica->maxMP = 50;
+ monica->currentMP = monica->maxMP;
+ monica->agility = 8.0f;
+ monica->moveDist = 6.0f;
+ monica->texture = monica_texture;
+ monica->position = { 0.0f, 0.0f };
+ monica->attack = 6;
+ monica->basicAttackType = SLASH;
+ monica->defense = 5;
+
+ monica->knownSpells = { AIMED_SHOT, ARROW_RAIN };
+}
\ No newline at end of file
extern SDL_Texture* monica_texture;
extern SDL_Texture* player_forward_texture;
extern SDL_Texture* frog_texture;
+extern SDL_Texture* practice_dummy_texture;
extern Mix_Music* background_music;
void initResources();
+void initPlayerParty();
extern S2DE::InputState inputState;
COMBAT
};
-extern GameState gameState;
\ No newline at end of file
+extern GameState gameState;
+
+
+enum SpellType {
+
+ BASIC_ATTACK, // basic melee attack
+ SLASH, // slashing attack
+ THROW_ROCK, // basic ranged attack
+
+ // elemental magics
+ FIREBALL, // single target fire attack
+ FIREBURST, // aoe fire attack
+ LIGHTNING_ZAP, // single target lightning attack
+ CHAIN_LIGHTNING,// aoe lightning attack
+
+ // archery
+ AIMED_SHOT, // single target arrow attack
+ ARROW_RAIN, // archery aoe
+
+ // thief
+ BACKSTAB, // melee attack that does more damage if the attacker is behind the target
+};
+
+struct Character {
+ bool allied;
+ std::string name;
+ int currentHP;
+ int maxHP;
+ int currentMP;
+ int maxMP;
+ int attack;
+ int defense;
+ int agility; // to determine move order
+ float moveDist;
+
+ // animation stuff?
+ SDL_Texture* texture;
+ S2DE::Vec2<float> position;
+ bool beingHurt = false;
+ // direction vector?
+ S2DE::Vec2<float> combatMoveDestination = { 0.0f, 0.0f };
+
+ int basicAttackRange = 1.75f;
+
+ bool canMove = true;
+ bool canAttack = true;
+
+ bool alive = true;
+
+ SpellType basicAttackType = BASIC_ATTACK;
+
+ std::vector<SpellType> knownSpells;
+};
+
+extern Character* eric;
+extern Character* monica;
\ No newline at end of file