Page 2 of 2

Re: Random Tile Generation Using Arrays

PostPosted: Fri May 17, 2013 9:53 pm
by DragonRift
skydereign wrote:
DragonRift wrote:This says incompatible Type, but if I change it to int it works. However I think I am going to have to use a floating point variable to do that code I am porting... am I not correct

As I mentioned, you need to put a const int for the size of the array. This means you either need to use a literal int (like 10, or any other number) or a const int. Essentially you need to specify a fixed size for the array at the point that you declare it (before the game even starts).
Code: Select all
const int size = 10;
int array[size];

It sounds like though you want these arrays to change size within the game. If that is the case, you need to use pointers and memory allocation.


How do I use Pointers and Memory Allocation in a means that will work within GE?

Re: Random Tile Generation Using Arrays

PostPosted: Sat May 18, 2013 2:32 am
by skydereign
DragonRift wrote:How do I use Pointers and Memory Allocation in a means that will work within GE?

As you would in C. There are great tutorials on pointers and dynamic memory allocation all over the internet. I suggest searching around, you'll find better things there than you will find here. Though if you need specific questions answered, feel free to post them here. The memory allocation functions you should look into are calloc, malloc, realloc.