Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9172783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:26:00+00:00 2026-06-17T16:26:00+00:00

I want the users to pick there map size so I do not know

  • 0

I want the users to pick there map size so I do not know the size of the map at run time. I have been looking around how I can implement this with little success. Closest to something that is working is with the vector variant but while it runs it still does not work properly.

I want a 3 dimensional array so in my header i declare the tilemap like this.

std::vector<std::vector<std::vector<Tile>>> tileMap;

and test it in the class like this:

World::World(int width, int height, int depth)
{
tileMap.resize(width);
tileMap[0].resize(height);
tileMap[0][0].resize(depth);

tileMap.resize(width);

for (int i = 0;i<width;i++)
{
    tileMap[i].resize(height);
}



for (int y = 0; y < height;y++)
{
    for (int x = 0; x < width; x++)
    {
        tileMap[x,y].resize(depth);
    }
}

std::cout << sizeof tileMap / sizeof tileMap[0][0][0] << std::endl;

}

I am aware that not all the dimensions of the array are resized properly but the final line just outputs “0”.

Is there i better way to create my tilemap of unknown size? I need a lot of sizes like 64*64, 256*256, 64*1024, etc (the z levels will be determined after generating the level). so creating an array for each size seems inefficient. But maybe there is a better way of declaring my array or i am doing something wrong somewhere.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T16:26:01+00:00Added an answer on June 17, 2026 at 4:26 pm

    You want tileMap.size() * tileMap[0].size() * tileMap[0][0].size() to get the number of tiles.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form where users can pick several locations they want to stay
I have a PHP function that allows users to pick which categories there post
My asp.net site allows users to pick the theme they want from a list
i want users can log in my website throw FB connect ON MOBILE but
I've been looking around on SO and I don't -think- this is something that's
I want my application to pick a video from the gallery. It uses following
I want users to receive 'points' for completing various tasks in my application -
I want users to enter a comma-delimited list of logins on the form, to
I want users to be redirected to the posts index action upon login. But
I want users#new and tasks#index to display as the root path URL, i.e. /

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.