Quote:
So am i really going to define 200 ENTITIES MANUALLY?
Noo noo, of course not manually
. You can store entity pointers in variable arrays. But I can not provide you the full code now, it would take time to figure out a good method, but this is how you should basicly do it (code in green is code you should add, orange is psuedo thus you yet need to define it):
Code:
var grass_array_x[1000];
var grass_array_y[1000];
var grass_pointer[200];
var grass_array_index;
function create_grass()
{
while(grass_array_index < 1000) {
grass_array_x[grass_array_index] = random(10000);
grass_array_y[grass_array_index] = random(10000);
grass_array_index += 1;
}
}
function run_grass() {
var i;
while(i < 200) {
grass_pointer[i] = ent_create ("grass.tga", nullvector, NULL);
i += 1;
}
while(1) {
while(i < grass_array_index) {
you = grass_array_index[i];
if (vec_dist (you.x, player.x) > 1000) {
you.x = closest_stored_xpoint_to_player; //that is not already taken by a grass sprite
you.y = closest_stored_ypoint_to_player;
}
}
wait(1);
}
}
Now the orange part is most certainly not the easiest part, and because you have predefined positions, it's alot more calculating and loops than just placing at random places. I do advise you to not use fixed positions for this reason, but there might be a different method I have not thought of to handle this (maybe involve an entity it's skill variables).