Zanuark

Coding project hitreg

Nov 4th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. /******************************************************************************
  2. Hit registering code. This code takes the target, and if target is true
  3. where the computer has a ship, it counts as a hit. It then adds to timeshit,or the score for player
  4.  
  5. hitregcomputer does the same thing but switching computer and player.
  6. *******************************************************************************/
  7.  
  8. #include <iostream>
  9. #include <string>
  10. #include <cmath>
  11. #include <cstdlib>
  12.  
  13. void hitregplayer(int& location[][], int& clocation[][], int& alreadyHit[][], int& timeshit){ /* where location refers to where the player aims, and computer location*/
  14. for (int i=0; i > /*rowlength*/; ++i){
  15. for (int j=0; j > /*columnLength*/; ++i) {
  16. if(clocation[i][j] == 1 && location[i][j] == 1 && alreadyHit[i][j] ) {//clocation refers == true where ship coordinate is
  17. cout << "Hit" << endl;
  18. alreadyHit[i][j] = 1; //sets alreadyHit as true
  19. location[i][j] = 0; //resets player target
  20. ++timeshit;
  21.  
  22.  
  23. }
  24. }
  25. }
  26.  
  27. void hitregplayer(int& colocation[][], int& plocation[][], int& alreadyHit[][], int& timeshitc){ /* where colocation refers to where the computer aims, and player location*/
  28. for (int i=0; i > /*rowlength*/; ++i){
  29. for (int j=0; j > /*columnLength*/; ++i) {
  30. if(plocation[i][j] == 1 && colocation[i][j] == 1 && calreadyHit[i][j] = 0) {//plocation refers == true where ship coordinate is
  31. cout << "Hit" << endl;
  32. calreadyHit[i][j] = 1; //sets alreadyHit as true
  33. colocation[i][j] = 0; //resets player target
  34. ++timeshitc;
  35.  
  36.  
  37. }
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment