- Joined
- Jul 18, 2008
- Messages
- 4,283
Heys guys and gals.
I'm making a game in GameMaker Studio that uses its own GML for its scripting language (which is mostly a derivative of Java.)
Without going into details as to why this is the case, I wrote a script to generate grass patches in random spots every few seconds on the map. The map is somewhat grid-like where each 'space' is a 48 x 48 pixel section in which the grass patch object spawns.
The code I have for it is the following:
xspawn = 48 * irandom_range(4, 9) ;
yspawn = 48 * irandom_range(3, 7);
instance_create(xspawn, yspawn, obj_grass_patch);
The limits for the range just represents the edges of the spawn area.
Ideally, I want to make it so that if a grass patch appears on a space, I don't want another one to appear on top of it when the script runs again, so I want to modify it to recognize the xspawn and yspawn value from the previous execution of the script and then exclude it in future runs until the the object is destroyed.
I'm a noob at programming, so this might be a really easy problem, but can anyone show me how this might be possible?Again, GML, from what I understand, was written primarily in Java, so a Java solution would probably apply here as well. And even if it doesn't, I can figure out the syntax once I get the logic behind it. If anyone can help with this, I'd really appreciate it.
I'm making a game in GameMaker Studio that uses its own GML for its scripting language (which is mostly a derivative of Java.)
Without going into details as to why this is the case, I wrote a script to generate grass patches in random spots every few seconds on the map. The map is somewhat grid-like where each 'space' is a 48 x 48 pixel section in which the grass patch object spawns.
The code I have for it is the following:
xspawn = 48 * irandom_range(4, 9) ;
yspawn = 48 * irandom_range(3, 7);
instance_create(xspawn, yspawn, obj_grass_patch);
The limits for the range just represents the edges of the spawn area.
Ideally, I want to make it so that if a grass patch appears on a space, I don't want another one to appear on top of it when the script runs again, so I want to modify it to recognize the xspawn and yspawn value from the previous execution of the script and then exclude it in future runs until the the object is destroyed.
I'm a noob at programming, so this might be a really easy problem, but can anyone show me how this might be possible?Again, GML, from what I understand, was written primarily in Java, so a Java solution would probably apply here as well. And even if it doesn't, I can figure out the syntax once I get the logic behind it. If anyone can help with this, I'd really appreciate it.