this error appears to me in two classes specifically and referenced in the main. Honestly, I don't know what happened.
"Boxes::fillLadder(char**, int**, int, int, int)", referenced from:
Boxes::fill(char**, int**, int, int) in SnakesAndLadders2-455af6.o
Board::draw(char**, int**, int, int) in SnakesAndLadders2-455af6.o
"Boxes::fillSnake(char**, int**, int, int, int)", referenced from:
Boxes::fill(char**, int**, int, int) in SnakesAndLadders2-455af6.o
Board::draw(char**, int**, int, int) in SnakesAndLadders2-455af6.o
"Boxes::Boxes()", referenced from:
Board::draw(char**, int**, int, int) in SnakesAndLadders2-455af6.o
_main in SnakesAndLadders2-455af6.o
ld: symbol(s) not found for architecture x86_64
This is class Boxes
#include <iostream>
#include <string>
using namespace std;
class Boxes{
public:
Boxes();
void fill(char **board, int **positions, int y, int x);
void fillLadder(char **board, int **positions, int y, int x, int lenght);
void fillSnake(char **board, int **positions, int y, int x, int lenght);
};
void Boxes::fill(char **board, int **positions, int y, int x)
{
for (int i = 0; i < y; i++)
{
for (int w = 0; w < x; w++)
{
board[i][w] = 'N';
positions[i][w] = 0;
}
}
if (y % 2 != 0)
{
board[0][x - 1] = 'O';
}
else
{
board[0][0] = 'O';
}
board[y - 1][0] = 'O';
if (y < 8)
{
fillLadder(board, positions, y - 1, 2, y / 2);
fillLadder(board, positions, y / 2, 4, 2);
fillSnake(board, positions, 0, 1, -1 * y / 2 + 1);
}
if (y >= 8 && y <= 12)
{
fillLadder(board, positions, y - 1, 3, 3);
fillLadder(board, positions, 4, x - 3, 2);
fillLadder(board, positions, 2, x - 2, 2);
fillSnake(board, positions, 0, 4, -4);
fillSnake(board, positions, 4, x - 4, -4);
fillSnake(board, positions, 4, 0, -3);
}
if (y > 12)
{
fillLadder(board, positions, y - 1, 3, 6);
fillLadder(board, positions, 6, x - 3, 5);
fillLadder(board, positions, 7, x - 2, 6);
fillLadder(board, positions, 9, 3, 3);
fillSnake(board, positions, 0, 4, -7);
fillSnake(board, positions, 4, x - 4, -6);
fillSnake(board, positions, 7, 0, -3);
fillSnake(board, positions, 5, 2, -2);
}
}
This is class Board
#include <iostream>
#include <string>
#include <ctime>
#include "Player.h"
#include "Boxes.h"
using namespace std;
class Board{
public:
void loop(char **board, int **positions, int y, int x);
void draw(char **board, int **positions, int y, int x);
};
void Board::loop(char **board, int **positions, int x, int y)
{
player1.location = 0;
player2.location = 0;
player1.level = y - 1;
player2.level = y - 1;
bool game = true;
Player p;
bool playerFlag;
int &movement = movement;
void Movement(int &movement, bool playerFlag);
{
Dice dice;
int status = 0;
if (playerFlag == true)
{
std::cout << "Player 1: Press 1 to roll the dice." << std::endl;
cin >> status;
if (status == 1)
{
dice.roll();
movement = dice.roll();
std::cout << "Player 1 rolled a: " << dice.roll() << std::endl;
}
}
if (playerFlag == false)
{
std::cout << "Player 2: Press 2 to roll the dice." << std::endl;
cin >> status;
if (status == 2)
{
dice.roll();
movement = dice.roll();
std::cout << "Player 2 rolled a: " << dice.roll() << std::endl;
}
}
}
while (game == true)
{
p.Movement(player1.movement, true);
p.logic(board, positions, y, x, player1.movement, player1.location, player1.level, player1.movestatus);
if (p.checkWin(y, x, player1.location, player1.level) == true)
{
std::cout << "Player 1 HAS WON THE GAME !!!!!!" << std::endl;
game = false;
}
else
{
p.updatePlayerLevel(positions, y, x, player1.location, player1.level, player1.movestatus);
board[player1.level][player1.location] = player1.symbol;
draw(board, positions, y, x);
}
if (player2.on == true)
{
p.Movement(player2.movement, false);
p.logic(board, positions, y, x, player2.movement, player2.location, player2.level, player2.movestatus);
if (p.checkWin(y, x, player2.location, player2.level) == true)
{
std::cout << "Player 2 HAS WON THE GAME !!!!!!" << std::endl;
game = false;
}
else
{
p.updatePlayerLevel(positions, y, x, player2.location, player2.level, player2.movestatus);
board[player2.level][player2.location] = player2.symbol;
draw(board, positions, y, x);
}
}
}
}
void Board::draw(char **board, int **positions, int y, int x)
{
Boxes bx;
if (y % 2 != 0)
{
board[0][x - 1] = 'O';
}
else
{
board[0][0] = 'O';
}
board[y - 1][0] = 'O';
for (int i = 0; i < y; i++)
{
if ((y - 1) > 9)
{
std::cout << y - 1 << " ⎪" << std::endl;
}
else
{
std::cout << y - 1 << " ⎪" << std::endl;
}
for (int y = 0; y < x; y++)
{
std::cout << board[i][y] << " " << std::endl;
}
std::cout << " " << std::endl;
}
if (y < 8)
{
bx.fillLadder(board, positions, y - 1, 2, y / 2);
bx.fillLadder(board, positions, y / 2, 4, 2);
bx.fillLadder(board, positions, 0, 1, -1 * y / 2 + 1);
}
if (y >= 8 && y <= 12)
{
bx.fillLadder(board, positions, y - 1, 3, 3);
bx.fillLadder(board, positions, 4, x - 3, 2);
bx.fillLadder(board, positions, 2, x - 2, 2);
bx.fillSnake(board, positions, 0, 4, -4);
bx.fillSnake(board, positions, 4, x - 4, -4);
bx.fillSnake(board, positions, 4, 0, -3);
}
if (y > 12)
{
bx.fillLadder(board, positions, y - 1, 3, 6);
bx.fillLadder(board, positions, 6, x - 3, 5);
bx.fillLadder(board, positions, 7, x - 2, 6);
bx.fillLadder(board, positions, 9, 3, 3);
bx.fillSnake(board, positions, 0, 4, -7);
bx.fillSnake(board, positions, 4, x - 4, -6);
bx.fillSnake(board, positions, 7, 0, -3);
bx.fillSnake(board, positions, 5, 2, -2);
}
}
And the main
#include <iostream>
#include <string>
#include <ctime>
#include "Board.h"
using namespace std;
int main()
{
Boxes f;
Board bo;
std::cout << "****** SNAKES AND LADDERS ******" << std::endl;
int size_y;
int size_x;
std::cout << "What size board do you want? Pick the number of rows and columns." << std::endl;
std::cout << "For balance, best size is 10x10." << std::endl;
std::cout << "Rows: " << std::endl;
cin >> size_y;
std::cout << "Columns: " << std::endl;
cin >> size_x;
int flag;
std::cout << "Press 2 if you want to play multiplayer (2 players). Press 1 for single player." << std::endl;
cin >> flag;
if (flag == 2)
{
player2.on = true;
}
std::cout << "Player 1: Select a letter/number on the keyboard for your character." << std::endl;
cin >> player1.symbol;
if (player2.on == true)
{
std::cout << "PLayer 2: Select a letter/number on the keyboard for your character." << std::endl;
cin >> player2.symbol;
}
system("CLS");
char **board;
board = new char *[size_y];
int **position_status;
position_status = new int *[size_y];
for (int i = 0; i < size_y; i++)
{
board[i] = new char [size_x];
position_status[i] = new int [size_x];
}
f.fill(board, position_status, size_y, size_x);
bo.draw(board, position_status, size_y, size_x);
bo.loop(board, position_status, size_y, size_x);
char stop;
std::cout << "Press e to end the programme." << std::endl;
cin >> stop;
for (int i = 0; i < size_y; i++)
{
delete[] board[i];
delete[] position_status[i];
}
delete board;
delete position_status;
return 0;
}
This code is about a snakes and ladders game. Let me know if you need the class player because I used it on the class board.
Aucun commentaire:
Enregistrer un commentaire