Advertisement
Guest User

Untitled

a guest
Jan 17th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. //
  2. // Created by mathilde charpiot on 10/01/2018.
  3. //
  4.  
  5. #include "Boss2.h"
  6. #include "Game.h"
  7.  
  8.  
  9. Boss2::Boss2(EnemyType type) : Boss() {
  10. TextureManager &ptr1 = TextureManager::Instance();
  11. stance = Stance::IDLE;
  12. if (type == EnemyType::BOSS) {
  13. enemyType = type;
  14. orientation = Orientation::VERTICAL;
  15. sprites[(int) Stance::IDLE] = ptr1.getSprite(Textures::BOSS2);
  16. pos.x = WIN_WIDTH / 2;
  17. pos.y = WIN_HEIGHT * 20 / 100;
  18. trajectory.x = 0;
  19. trajectory.y = 0;
  20. speed = 10;
  21. hp = 1000;
  22. weapon.setWeapon(WeaponType::SPREAD, 80, 15);
  23. }
  24. }
  25.  
  26. Boss2::~Boss2() {
  27.  
  28. }
  29.  
  30. void Boss2::shoot() {
  31. if (shootCooldown == 0) {
  32. switch (enemyType) {
  33. case EnemyType::BASIC_A : {
  34. shootCooldown = weapon.getCoolDown();
  35. weapon.shoot(orientation, pos, Side::ENEMY, BulletType::ENEMY_A);
  36. }
  37. case EnemyType::BOSS : {
  38. shootCooldown = weapon.getCoolDown();
  39. weapon.shoot(orientation, pos, Side::ENEMY, BulletType::BOSS2);
  40. }
  41. }
  42. }
  43. }
  44.  
  45. void Boss2::updatePos() {
  46. if (shootCooldown > 0)
  47. shootCooldown--;
  48. if (orientation == Orientation::VERTICAL) {
  49. if (back == true)
  50. move(sf::Vector2f(1, 1));
  51. else
  52. move(sf::Vector2f(-1, -1));
  53. if (pos.x == WIN_WIDTH && back == true) {
  54. back = false;
  55. }
  56. if (pos.x == 0 && back == false) {
  57. back = true;
  58. }
  59. } else if (orientation == Orientation::HORIZONTAL) {
  60. if (back == true)
  61. move(sf::Vector2f(1, 1));
  62. else
  63. move(sf::Vector2f(-1, -1));
  64. if (pos.y == WIN_HEIGHT && back == true) {
  65. back = false;
  66. }
  67. if (pos.y == 0 && back == false) {
  68. back = true;
  69. }
  70. }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement