So I wanted to create a game with a square world.
When starting the game, the user should be able to specify the size of the world.
The world is saved as a two-dimensional array of shorts.
const short gameSize = 4;
short world[gameSize][gameSize];
The short gameSize
must be const
, otherwise, I can't put gameSize
as the size of world[][]
.
However, this won't allow me to set gameSize
to the player-wished size.
I thought of something simple like
short gameSize = 0;
cout << "World size?" << endl;
cin >> gameSize;
short world[gameSize][gameSize];
As stated, this won't work.
In the game, it won't be possible to change the value of gameSize later on.
How could I make this happen?