Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //in parameterized constructor
- a = new char*[height+3];
- for(int i = 0; i < height+3; i++)
- {a[i] = new char[width+2];}
- ~destructor
- for (int i = 0; i < height+3; ++i)
- delete [] a[i];
- delete [] a;
- //elsewhere
- piece *current_piece; //both initialized to nullptr
- piece *next_piece;
- void Game::update()
- {
- if(current_piece==nullptr && next_piece==nullptr)
- {
- switch (randPieceType())
- {
- case PIECE_I:
- current_piece=new I();// make the next piece an I piece
- break;
- case PIECE_L:
- current_piece=new L(); // make the next piece an L piece
- break;
- case PIECE_J:
- current_piece=new J(); // make the next piece an L piece
- break;
- case PIECE_T:
- current_piece=new T(); // make the next piece an L piece
- break;
- case PIECE_O:
- current_piece=new O(); // make the next piece an L piece
- break;
- case PIECE_S:
- current_piece=new S(); // make the next piece an L piece
- break;
- case PIECE_Z:
- current_piece=new Z(); // make the next piece an L piece
- break;
- }
- }
- else
- { delete current_piece;
- current_piece=next_piece;
- }
- if(!next_piece)
- {
- delete next_piece;
- }
- switch (randPieceType())
- {
- case PIECE_I:
- next_piece=new I();// make the next piece an I piece
- break;
- case PIECE_L:
- next_piece=new L(); // make the next piece an L piece
- break;
- case PIECE_J:
- next_piece=new J(); // make the next piece an L piece
- break;
- case PIECE_T:
- next_piece=new T(); // make the next piece an L piece
- break;
- case PIECE_O:
- next_piece=new O(); // make the next piece an L piece
- break;
- case PIECE_S:
- next_piece=new S(); // make the next piece an L piece
- break;
- case PIECE_Z:
- next_piece=new Z(); // make the next piece an L piece
- break;
- }
- }
- //destructor
- ~Game(){delete next_piece; delete current_piece;}
- // transition between levels
- delete current_piece; delete next_piece; incode
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement