Dynamic Memory World Generation

Hello everyone, first time here. I didn't know where the cut off line is between beginners and general so its here. Im in the process of making a sidescroller with a expanding array. I am looking for a good algorithem, any recomendations? The other thing is, if I do something like this
1
2
3
4
5
6
7
8
#include "math.h"
#include <iostream>
for(int y; y < generationsizey; y++){
for(int x; x < generationsizex; x++){
std::cout << sin((x+y)/2) //Say this is the algorithem
}
std::cout << endl //Im using sfml but this is for an example
}

Will there be chunks between that and what generates when I allocate more memory? -Dont comment on my code its just an example-
Thanks in advance :)
Last edited on
std::vector is an expanding array.

1
2
3
4
5
6
7
8
9
10
11
12
#include <vector>

std::vector<int> myarray(10);  // make an array with 10 elements

// I want to expand that array to 100 elements
myarray.resize(100);  // <- that's all you gotta do

// I want to add a single element to the end of the array
myarray.push_back( some_int );  // <- myarray's size is now 101

// how big is the array?
cout << myarray.size();  // prints 101 
Ok thanks
Topic archived. No new replies allowed.