diff --git a/.gitignore b/.gitignore index ac0b643..05ada8c 100644 --- a/.gitignore +++ b/.gitignore @@ -16,4 +16,5 @@ obj/ !libmysql-505/bin/libmysql.dll -# End of https://www.gitignore.io/api/codeblocks \ No newline at end of file +# End of https://www.gitignore.io/api/codeblocks +Maze Raider.cscope_file_list diff --git a/include/BattleScene.h b/include/BattleScene.h index 6334b81..bda5696 100644 --- a/include/BattleScene.h +++ b/include/BattleScene.h @@ -5,7 +5,7 @@ #include #define attackAnimSpeed 10 -#define defencehealAnimSpeed 150 +#define defenceHealAnimSpeed 150 using namespace std; @@ -27,20 +27,20 @@ class BattleScene bool enemyJustAttacked; // Set of player actions - void PlayerAttack(int num, int color, int power, int speed = attackAnimSpeed); - void PlayerDefend(int num, int color, int speed = defencehealAnimSpeed); - void PlayerHeal(int num, int color, int power, int speed = defencehealAnimSpeed); + void PlayerAttack(int num, int color, int power); + void PlayerDefend(int num, int color); + void PlayerHeal(int num, int color, int power); // Set of enemy actions - void EnemyAttack(int num, int color, int power, int speed = attackAnimSpeed); - void EnemyDefend(int num, int color, int speed = defencehealAnimSpeed); - void EnemyHeal(int num, int color, int power, int speed = defencehealAnimSpeed); + void EnemyAttack(); + void EnemyDefend(); + void EnemyHeal(); //TEMP int playerHealth = 100; int playerMaxHealth = 100; - int enemyHealth = 100; - int enemyMaxHealth = 100; + int enemyHealth; + int enemyMaxHealth; protected: private: @@ -62,11 +62,11 @@ class BattleScene void UpdateBattleInfo(pair lineToAdd); // Play attack animation - void PlayAttack(int num, int color, int speed); + void PlayAttack(int num, int color); // Play defend animation - void PlayDefend(int num, int color, int speed); + void PlayDefend(int num, int color); // Play heal animation - void PlayHeal(int num, int color, int speed); + void PlayHeal(int num, int color); // Meshes vector> enemyMesh = {{" ", diff --git a/include/Enemy.h b/include/Enemy.h index 3503f23..8e12507 100644 --- a/include/Enemy.h +++ b/include/Enemy.h @@ -1,6 +1,5 @@ #ifndef ENEMY_H #define ENEMY_H -#include "Maze.h" #include #include #include //random generation @@ -16,19 +15,41 @@ class Enemy Enemy(Maze* m); //functions - void moveEnemy(void); + void randomMoveEnemy(); + // 0 = Up | 1 = Right | 1 = Down | 3 = Left + void moveEnemy(int direction); + // Enemy stats + int getHealth(); + int getArmor(); + int getPower(); + int getHealPower(); + + // Animation types + int getAttackColour(); + int getAttackType(); + int getDefenceColour(); + int getDefenceType(); + int getHealColour(); + int getHealType(); //variables Maze* maze; - int xPosEnemy, yPosEnemy; + int xPos, yPos; protected: private: + // Moving variables int eDirection, ranVal, ranDecision; + + // Enemy stats + int health, armor, power, healPower; + + // Animation types + int attackColour, attackType, defenceColour, defenceType, healColour, healType; }; #endif // ENEMY_H diff --git a/include/UIHelpers.h b/include/UIHelpers.h index eb0a028..16f79be 100644 --- a/include/UIHelpers.h +++ b/include/UIHelpers.h @@ -23,8 +23,8 @@ #define leftVertical (char)180 #define attackBottom (char)223 #define attackTop (char)220 -#define heal (char)207 -#define shield (char)245 +#define healSymbol (char)207 +#define shieldSymbol (char)245 #define cursorPosition(h, x, y) SetConsoleCursorPosition( h, { x, y } ) #define red SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 12) #define blue SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 9) @@ -64,8 +64,8 @@ #define leftVertical "\u253c" #define attackBottom "\u2580" #define attackTop "\u2584" -#define heal "\u00a4" -#define shield "\u00a7" +#define healSymbol "\u00a4" +#define shieldSymbol "\u00a7" #define cursorPosition(h, x, y) cout << "\033[" << y << ";" << x << "H" #define red cout << "\033[1;31m" #define blue cout << "\033[1;34m" diff --git a/src/BattleScene.cpp b/src/BattleScene.cpp index 080ab33..bd8d368 100644 --- a/src/BattleScene.cpp +++ b/src/BattleScene.cpp @@ -13,6 +13,9 @@ BattleScene::BattleScene(LevelManager* lvlman, Enemy* e) lvlManager = lvlman; enemy = e; + enemyHealth = enemy->getHealth(); + enemyMaxHealth = enemy->getHealth(); + lvlman->ui->inBattle = true; TPlayerFEnemy = true; isPlayerDefending = false; @@ -43,7 +46,7 @@ int BattleScene::BuildScene() lvlManager->ui->inBattle = false; return 1; } - else if (enemyHealth <= 0) + else if (eHealth <= 0) { lvlManager->ui->inBattle = false; @@ -94,7 +97,7 @@ int BattleScene::BuildScene() PrintC(bsTopBottomLines); } -// Left and right lines +// Left and right lines and battle info lines else if (w == 0 || w == sceneWidth - 1) { PrintC(bsLeftRightLines); @@ -179,13 +182,13 @@ int BattleScene::BuildScene() // Draw player shield else if(w == 27 && h == 3 && isPlayerDefending) { - PrintC(shield, 11); + PrintC(shieldSymbol, 11); } // Draw enemy shield else if(w == 66 && h == 11 && isEnemyDefending) { - PrintC(shield, 11); + PrintC(shieldSymbol, 11); } // Place to draw player @@ -219,7 +222,7 @@ int BattleScene::BuildScene() } if (!TPlayerFEnemy) - EnemyAttack(0, 10, 10, 10); + EnemyAttack(); return 0; } @@ -261,7 +264,7 @@ void BattleScene::UpdateBattleInfo(pair lineToAdd) } -void BattleScene::PlayAttack(int num, int color, int speed) +void BattleScene::PlayAttack(int num, int color) { #ifdef _WIN32 HANDLE hStdOut = GetStdHandle( STD_OUTPUT_HANDLE ); @@ -296,7 +299,7 @@ void BattleScene::PlayAttack(int num, int color, int speed) cursorPosition( hStdOut, xPos + 1, yPos + 1 ); // Bottom Front PrintC(attackBottom, color); - Sleep(speed); + Sleep(attackAnimSpeed); cursorPosition( hStdOut, xPos, yPos ); // Main PrintC(mazePath); @@ -332,7 +335,7 @@ void BattleScene::PlayAttack(int num, int color, int speed) cursorPosition( hStdOut, xPos + 1, yPos ); // Back PrintC(mazeWall, color); - Sleep(speed); + Sleep(attackAnimSpeed); cursorPosition( hStdOut, xPos, yPos ); // Main PrintC(mazePath); @@ -361,34 +364,24 @@ void BattleScene::PlayAttack(int num, int color, int speed) { cursorPosition( hStdOut, xPos, yPos ); // Main Middle PrintC(mazeWall, color); - cout << flush; cursorPosition( hStdOut, xPos + 2, yPos - 1 ); // Front Middle PrintC(mazeWall, color); - cout << flush; cursorPosition( hStdOut, xPos - 2, yPos + 1 ); // Back Middle PrintC(mazeWall, color); - cout << flush; cursorPosition( hStdOut, xPos, yPos - 2 ); // Main Top PrintC(mazeWall, color); - cout << flush; cursorPosition( hStdOut, xPos + 2, yPos - 3 ); // Front Top PrintC(mazeWall, color); - cout << flush; cursorPosition( hStdOut, xPos - 2, yPos - 1 ); // Back Top PrintC(mazeWall, color); - cout << flush; cursorPosition( hStdOut, xPos, yPos + 2 ); // Main Bottom PrintC(mazeWall, color); - cout << flush; cursorPosition( hStdOut, xPos + 2, yPos + 1 ); // Front Bottom PrintC(mazeWall, color); - cout << flush; cursorPosition( hStdOut, xPos - 2, yPos + 3 ); // Back Bottom PrintC(mazeWall, color); - cout << flush; - cout << flush; - Sleep(speed); + Sleep(attackAnimSpeed); cursorPosition( hStdOut, xPos, yPos ); // Main Middle PrintC(mazePath); @@ -440,7 +433,7 @@ void BattleScene::PlayAttack(int num, int color, int speed) cursorPosition( hStdOut, xPos + 2, yPos + 1 ); // Back Bottom PrintC(mazeWall, color); - Sleep(speed); + Sleep(attackAnimSpeed); cursorPosition( hStdOut, xPos, yPos ); // Main Middle PrintC(mazePath); @@ -479,7 +472,7 @@ void BattleScene::PlayAttack(int num, int color, int speed) #endif // __linux__ } -void BattleScene::PlayDefend(int num, int color, int speed) +void BattleScene::PlayDefend(int num, int color) { #ifdef _WIN32 HANDLE hStdOut = GetStdHandle( STD_OUTPUT_HANDLE ); @@ -507,9 +500,9 @@ void BattleScene::PlayDefend(int num, int color, int speed) { cursorPosition( hStdOut, xPos + x, yPos - y ); PrintC(mazeWall, color); - Sleep(speed / 2); + Sleep(defenceHealAnimSpeed / 2); } - Sleep(speed); + Sleep(defenceHealAnimSpeed); } } else @@ -523,9 +516,9 @@ void BattleScene::PlayDefend(int num, int color, int speed) { cursorPosition( hStdOut, xPos - x, yPos - y ); PrintC(mazeWall, color); - Sleep(speed / 2); + Sleep(defenceHealAnimSpeed / 2); } - Sleep(speed); + Sleep(defenceHealAnimSpeed); } } break; @@ -545,9 +538,9 @@ void BattleScene::PlayDefend(int num, int color, int speed) cursorPosition(hStdOut, xPos + x, yPos - y - 1); PrintC(mazeWall, color); - Sleep(speed / 2); + Sleep(defenceHealAnimSpeed / 2); } - Sleep(speed); + Sleep(defenceHealAnimSpeed); } } else @@ -565,9 +558,9 @@ void BattleScene::PlayDefend(int num, int color, int speed) cursorPosition( hStdOut, xPos - x, yPos + y ); PrintC(mazeWall, color); - Sleep(speed / 2); + Sleep(defenceHealAnimSpeed / 2); } - Sleep(speed); + Sleep(defenceHealAnimSpeed); } } break; @@ -583,7 +576,7 @@ void BattleScene::PlayDefend(int num, int color, int speed) #endif // __linux__ } -void BattleScene::PlayHeal(int num, int color, int speed) +void BattleScene::PlayHeal(int num, int color) { #ifdef _WIN32 HANDLE hStdOut = GetStdHandle( STD_OUTPUT_HANDLE ); @@ -610,13 +603,13 @@ void BattleScene::PlayHeal(int num, int color, int speed) for (int y = 0; y < 6 - x; y++) { cursorPosition(hStdOut, xPos + x, yPos - y); - PrintC(heal, color); + PrintC(healSymbol, color); cursorPosition(hStdOut, xPos + 2 + x, yPos - y + 1); - PrintC(heal, color); - Sleep(speed / 2); + PrintC(healSymbol, color); + Sleep(defenceHealAnimSpeed / 2); } - Sleep(speed); + Sleep(defenceHealAnimSpeed); for (int y = 0; y < 6 - x; y++) { @@ -624,7 +617,7 @@ void BattleScene::PlayHeal(int num, int color, int speed) PrintC(mazePath); cursorPosition(hStdOut, xPos + 2 + x, yPos - y + 1); PrintC(mazePath); - Sleep(speed / 2); + Sleep(defenceHealAnimSpeed / 2); } } } @@ -638,13 +631,13 @@ void BattleScene::PlayHeal(int num, int color, int speed) for (int y = 0; y < 7 - x; y++) { cursorPosition(hStdOut, xPos - x, yPos - y); - PrintC(heal, color); + PrintC(healSymbol, color); cursorPosition(hStdOut, xPos - 2 - x, yPos - y + 1); - PrintC(heal, color); - Sleep(speed / 2); + PrintC(healSymbol, color); + Sleep(defenceHealAnimSpeed / 2); } - Sleep(speed); + Sleep(defenceHealAnimSpeed); for (int y = 0; y < 7 - x; y++) { @@ -652,7 +645,7 @@ void BattleScene::PlayHeal(int num, int color, int speed) PrintC(mazePath); cursorPosition(hStdOut, xPos - 2 - x, yPos - y + 1); PrintC(mazePath); - Sleep(speed / 2); + Sleep(defenceHealAnimSpeed / 2); } } } @@ -668,13 +661,13 @@ void BattleScene::PlayHeal(int num, int color, int speed) for (int y = 0; y < 5; y++) { cursorPosition(hStdOut, xPos + x, yPos - y - 1); - PrintC(heal, color); + PrintC(healSymbol, color); cursorPosition(hStdOut, xPos - 2 + x, yPos - y ); - PrintC(heal, color); + PrintC(healSymbol, color); cursorPosition(hStdOut, xPos + 2 + x, yPos - y + 1); - PrintC(heal, color); + PrintC(healSymbol, color); - Sleep(speed); + Sleep(defenceHealAnimSpeed); cursorPosition(hStdOut, xPos + x, yPos - y - 1); PrintC(mazePath); @@ -695,13 +688,13 @@ void BattleScene::PlayHeal(int num, int color, int speed) for (int y = 0; y < 3; y++) { cursorPosition(hStdOut, xPos - x, yPos - y - 1); - PrintC(heal, color); + PrintC(healSymbol, color); cursorPosition(hStdOut, xPos - 2 - x, yPos - y ); - PrintC(heal, color); + PrintC(healSymbol, color); cursorPosition(hStdOut, xPos + 2 - x, yPos - y + 1); - PrintC(heal, color); + PrintC(healSymbol, color); - Sleep(speed); + Sleep(defenceHealAnimSpeed); cursorPosition(hStdOut, xPos - x, yPos - y - 1); PrintC(mazePath); @@ -726,34 +719,40 @@ void BattleScene::PlayHeal(int num, int color, int speed) } -void BattleScene::PlayerAttack(int num, int color, int power, int speed) +void BattleScene::PlayerAttack(int num, int color, int power) { UpdateBattleInfo(make_pair(" dealt " + to_string(power) + " damage", 0)); - PlayAttack(num, color, speed); + PlayAttack(num, color); if (!isEnemyDefending) - enemyHealth -= power; + { + if(enemyHealth - power >= 0) + enemyHealth -= power; + else + enemyHealth = 0; + } isEnemyDefending = false; TPlayerFEnemy = false; } -void BattleScene::PlayerDefend(int num, int color, int speed) +void BattleScene::PlayerDefend(int num, int color) { UpdateBattleInfo(make_pair(" is defending", 1)); - PlayDefend(num, color, speed); + PlayDefend(num, color); + isPlayerDefending = true; isEnemyDefending = false; TPlayerFEnemy = false; } -void BattleScene::PlayerHeal(int num, int color, int power, int speed) +void BattleScene::PlayerHeal(int num, int color, int power) { UpdateBattleInfo(make_pair(" healed by " + to_string(power), 2)); - PlayHeal(num, color, speed); + PlayHeal(num, color); if (playerHealth + power <= playerMaxHealth) playerHealth += power; @@ -765,39 +764,39 @@ void BattleScene::PlayerHeal(int num, int color, int power, int speed) } -void BattleScene::EnemyAttack(int num, int color, int power, int speed) +void BattleScene::EnemyAttack() { - UpdateBattleInfo(make_pair(" dealt " + to_string(power) + " damage", 0)); + UpdateBattleInfo(make_pair(" dealt " + to_string(enemy->getPower()) + " damage", 0)); - PlayAttack(num, color, speed); + PlayAttack(enemy->getAttackType(), enemy->getAttackColour()); if (!isPlayerDefending) - playerHealth -= power; + playerHealth -= enemy->getPower(); isPlayerDefending = false; TPlayerFEnemy = true; enemyJustAttacked = true; } -void BattleScene::EnemyDefend(int num, int color, int speed) +void BattleScene::EnemyDefend() { UpdateBattleInfo(make_pair(" is defending", 1)); - PlayDefend(num, color, speed); + PlayDefend(enemy->getDefenceType(), enemy->getDefenceColour()); isPlayerDefending = false; TPlayerFEnemy = true; enemyJustAttacked = true; } -void BattleScene::EnemyHeal(int num, int color, int power, int speed) +void BattleScene::EnemyHeal() { - UpdateBattleInfo(make_pair(" healed by " + to_string(power), 2)); + UpdateBattleInfo(make_pair(" healed by " + to_string(enemy->getHealPower()), 2)); - PlayAttack(num, color, speed); + PlayHeal(enemy->getHealType(), enemy->getHealColour()); - if (enemyHealth + power <= enemyMaxHealth) - enemyHealth += power; + if (enemyHealth + enemy->getHealPower() <= enemyMaxHealth) + enemyHealth += enemy->getHealPower(); else enemyHealth = enemyMaxHealth; diff --git a/src/Enemy.cpp b/src/Enemy.cpp index 6eaff1f..b0fc307 100644 --- a/src/Enemy.cpp +++ b/src/Enemy.cpp @@ -1,29 +1,53 @@ #include "Enemy.h" +#include "Maze.h" Enemy::Enemy(Maze* m) { maze = m; + // Enemy stats + health = 100; + armor = 10; + power = 10; + healPower = 10; + + // Animation types + attackColour = 10; + attackType = 0; + defenceColour = 10; + defenceType = 0; + healColour = 10; + healType = 0; + //spawn enemy int x,y; - x = rand() % 29 + 1; - y = rand() % 29 + 1; - for(int i = 0; i<10;i++) + while(true) { - if(maze->getMazeArray()[x][y]==0) + x = rand() % (maze->getMazeSizeWH().first - 6) + 5; + y = rand() % (maze->getMazeSizeWH().second - 2) + 1; + + // Only spawn in places where player can stop + if(maze->getMazeArray()[x][y]==0 && !(maze->getMazeArray()[x + 1][y] == 1 && maze->getMazeArray()[x - 1][y] == 1 && + maze->getMazeArray()[x][y + 1] == 0 && maze->getMazeArray()[x][y - 1] == 0) && + !(maze->getMazeArray()[x + 1][y] == 0 && maze->getMazeArray()[x - 1][y] == 0 && + maze->getMazeArray()[x][y + 1] == 1 && maze->getMazeArray()[x][y - 1] == 1)) { break; } - x = rand() % 29 + 1; - y = rand() % 29 + 1; } - xPosEnemy = x; - yPosEnemy = y; + xPos = x; + yPos = y; } -void Enemy::moveEnemy(void) +// 0 = Up | 1 = Right | 1 = Down | 3 = Left +void moveEnemy(int direction) +{ + +} + +void Enemy::randomMoveEnemy() { ranDecision = rand() % 5 + 1; if(ranDecision == 1) // random chance of moving @@ -34,13 +58,13 @@ void Enemy::moveEnemy(void) { for(int i = 1;i < ranVal; i++) { - if(maze->getMazeArray()[xPosEnemy][yPosEnemy+i]==1) // checks wall forward + if(maze->getMazeArray()[xPos][yPos+i]==1) // checks wall forward { - yPosEnemy+=i-1; + yPos+=i-1; break; - }else if((maze->getMazeArray()[xPosEnemy-1][yPosEnemy+i] == 0 || maze->getMazeArray()[xPosEnemy+1][yPosEnemy+i] == 0) && (ranDecision == 1 || ranDecision == 2)) //checks path from sides + }else if((maze->getMazeArray()[xPos-1][yPos+i] == 0 || maze->getMazeArray()[xPos+1][yPos+i] == 0) && (ranDecision == 1 || ranDecision == 2)) //checks path from sides { - yPosEnemy+=i-1; + yPos+=i-1; break; } } @@ -49,13 +73,13 @@ void Enemy::moveEnemy(void) { for(int i = 1;i < ranVal; i++) { - if(maze->getMazeArray()[xPosEnemy-i][yPosEnemy]==1) // checks wall forwards + if(maze->getMazeArray()[xPos-i][yPos]==1) // checks wall forwards { - xPosEnemy-=i-1; + xPos-=i-1; break; - }else if((maze->getMazeArray()[xPosEnemy-i][yPosEnemy+1] == 0 || maze->getMazeArray()[xPosEnemy-i][yPosEnemy-1] == 0) && (ranDecision == 1 || ranDecision == 2)) //checks path from sides + }else if((maze->getMazeArray()[xPos-i][yPos+1] == 0 || maze->getMazeArray()[xPos-i][yPos-1] == 0) && (ranDecision == 1 || ranDecision == 2)) //checks path from sides { - xPosEnemy-=i-1; + xPos-=i-1; break; } } @@ -64,13 +88,13 @@ void Enemy::moveEnemy(void) { for(int i = 1;i < ranVal; i++) { - if(maze->getMazeArray()[xPosEnemy+i][yPosEnemy]==1) // checks wall forwards + if(maze->getMazeArray()[xPos+i][yPos]==1) // checks wall forwards { - xPosEnemy+=i-1; + xPos+=i-1; break; - }else if((maze->getMazeArray()[xPosEnemy+i][yPosEnemy+1] == 0 || maze->getMazeArray()[xPosEnemy+i][yPosEnemy-1] == 0) && (ranDecision == 1 || ranDecision == 2)) //checks path from sides + }else if((maze->getMazeArray()[xPos+i][yPos+1] == 0 || maze->getMazeArray()[xPos+i][yPos-1] == 0) && (ranDecision == 1 || ranDecision == 2)) //checks path from sides { - xPosEnemy+=i-1; + xPos+=i-1; break; } } @@ -79,16 +103,66 @@ void Enemy::moveEnemy(void) { for(int i = 1;i < ranVal; i++) { - if(maze->getMazeArray()[xPosEnemy][yPosEnemy-i]==1) // checks wall forward + if(maze->getMazeArray()[xPos][yPos-i]==1) // checks wall forward { - yPosEnemy-=i-1; + yPos-=i-1; break; - }else if((maze->getMazeArray()[xPosEnemy-1][yPosEnemy-i] == 0 || maze->getMazeArray()[xPosEnemy+1][yPosEnemy-i] == 0) && (ranDecision == 1 || ranDecision == 2)) //checks path from sides + }else if((maze->getMazeArray()[xPos-1][yPos-i] == 0 || maze->getMazeArray()[xPos+1][yPos-i] == 0) && (ranDecision == 1 || ranDecision == 2)) //checks path from sides { - yPosEnemy-=i-1; + yPos-=i-1; break; } } } } } + +int Enemy::getHealth() +{ + return health; +} + +int Enemy::getArmor() +{ + return armor; +} + +int Enemy::getPower() +{ + return power; +} + +int Enemy::getHealPower() +{ + return healPower; +} +// Animation types +int Enemy::getAttackColour() +{ + return attackColour; +} + +int Enemy::getAttackType() +{ + return attackType; +} + +int Enemy::getDefenceColour() +{ + return defenceColour; +} + +int Enemy::getDefenceType() +{ + return defenceType; +} + +int Enemy::getHealColour() +{ + return healColour; +} + +int Enemy::getHealType() +{ + return healType; +} diff --git a/src/LevelManager.cpp b/src/LevelManager.cpp index 9dcd59f..079a30f 100644 --- a/src/LevelManager.cpp +++ b/src/LevelManager.cpp @@ -15,6 +15,13 @@ LevelManager::LevelManager() player->xPos = maze->getMazeStart().first; player->yPos = maze->getMazeStart().second; + enemies.emplace_back(new Enemy(maze)); + enemies.emplace_back(new Enemy(maze)); + enemies.emplace_back(new Enemy(maze)); + enemies.emplace_back(new Enemy(maze)); + enemies.emplace_back(new Enemy(maze)); + enemies.emplace_back(new Enemy(maze)); + enemies.emplace_back(new Enemy(maze)); enemies.emplace_back(new Enemy(maze)); ui = new UI(this); diff --git a/src/UI.cpp b/src/UI.cpp index cb67c61..d183251 100644 --- a/src/UI.cpp +++ b/src/UI.cpp @@ -63,7 +63,7 @@ void UI::PrintMaze() // Get enemy positions, 4 = Enemy for(int i = 0 ; i < lvlManager->enemies.size(); i++) - lvlManager->maze->getMazeArray()[lvlManager->enemies[i]->xPosEnemy][lvlManager->enemies[i]->yPosEnemy] = 4; + lvlManager->maze->getMazeArray()[lvlManager->enemies[i]->xPos][lvlManager->enemies[i]->yPos] = 4; // Print maze with objects for(int h = 0; h < lvlManager->maze->getMazeSizeWH().second ; h++) { @@ -190,6 +190,10 @@ void UI::PrintUOptions() else if (userOption == 'A' || userOption == 'a' || userOption == 'D' || userOption == 'd' || userOption == 'S' || userOption == 's' || userOption == 'W' || userOption == 'w') { lvlManager->player->movePlayer(userOption); + for(Enemy* e : lvlManager->enemies) + { + e->randomMoveEnemy(); + } notvalid = false; } else diff --git a/src/UIHelpers.cpp b/src/UIHelpers.cpp index baf9802..06f753e 100644 --- a/src/UIHelpers.cpp +++ b/src/UIHelpers.cpp @@ -65,6 +65,9 @@ void UIHelpers::PrintC(char character, int color, bool twoChar) else cout << character; + + cout << flush; + // Return color to default if (needsReset) grey; @@ -80,6 +83,9 @@ void UIHelpers::PrintC(string character, int color, bool twoChar) else cout << character; + + cout << flush; + // Return color to default if (needsReset) grey;