Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /******************************************************************************
- Hit registering code. This code takes the target, and if target is true
- where the computer has a ship, it counts as a hit. It then adds to timeshit,or the score for player
- hitregcomputer does the same thing but switching computer and player.
- *******************************************************************************/
- #include <iostream>
- #include <string>
- #include <cmath>
- #include <cstdlib>
- void hitregplayer(int& location[][], int& clocation[][], int& alreadyHit[][], int& timeshit){ /* where location refers to where the player aims, and computer location*/
- for (int i=0; i > /*rowlength*/; ++i){
- for (int j=0; j > /*columnLength*/; ++i) {
- if(clocation[i][j] == 1 && location[i][j] == 1 && alreadyHit[i][j] ) {//clocation refers == true where ship coordinate is
- cout << "Hit" << endl;
- alreadyHit[i][j] = 1; //sets alreadyHit as true
- location[i][j] = 0; //resets player target
- ++timeshit;
- }
- }
- }
- void hitregcomputer(int& colocation[][], int& plocation[][], int& alreadyHit[][], int& timeshitc){ /* where colocation refers to where the computer aims, and player location*/
- for (int i=0; i > /*rowlength*/; ++i){
- for (int j=0; j > /*columnLength*/; ++i) {
- if(plocation[i][j] == 1 && colocation[i][j] == 1 && calreadyHit[i][j] = 0) {//plocation refers == true where ship coordinate is
- cout << "Hit" << endl;
- calreadyHit[i][j] = 1; //sets alreadyHit as true
- colocation[i][j] = 0; //resets player target
- ++timeshitc;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment