Random Tile Generation Using Arrays

Non-platform specific questions.

Re: Random Tile Generation Using Arrays

Postby DragonRift » Fri May 17, 2013 9:53 pm

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?
DragonRift
 
Posts: 70
Joined: Mon May 13, 2013 5:05 am
Score: 0 Give a positive score

Re: Random Tile Generation Using Arrays

Postby skydereign » Sat May 18, 2013 2:32 am

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Previous

Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron