1234567891011121314151617181920212223242526272829303132333435363738 |
- #include "enemy.hpp"
- enemy::enemy() : game_object() { id=4; alive=true; direction=0; }
- enemy::enemy(int X,int Y) : game_object(X,Y,4) { alive=true; direction=0; }
- void enemy::next_pos(){
- if( (direction==0 && x==C-1) || (direction==1 && x==0) )
- direction=2;
- switch (direction){ //assegno a direction un valore 0,1,2
- case 0: //0 significa che si sta muovendo verso destra
- x++;
- break;
- case 1: //1 verso sinistra
- x--;
- break;
- case 2: //2 verso il basso (quando incontra la parete).
- y++;
- break;
- }
- if(direction==2)
- {
- if(x==0) direction=0;
- else direction=1;
- }
-
- }
- void enemy::shoot(std::list<bullet> & bombs){ //random bomb-dropping
- bullet new_bomb(x,y+1,8);
- bombs.push_back(new_bomb);
- }
|