1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- #include "boss.hpp"
- boss::boss(int x, int y, int life, int w, int h, std::string newname) : enemy(x,y), pic(w,h)
- {
- name = newname;
- health=life;
- healthmax=life;
- id=16;
- alive=false;
- }
- void boss::next_pos()
- {
- if((x==0 && direction==1) || (x==C-width-1 && direction==0))
- direction=2;
-
- switch(direction){
- case 0:
- x++;
- break;
- case 1:
- x--;
- break;
- case 2:
- y++;
- if(x==0)
- direction=0;
- else direction=1;
- break;
- }
- }
- void boss::set_life(int life){
- health=life;
- healthmax=life;
- }
- void boss::shoot(std::list<bullet> & bullets){ //random bomb-dropping
- for(std::list<bullet>::reverse_iterator it=bullets.rbegin(); it!=bullets.rend(); ++it)
- if((it->x==x+width/3 || it->x==x+2*width/3) && it->y==y+height)
- return;
- bullet new_bomb(x+width/3,y+height,8);
- bullets.push_back(new_bomb);
- bullet new_bomb2(x+2*width/3,y+height,8);
- bullets.push_back(new_bomb2);
- }
- boss& boss::operator=(boss& otherboss)
- {
- x=otherboss.x;
- y=otherboss.y;
- health=otherboss.health;
- healthmax=otherboss.health;
- width=otherboss.width;
- height=otherboss.height;
- name=otherboss.name;
-
- picture = new char* [otherboss.height];
- for(int i=0; i<height; ++i)
- picture[i] = new char[otherboss.width];
-
- for(int i=0;i<height;i++)
- for(int j=0;j<width;j++)
- picture[i][j] = otherboss.picture[i][j];
-
- return *this; //just to get rid of the compiler warning
- }
|