12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- /* 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 <https://www.gnu.org/licenses/\>.
- */
- #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;
- }
|