1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- #include "wall.hpp"
- wall::wall():game_object(0,0,32) , body(0,0){} //default constructor
- wall::wall(int x,int y,int w,int h,int life) : game_object(x,y,32) , body(w,h){
- /*health = new int* [height];
- for(int i=0; i<height; ++i)
- health[i] = new int[w];*/
- set_life(life);
- }
- wall::~wall()
- {
- //delete [] health; if this line is commented, the program won't receive SIGSEGV after calling the destructor while creating walls' vector.
- }
- void wall::set_life(int Life){
- for(int i=0;i<width;i++)
- for(int j=0;j<height;j++)
- health[j][i]=Life;
-
- }
- void wall::create(int X,int Y,int W, int H,int life){
- x=X;
- y=Y;
- width=W;
- height=H;
- /*health = new int* [height];
- for(int i=0; i<height; ++i)
- health[i] = new int[width];*/
- set_life(life);
- }
- void wall::printlife(){
- for(int i=0;i<height;i++){
- for(int j=0;j<width;j++)
- std::cout<<health[i][j];
- std::cout<<std::endl;
- }
- std::cout<<std::endl;
- }
|