Home Forums Programming Help about random city generating in C++

Welcome to our forums. These forums were active from 2003-2014. We have now decided to close them down, but will leave them here as an archive.

Remember you can send us feedback, news, jobs and content ideas by clicking here.

If you're really stuck for time, email news@gamedevelopers.ie.

You can also follow us on Twitter @gamedev_ie 

 

 

This topic contains 6 replies, has 6 voices, and was last updated by  Skyclad 12 years ago.

  • Author
    Posts
  • #4822

    oozsakarya
    Participant

    Hello. I must tu generate random city maps in c++. I think to use a 2 dimensional matrix. According to the values in matrix I will draw the buildings,ways and cars,taxis,motobiycles etc on ways. How can I do these? Can you help me??? :?:

  • #27671

    Nooptical
    Participant

    Sorry, took a wrong step and now I’m on the programming boards……..must go and have a shower now to cleanse myself!

    As to your problem, I’m sure someone around here has an idea of what you need……but I’m an artist, and talk of Matrices confuses me greatly! ;)

  • #27672

    peter_b
    Participant

    Hello. I must tu generate random city maps in c++. I think to use a 2 dimensional matrix. According to the values in matrix I will draw the buildings,ways and cars,taxis,motobiycles etc on ways. How can I do these? Can you help me??? :?:[/quote:33d4e10d87]

    have you not answered your question?

    have something like the following:

    in your setup do the following once:

    int cityArray[5][5];

    srand(timeGetTime());

    const int CAR=1;
    const int BUILDING=2;
    const int TAXI =3;

    const int NUMBER_OF_ITEMS = 3;

    for(int i=0;i<5;i++)
    {
    for(int j=0;j<5;j++)
    {
    cityArray = rand()/%NUMBER_OF_ITEMS;
    }
    }

    then during rendering do the following.

    for(int i=0;i<5;i++)
    {
    for(int j=0;j<5;j++)
    {
    switch(cityArray
    )
    {
    case CAR:
    {
    renderCar();
    break;
    }

    case TAXI:
    {
    renderTaxi();
    break;
    }
    case BUILDING:
    {
    renderBuilding();
    break;
    }
    }

    }
    }

    finally if you wanted to make this better, the array could be an array of structures(instead of int’s) which have stuff in them like x,y coordinates,textures etc.
    Alternatively if your going the c++ way then you might make them class and create a polymorphic array where each different object type has an override render which gets called. If you arent familar with these terms then read up on them before you write your game.. these technqiues will save you an ass load of time

    peter

  • #27673

    hugh
    Participant

    Well you could start by looking at this:

    http://www.vterrain.org/

    In particular check out what these guys have done:

    http://www.centralpictures.com/ce/tp/paper.pdf

    And then maybe in about a year’s time you could check the link below when hopefully there will be results available on the research project we are just starting on this exact topic …

    http://www.gamesitb.com/index.php?option=com_content&task=view&id=21&Itemid=28

    Alternatively if you are looking to lash up something quickly then do what Peter said …

  • #27690

    Pete
    Participant

    As to your problem, I’m sure someone around here has an idea of what you need……but I’m an artist, and talk of Matrices confuses me greatly! ;)[/quote:66b66bdb52]

    Don’t worry mate, there is no spoon

  • #27693

    Nooptical
    Participant

    Then what did I just use to eat this bowl of ice cream then??……..unless……

  • #27694

    Skyclad
    Participant

    Too many pills :(

The forum ‘Programming’ is closed to new topics and replies.