rocket.cpp 432 B

1234567891011121314151617181920212223242526
  1. /* This file is part of Invaders.
  2. *
  3. * Copyright (C) 2020 LCM.
  4. * You may use, distribute and modify Invaders under the terms of the
  5. * GPLv3 license, available at <https://www.gnu.org/licenses/\>.
  6. */
  7. #include "rocket.hpp"
  8. rocket::rocket(int X,int Y,int V) : bullet(X,Y,256){
  9. v=(V>=0?1:-1);
  10. }
  11. void rocket::next_pos(){
  12. y--;
  13. if(x==C-1 || x==0) v*=-1;
  14. switch(v){
  15. case 1:
  16. x++;
  17. break;
  18. case -1:
  19. x--;
  20. break;
  21. }
  22. }