Generating a random object in specified area?

For questions about using Classic.

Post » Tue Dec 21, 2010 9:24 am

I'm making a simple turret game and I want the enemy to randomly spawn somewhere within the layout (it will then proceed to travel towards the turret/player who must shoot it, etc.)

I can't for the life of me figure out a good way to get the baddie to respawn within a random area around the turret to generate a repeated assault upon the turret. I've messed with Create and create at offset to object, etc. and my current try is generating a random x and Y which yields no new creation (as opposed to other methods which worked, but didnt create the random spawning result i want) Here's my event screen so far.


Right click view to get the whole picture.

Any ideas? Again, trying to get baddies to spawn around the turret. Thanks in advance for help.


Here is a WIP link to my .cap http://www.mediafire.com/?5vp493h2rzdyaqa
B
1
G
2
Posts: 5
Reputation: 635

Post » Tue Dec 21, 2010 12:47 pm

Hopefully this is what you were after, you can change the global variable "SpawnDistance" as needed, it currently spawns the enemies 128 pixels away, or you could even randomize the spawn distance the same way i randomized the spawn angle.

Note: I saved this in 0.99.96, and it said you saved it in an older version, so you may need to upgrade to open it.

http://dl.dropbox.com/u/6660860/spawns.cap
B
7
S
2
G
4
Posts: 164
Reputation: 2,418

Post » Tue Dec 21, 2010 7:23 pm

Perfect!! I didn't get the highest grades in programming or math so this helps me very much!

Thanks for reminding me to update too...!
B
1
G
2
Posts: 5
Reputation: 635


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest