/* This file is part of Invaders. * * Copyright (C) 2020 LCM. * You may use, distribute and modify Invaders under the terms of the * GPLv3 license, available at . */ #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 & bullets){ //random bomb-dropping for(std::list::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