Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Tactics/Board.cpp
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
130 lines (89 sloc)
3.63 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include "Board.hh" | |
void Board::board_creation() | |
{ | |
//Board(); | |
//{ | |
// Creating an array for the random numbers to be stored in | |
//int random; // Old variable used for testing random to see if it was causing any errors | |
//int num1; | |
int counter; //used for for loop generation of array one counter for each dimension of the array | |
static int counter2; | |
int terrain; | |
// int row1; | |
// int row2; | |
// int row3; | |
// int row4; | |
// int row5; | |
// int row6; | |
// int row7; | |
// int row8; | |
srand (time(NULL)); // Sets the random seed to be based on the time so that i dont get the same number every time | |
for (counter2 = 0; counter2 <8; counter2++) //this counter handles the horizontal axis of the board | |
{ | |
for (counter = 0; counter < 8; counter++) //this counter handles the vertical axis of the board | |
{ | |
board[counter][counter2] = '-'; // Randomly assigns a value from 1-4 to that part of the array | |
//num1 = counter2; | |
//std::cout<<counter<<std::endl; | |
//std::cout<<num1<<std::endl; | |
// if(num1 = 1) | |
// { | |
// row1 = row1 + board[counter][counter2]; | |
// //std::cout<<board[counter][counter2]<<std::endl; | |
// //std::cout<<"success"<<std::endl; | |
// } | |
// if(num1 = 2) | |
// { | |
// row2 = row2 + board[counter][counter2]; | |
// } | |
//std::cout<<board[0][0]<<board[0][1]<<std::endl; | |
} | |
// } | |
//std::cout<<row1<<std::endl; | |
//std::cout<<row2<<std::endl; | |
} | |
} | |
void Board::board_output() | |
{ | |
int i; // Two counters used for double for loop for outputting array | |
int x; | |
int colourcheck; | |
int colour; | |
HANDLE hConsole; | |
hConsole = GetStdHandle(STD_OUTPUT_HANDLE); | |
for (x = 0; x < 8; x++) | |
{ | |
for (i = 0; i < 8; i++) | |
{ | |
colourcheck = rand() % 10 + 5; | |
// if (colourcheck = 0); | |
// { | |
// colour = 10; // Green | |
// } | |
// if (colourcheck = 1); | |
// { | |
// colour = 3; // Blue | |
// } | |
// if (colourcheck = 2); | |
// { | |
// colour = 4; // Red | |
// } | |
// if (colourcheck = 3); | |
// { | |
// colour = 8; // Grey | |
// } | |
SetConsoleTextAttribute(hConsole, colourcheck); | |
std::cout<<board[x][i]; | |
std::cout<<" "; // Puts spaces between the numbers to make it clearer to the player | |
} | |
std::cout<<""<<std::endl; // Puts new lines between each row to create distance between spaces | |
std::cout<<""<<std::endl; | |
} | |
SetConsoleTextAttribute(hConsole, 7); | |
// for (i = 0; i < 7; i++) | |
// { | |
// std::cout<<board[1][i]; | |
// std::cout<<" "; | |
// } | |
} | |