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

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

  • Author
    Posts
  • #4822

    Anonymous

    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

    Anonymous

    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

    Anonymous

    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

    Anonymous

    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

    Anonymous

    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

    Anonymous

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

  • #27694

    Anonymous

    Too many pills :(

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